1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: resourceVersion can be a number

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

View File

@ -97,7 +97,7 @@ export interface DerivedKubeApiOptions {
export interface KubeApiQueryParams { export interface KubeApiQueryParams {
watch?: boolean | number; watch?: boolean | number;
resourceVersion?: string; resourceVersion?: string | number;
timeoutSeconds?: number; timeoutSeconds?: number;
limit?: number; // doesn't work with ?watch limit?: number; // doesn't work with ?watch
continue?: string; // might be used with ?limit from second request continue?: string; // might be used with ?limit from second request
@ -272,7 +272,7 @@ export class KubeApi<
public readonly objectConstructor: KubeObjectConstructor<Object, Data>; public readonly objectConstructor: KubeObjectConstructor<Object, Data>;
protected readonly request: KubeJsonApi; protected readonly request: KubeJsonApi;
protected readonly resourceVersions = new Map<string, string>(); protected readonly resourceVersions = new Map<string, string | number>();
protected readonly watchDisposer: Disposer | undefined; protected readonly watchDisposer: Disposer | undefined;
private watchId = 1; private watchId = 1;
protected readonly doCheckPreferredVersion: boolean; 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); this.resourceVersions.set(namespace, newVersion);
} }

View File

@ -9,7 +9,7 @@ import type { KubeObject } from "./kube-object";
* The metadata for LIST requests to the KubeApi * The metadata for LIST requests to the KubeApi
*/ */
export interface KubeJsonApiListMetadata { export interface KubeJsonApiListMetadata {
resourceVersion: string; resourceVersion: string | number;
selfLink?: string; selfLink?: string;
} }
@ -229,7 +229,7 @@ export type KubeObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectSc
readonly selfLink: string; readonly selfLink: string;
readonly uid: string; readonly uid: string;
readonly name: string; readonly name: string;
readonly resourceVersion: string; readonly resourceVersion: string | number;
}; };
export type NamespaceScopedMetadata = KubeObjectMetadata<KubeObjectScope.Namespace>; export type NamespaceScopedMetadata = KubeObjectMetadata<KubeObjectScope.Namespace>;
@ -256,7 +256,7 @@ export interface EvictionObject {
orphanDependents?: boolean; orphanDependents?: boolean;
propagationPolicy?: string; propagationPolicy?: string;
preconditions?: { preconditions?: {
resourceVersion: string; resourceVersion: string | number;
uid: string; uid: string;
}[]; }[];
}; };

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)) { if (!isString(data.metadata.selfLink)) {
throw new KubeCreationError( throw new KubeCreationError(
`Cannot create a KubeObject from an object without metadata.selfLink being a string`, `Cannot create a KubeObject from an object without metadata.selfLink being a string`,