Description
Describe the bug
When reading a Kubernetes object, the request must include the apiVersion
, kind
, and metadata
fields for the object. If the object is found, the response will include the spec
and status
.
It appears the KubernetesObjectApi.read()
type definition was accidentally changed in the 1.0.0 release, so the request and response object are the same.
Old type definition in 0.x:
Lines 19 to 27 in 8d4a84c
Lines 344 to 350 in 8d4a84c
The request payload is KubernetesObjectHeader<T>
and the response is T
.
New type definition in 1.0.0:
Lines 280 to 286 in 27ba0e1
The request payload is T
and the response is T
.
Client Version
N/A
Server Version
N/A
To Reproduce
Results in an error:
Argument of type '{ apiVersion: "networking.gke.io/v1"; kind: "ManagedCertificate"; metadata: { name: string; namespace: string; }; }' is not assignable to parameter of type 'GKEManagedCertificate'.
Property 'spec' is missing in type '{ apiVersion: "networking.gke.io/v1"; kind: "ManagedCertificate"; metadata: { name: string; namespace: string; }; }' but required in type 'GKEManagedCertificate'.(2345)
input.tsx(10, 5): 'spec' is declared here.
Expected behavior
For any type, only the apiVersion
, kind
, and metadata
fields should be required.
Example Code
import * as k8s from '@kubernetes/client-node';
interface GKEManagedCertificate extends k8s.KubernetesObject {
apiVersion: 'networking.gke.io/v1';
kind: 'ManagedCertificate';
metadata: {
name: string;
namespace?: string;
};
spec: {
domains: string[];
};
status?: {
certificateName: string;
certificateStatus: string;
domainStatus: { domain: string; status: string }[];
expireTime: string;
};
}
const client = new k8s.KubeConfig().makeApiClient(k8s.KubernetesObjectApi);
function readCertificate(name: string, namespace: string) {
const cert = client.read<GKEManagedCertificate>({
apiVersion: 'networking.gke.io/v1',
kind: 'ManagedCertificate',
metadata: { name, namespace }
});
return cert;
}
Environment (please complete the following information):
- OS: macOS
- NodeJS Version: 20.17.0
- Cloud runtime: N/A
Additional context
This only affects type checking, not runtime.