chore: resourceVersion can be a number

Signed-off-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
Gabriel committed 2023-05-16 10:39:36 +02:00
1 parent 6fc01284d3
commit 1f8c9c5103
3 files changed
+6 -13

No files matched your search

+3 -3
View File
@@ -97,7 +97,7 @@ export interface DerivedKubeApiOptions {
export interface KubeApiQueryParams {
watch?: boolean | number;
resourceVersion?: string;
resourceVersion?: string | number;
timeoutSeconds?: number;
limit?: number; // doesn't work with ?watch
continue?: string; // might be used with ?limit from second request
@@ -272,7 +272,7 @@ export class KubeApi<
public readonly objectConstructor: KubeObjectConstructor<Object, Data>;
protected readonly request: KubeJsonApi;
protected readonly resourceVersions = new Map<string, string>();
protected readonly resourceVersions = new Map<string, string | number>();
protected readonly watchDisposer: Disposer | undefined;
private watchId = 1;
protected readonly doCheckPreferredVersion: boolean;
@@ -385,7 +385,7 @@ export class KubeApi<
}
}
setResourceVersion(namespace = "", newVersion: string) {
setResourceVersion(namespace = "", newVersion: string | number) {
this.resourceVersions.set(namespace, newVersion);
}
+3 -3
View File
@@ -9,7 +9,7 @@ import type { KubeObject } from "./kube-object";
* The metadata for LIST requests to the KubeApi
*/
export interface KubeJsonApiListMetadata {
resourceVersion: string;
resourceVersion: string | number;
selfLink?: string;
}
@@ -229,7 +229,7 @@ export type KubeObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectSc
readonly selfLink: string;
readonly uid: string;
readonly name: string;
readonly resourceVersion: string;
readonly resourceVersion: string | number;
};
export type NamespaceScopedMetadata = KubeObjectMetadata<KubeObjectScope.Namespace>;
@@ -256,7 +256,7 @@ export interface EvictionObject {
orphanDependents?: boolean;
propagationPolicy?: string;
preconditions?: {
resourceVersion: string;
resourceVersion: string | number;
uid: string;
}[];
};
-7
View File
@@ -118,13 +118,6 @@ export class KubeObject<
);
}
if (!isString(data.metadata.resourceVersion)) {
throw new KubeCreationError(
`Cannot create a KubeObject from an object without metadata.resourceVersion being a string`,
data,
);
}
if (!isString(data.metadata.selfLink)) {
throw new KubeCreationError(
`Cannot create a KubeObject from an object without metadata.selfLink being a string`,