mirror of
https://github.com/lensapp/lens.git
synced 2024-11-10 10:36:25 +03:00
Fix breaking changes in extension API types (#5797)
This commit is contained in:
parent
2a37d6bfac
commit
d44599af00
@ -5,7 +5,7 @@
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { ClusterScopedMetadata, KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { RoleRef } from "./types/role-ref";
|
||||
import type { Subject } from "./types/subject";
|
||||
@ -15,7 +15,11 @@ export interface ClusterRoleBindingData extends KubeJsonApiData<KubeObjectMetada
|
||||
roleRef: RoleRef;
|
||||
}
|
||||
|
||||
export class ClusterRoleBinding extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
export class ClusterRoleBinding extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static kind = "ClusterRoleBinding";
|
||||
static namespaced = false;
|
||||
static apiBase = "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings";
|
||||
|
@ -6,7 +6,7 @@
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { ClusterScopedMetadata, KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { AggregationRule } from "./types/aggregation-rule";
|
||||
import type { PolicyRule } from "./types/policy-rule";
|
||||
@ -16,7 +16,11 @@ export interface ClusterRoleData extends KubeJsonApiData<KubeObjectMetadata<Kube
|
||||
aggregationRule?: AggregationRule;
|
||||
}
|
||||
|
||||
export class ClusterRole extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
export class ClusterRole extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static kind = "ClusterRole";
|
||||
static namespaced = false;
|
||||
static apiBase = "/apis/rbac.authorization.k8s.io/v1/clusterroles";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
@ -16,7 +16,11 @@ export interface ConfigMapData extends KubeJsonApiData<KubeObjectMetadata<KubeOb
|
||||
immutable?: boolean;
|
||||
}
|
||||
|
||||
export class ConfigMap extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class ConfigMap extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static kind = "ConfigMap";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/configmaps";
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import moment from "moment";
|
||||
import type { KubeObjectScope, ObjectReference } from "../kube-object";
|
||||
import type { NamespaceScopedMetadata, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { formatDuration } from "../../utils/formatDuration";
|
||||
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
@ -66,7 +66,11 @@ export interface CronJobStatus {
|
||||
active?: ObjectReference[];
|
||||
}
|
||||
|
||||
export class CronJob extends KubeObject<CronJobStatus, CronJobSpec, KubeObjectScope.Namespace> {
|
||||
export class CronJob extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
CronJobStatus,
|
||||
CronJobSpec
|
||||
> {
|
||||
static readonly kind = "CronJob";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/batch/v1beta1/cronjobs";
|
||||
|
@ -6,7 +6,7 @@
|
||||
import { getLegacyGlobalDiForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/legacy-global-di-for-extension-api";
|
||||
import customResourcesRouteInjectable from "../../front-end-routing/routes/cluster/custom-resources/custom-resources/custom-resources-route.injectable";
|
||||
import { buildURL } from "../../utils/buildUrl";
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, ClusterScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -107,7 +107,11 @@ export interface CustomResourceDefinitionStatus {
|
||||
storedVersions: string[];
|
||||
}
|
||||
|
||||
export class CustomResourceDefinition extends KubeObject<CustomResourceDefinitionStatus, CustomResourceDefinitionSpec, KubeObjectScope.Cluster> {
|
||||
export class CustomResourceDefinition extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
CustomResourceDefinitionStatus,
|
||||
CustomResourceDefinitionSpec
|
||||
> {
|
||||
static kind = "CustomResourceDefinition";
|
||||
static namespaced = false;
|
||||
static apiBase = "/apis/apiextensions.k8s.io/v1/customresourcedefinitions";
|
||||
|
@ -7,7 +7,7 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pod.api";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectStatus, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||
|
||||
@ -41,7 +41,11 @@ export interface DaemonSetStatus extends KubeObjectStatus {
|
||||
updatedNumberScheduled?: number;
|
||||
}
|
||||
|
||||
export class DaemonSet extends KubeObject<DaemonSetStatus, DaemonSetSpec, KubeObjectScope.Namespace> {
|
||||
export class DaemonSet extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
DaemonSetStatus,
|
||||
DaemonSetSpec
|
||||
> {
|
||||
static kind = "DaemonSet";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/daemonsets";
|
||||
|
@ -9,7 +9,7 @@ import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData, PodSpec } from "./pod.api";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectStatus, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { hasTypedProperty, isNumber, isObject } from "../../utils";
|
||||
|
||||
@ -116,7 +116,11 @@ export interface DeploymentStatus extends KubeObjectStatus {
|
||||
unavailableReplicas?: number;
|
||||
}
|
||||
|
||||
export class Deployment extends KubeObject<DeploymentStatus, DeploymentSpec, KubeObjectScope.Namespace> {
|
||||
export class Deployment extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
DeploymentStatus,
|
||||
DeploymentSpec
|
||||
> {
|
||||
static kind = "Deployment";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/deployments";
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { autoBind } from "../../utils";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, ObjectReference } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -75,7 +75,11 @@ export interface EndpointsData extends KubeJsonApiData<KubeObjectMetadata<KubeOb
|
||||
subsets?: EndpointSubset[];
|
||||
}
|
||||
|
||||
export class Endpoints extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class Endpoints extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static kind = "Endpoints";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/endpoints";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -97,7 +97,11 @@ interface MetricCurrentTarget {
|
||||
target?: string;
|
||||
}
|
||||
|
||||
export class HorizontalPodAutoscaler extends KubeObject<HorizontalPodAutoscalerStatus, HorizontalPodAutoscalerSpec, KubeObjectScope.Namespace> {
|
||||
export class HorizontalPodAutoscaler extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
HorizontalPodAutoscalerStatus,
|
||||
HorizontalPodAutoscalerSpec
|
||||
> {
|
||||
static readonly kind = "HorizontalPodAutoscaler";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/autoscaling/v2beta1/horizontalpodautoscalers";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope, TypedLocalObjectReference } from "../kube-object";
|
||||
import type { NamespaceScopedMetadata, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { hasTypedProperty, isString, iter } from "../../utils";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
@ -140,7 +140,11 @@ export interface IngressStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export class Ingress extends KubeObject<IngressStatus, IngressSpec, KubeObjectScope.Namespace> {
|
||||
export class Ingress extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
IngressStatus,
|
||||
IngressSpec
|
||||
> {
|
||||
static readonly kind = "Ingress";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/networking.k8s.io/v1/ingresses";
|
||||
|
@ -7,7 +7,7 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodContainer, PodMetricData, PodSpec } from "./pod.api";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectStatus, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
|
||||
export interface JobSpec {
|
||||
@ -38,7 +38,11 @@ export interface JobStatus extends KubeObjectStatus {
|
||||
succeeded: number;
|
||||
}
|
||||
|
||||
export class Job extends KubeObject<JobStatus, JobSpec, KubeObjectScope.Namespace> {
|
||||
export class Job extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
JobStatus,
|
||||
JobSpec
|
||||
> {
|
||||
static readonly kind = "Job";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/batch/v1/jobs";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import type { NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -39,7 +39,11 @@ export interface LimitRangeSpec {
|
||||
limits: LimitRangeItem[];
|
||||
}
|
||||
|
||||
export class LimitRange extends KubeObject<void, LimitRangeSpec, KubeObjectScope.Namespace> {
|
||||
export class LimitRange extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
LimitRangeSpec
|
||||
> {
|
||||
static readonly kind = "LimitRange";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/limitranges";
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeObjectScope, KubeObjectStatus } from "../kube-object";
|
||||
import type { ClusterScopedMetadata, KubeObjectStatus } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pod.api";
|
||||
@ -23,7 +23,11 @@ export interface NamespaceStatus extends KubeObjectStatus {
|
||||
phase?: string;
|
||||
}
|
||||
|
||||
export class Namespace extends KubeObject<NamespaceStatus, NamespaceSpec, KubeObjectScope.Cluster> {
|
||||
export class Namespace extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
NamespaceStatus,
|
||||
NamespaceSpec
|
||||
> {
|
||||
static readonly kind = "Namespace";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/api/v1/namespaces";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import type { LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -99,11 +99,11 @@ export interface NetworkPolicySpec {
|
||||
egress?: IPolicyEgress[];
|
||||
}
|
||||
|
||||
export interface NetworkPolicy {
|
||||
spec: NetworkPolicySpec;
|
||||
}
|
||||
|
||||
export class NetworkPolicy extends KubeObject<void, NetworkPolicySpec, KubeObjectScope.Namespace> {
|
||||
export class NetworkPolicy extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
NetworkPolicySpec
|
||||
> {
|
||||
static readonly kind = "NetworkPolicy";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/networking.k8s.io/v1/networkpolicies";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, ClusterScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { cpuUnitsToNumber, unitsToBytes, isObject } from "../../../renderer/utils";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
@ -176,7 +176,11 @@ export interface NodeStatus {
|
||||
volumesAttached?: AttachedVolume[];
|
||||
}
|
||||
|
||||
export class Node extends KubeObject<NodeStatus, NodeSpec, KubeObjectScope.Cluster> {
|
||||
export class Node extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
NodeStatus,
|
||||
NodeSpec
|
||||
> {
|
||||
static readonly kind = "Node";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/api/v1/nodes";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope, LabelSelector, TypedLocalObjectReference } from "../kube-object";
|
||||
import type { LabelSelector, NamespaceScopedMetadata, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
@ -53,7 +53,11 @@ export interface PersistentVolumeClaimStatus {
|
||||
phase: string; // Pending
|
||||
}
|
||||
|
||||
export class PersistentVolumeClaim extends KubeObject<PersistentVolumeClaimStatus, PersistentVolumeClaimSpec, KubeObjectScope.Namespace> {
|
||||
export class PersistentVolumeClaim extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
PersistentVolumeClaimStatus,
|
||||
PersistentVolumeClaimSpec
|
||||
> {
|
||||
static readonly kind = "PersistentVolumeClaim";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/persistentvolumeclaims";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope, LabelSelector, ObjectReference, TypedLocalObjectReference } from "../kube-object";
|
||||
import type { ClusterScopedMetadata, LabelSelector, ObjectReference, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { unitsToBytes } from "../../utils";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
@ -64,7 +64,11 @@ export interface PersistentVolumeStatus {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export class PersistentVolume extends KubeObject<PersistentVolumeStatus, PersistentVolumeSpec, KubeObjectScope.Cluster> {
|
||||
export class PersistentVolume extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
PersistentVolumeStatus,
|
||||
PersistentVolumeSpec
|
||||
> {
|
||||
static kind = "PersistentVolume";
|
||||
static namespaced = false;
|
||||
static apiBase = "/api/v1/persistentvolumes";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import type { LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -21,7 +21,11 @@ export interface PodDisruptionBudgetStatus {
|
||||
expectedPods: number;
|
||||
}
|
||||
|
||||
export class PodDisruptionBudget extends KubeObject<PodDisruptionBudgetStatus, PodDisruptionBudgetSpec, KubeObjectScope.Namespace> {
|
||||
export class PodDisruptionBudget extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
PodDisruptionBudgetStatus,
|
||||
PodDisruptionBudgetSpec
|
||||
> {
|
||||
static readonly kind = "PodDisruptionBudget";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/policy/v1beta1/poddisruptionbudgets";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -25,7 +25,11 @@ export interface PodMetricsContainer {
|
||||
usage: PodMetricsContainerUsage;
|
||||
}
|
||||
|
||||
export class PodMetrics extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class PodMetrics extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "PodMetrics";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/metrics.k8s.io/v1beta1/pods";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import type { ClusterScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -80,7 +80,11 @@ export interface PodSecurityPolicySpec {
|
||||
volumes?: string[];
|
||||
}
|
||||
|
||||
export class PodSecurityPolicy extends KubeObject<void, PodSecurityPolicySpec, KubeObjectScope.Cluster> {
|
||||
export class PodSecurityPolicy extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
PodSecurityPolicySpec
|
||||
> {
|
||||
static readonly kind = "PodSecurityPolicy";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/policy/v1beta1/podsecuritypolicies";
|
||||
|
@ -8,7 +8,7 @@ import { metricsApi } from "./metrics.api";
|
||||
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions, ResourceDescriptor } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { RequireExactlyOne } from "type-fest";
|
||||
import type { KubeObjectMetadata, LocalObjectReference, Affinity, Toleration, LabelSelector, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, LocalObjectReference, Affinity, Toleration, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import type { SecretReference } from "./secret.api";
|
||||
import type { PersistentVolumeClaimSpec } from "./persistent-volume-claim.api";
|
||||
import { KubeObject } from "../kube-object";
|
||||
@ -776,7 +776,11 @@ export interface PodStatus {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export class Pod extends KubeObject<PodStatus, PodSpec, KubeObjectScope.Namespace> {
|
||||
export class Pod extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
PodStatus,
|
||||
PodSpec
|
||||
> {
|
||||
static kind = "Pod";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/pods";
|
||||
|
@ -7,7 +7,7 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pod.api";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectStatus, LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||
|
||||
@ -73,7 +73,11 @@ export interface ReplicaSetStatus extends KubeObjectStatus {
|
||||
observedGeneration?: number;
|
||||
}
|
||||
|
||||
export class ReplicaSet extends KubeObject<ReplicaSetStatus, ReplicaSetSpec, KubeObjectScope.Namespace> {
|
||||
export class ReplicaSet extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
ReplicaSetStatus,
|
||||
ReplicaSetSpec
|
||||
> {
|
||||
static kind = "ReplicaSet";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/replicasets";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import type { NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -50,7 +50,11 @@ export interface ResourceQuotaStatus {
|
||||
used: IResourceQuotaValues;
|
||||
}
|
||||
|
||||
export class ResourceQuota extends KubeObject<ResourceQuotaStatus, ResourceQuotaSpec, KubeObjectScope.Namespace> {
|
||||
export class ResourceQuota extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
ResourceQuotaStatus,
|
||||
ResourceQuotaSpec
|
||||
> {
|
||||
static readonly kind = "ResourceQuota";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/resourcequotas";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -16,7 +16,11 @@ export interface RoleBindingData extends KubeJsonApiData<KubeObjectMetadata<Kube
|
||||
roleRef: RoleRef;
|
||||
}
|
||||
|
||||
export class RoleBinding extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class RoleBinding extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "RoleBinding";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/rbac.authorization.k8s.io/v1/rolebindings";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -14,7 +14,11 @@ export interface RoleData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectS
|
||||
rules?: PolicyRule[];
|
||||
}
|
||||
|
||||
export class Role extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class Role extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "Role";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/rbac.authorization.k8s.io/v1/roles";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import { autoBind } from "../../utils";
|
||||
@ -42,7 +42,11 @@ export interface SecretData extends KubeJsonApiData<KubeObjectMetadata<KubeObjec
|
||||
data?: Partial<Record<string, string>>;
|
||||
}
|
||||
|
||||
export class Secret extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class Secret extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "Secret";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/secrets";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope, LocalObjectReference, ObjectReference } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, LocalObjectReference, NamespaceScopedMetadata, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -15,7 +15,11 @@ export interface ServiceAccountData extends KubeJsonApiData<KubeObjectMetadata<K
|
||||
secrets?: ObjectReference[];
|
||||
}
|
||||
|
||||
export class ServiceAccount extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
export class ServiceAccount extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "ServiceAccount";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/serviceaccounts";
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import type { NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -60,7 +60,11 @@ export interface ServiceStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export class Service extends KubeObject<ServiceStatus, ServiceSpec, KubeObjectScope.Namespace> {
|
||||
export class Service extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
ServiceStatus,
|
||||
ServiceSpec
|
||||
> {
|
||||
static readonly kind = "Service";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/services";
|
||||
|
@ -7,7 +7,7 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pod.api";
|
||||
import type { KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import type { LabelSelector, NamespaceScopedMetadata } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||
import type { PersistentVolumeClaimTemplateSpec } from "./types/persistent-volume-claim-template-spec";
|
||||
@ -81,7 +81,11 @@ export interface StatefulSetStatus {
|
||||
collisionCount: number;
|
||||
}
|
||||
|
||||
export class StatefulSet extends KubeObject<StatefulSetStatus, StatefulSetSpec, KubeObjectScope.Namespace> {
|
||||
export class StatefulSet extends KubeObject<
|
||||
NamespaceScopedMetadata,
|
||||
StatefulSetStatus,
|
||||
StatefulSetSpec
|
||||
> {
|
||||
static readonly kind = "StatefulSet";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/apps/v1/statefulsets";
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { autoBind } from "../../utils";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import type { ClusterScopedMetadata, KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -29,7 +29,11 @@ export interface StorageClassData extends KubeJsonApiData<KubeObjectMetadata<Kub
|
||||
volumeBindingMode?: string;
|
||||
}
|
||||
|
||||
export class StorageClass extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
export class StorageClass extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "StorageClass";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/storage.k8s.io/v1/storageclasses";
|
||||
|
@ -10,7 +10,7 @@ import { stringify } from "querystring";
|
||||
import { apiKubePrefix, isDevelopment } from "../../common/vars";
|
||||
import { apiBase, apiKube } from "./index";
|
||||
import { createKubeApiURL, parseKubeApi } from "./kube-api-parse";
|
||||
import type { KubeObjectConstructor, KubeJsonApiDataFor, KubeObjectMetadata, KubeObjectScope } from "./kube-object";
|
||||
import type { KubeObjectConstructor, KubeJsonApiDataFor, KubeObjectMetadata } from "./kube-object";
|
||||
import { KubeObject, KubeStatus, isKubeStatusData } from "./kube-object";
|
||||
import byline from "byline";
|
||||
import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||
@ -32,7 +32,7 @@ import autoRegistrationEmitterInjectable from "./api-manager/auto-registration-e
|
||||
/**
|
||||
* The options used for creating a `KubeApi`
|
||||
*/
|
||||
export interface KubeApiOptions<T extends KubeObject<any, any, KubeObjectScope>, Data extends KubeJsonApiDataFor<T> = KubeJsonApiDataFor<T>> extends DerivedKubeApiOptions {
|
||||
export interface KubeApiOptions<T extends KubeObject, Data extends KubeJsonApiDataFor<T> = KubeJsonApiDataFor<T>> extends DerivedKubeApiOptions {
|
||||
/**
|
||||
* base api-path for listing all resources, e.g. "/api/v1/pods"
|
||||
*
|
||||
@ -171,7 +171,7 @@ export interface IRemoteKubeApiConfig {
|
||||
};
|
||||
/**
|
||||
* Custom instance of https.agent to use for the requests
|
||||
*
|
||||
*
|
||||
* @remarks the custom agent replaced default agent, options skipTLSVerify,
|
||||
* clientCertificateData, clientKeyData and caData are ignored.
|
||||
*/
|
||||
@ -179,17 +179,17 @@ export interface IRemoteKubeApiConfig {
|
||||
}
|
||||
|
||||
export function forCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Api extends KubeApi<Object>,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(cluster: ILocalKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass: new (apiOpts: KubeApiOptions<Object>) => Api): Api;
|
||||
export function forCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(cluster: ILocalKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass?: new (apiOpts: KubeApiOptions<Object>) => KubeApi<Object>): KubeApi<Object>;
|
||||
|
||||
export function forCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(cluster: ILocalKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass: (new (apiOpts: KubeApiOptions<Object>) => KubeApi<Object>) = KubeApi): KubeApi<Object> {
|
||||
const url = new URL(apiBase.config.serverAddress);
|
||||
@ -210,17 +210,17 @@ export function forCluster<
|
||||
}
|
||||
|
||||
export function forRemoteCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Api extends KubeApi<Object>,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(config: IRemoteKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass: new (apiOpts: KubeApiOptions<Object>) => Api): Api;
|
||||
export function forRemoteCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(config: IRemoteKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass?: new (apiOpts: KubeApiOptions<Object>) => KubeApi<Object>): KubeApi<Object>;
|
||||
|
||||
export function forRemoteCluster<
|
||||
Object extends KubeObject<any, any, KubeObjectScope>,
|
||||
Object extends KubeObject,
|
||||
Api extends KubeApi<Object>,
|
||||
Data extends KubeJsonApiDataFor<Object>,
|
||||
>(config: IRemoteKubeApiConfig, kubeClass: KubeObjectConstructor<Object, Data>, apiClass: new (apiOpts: KubeApiOptions<Object>) => KubeApi<Object> = KubeApi): KubeApi<Object> {
|
||||
@ -277,7 +277,7 @@ export function forRemoteCluster<
|
||||
|
||||
export type KubeApiWatchCallback<T extends KubeJsonApiData = KubeJsonApiData> = (data: IKubeWatchEvent<T>, error: any) => void;
|
||||
|
||||
export interface KubeApiWatchOptions<Object extends KubeObject<any, any, KubeObjectScope>, Data extends KubeJsonApiDataFor<Object>> {
|
||||
export interface KubeApiWatchOptions<Object extends KubeObject, Data extends KubeJsonApiDataFor<Object>> {
|
||||
namespace: string;
|
||||
callback?: KubeApiWatchCallback<Data>;
|
||||
abortController?: AbortController;
|
||||
|
@ -83,6 +83,8 @@ export type KubeApiDataFrom<K extends KubeObject, A> = A extends KubeApi<K, infe
|
||||
: never
|
||||
: never;
|
||||
|
||||
export type JsonPatch = Patch;
|
||||
|
||||
export abstract class KubeObjectStore<
|
||||
K extends KubeObject = KubeObject,
|
||||
A extends KubeApi<K, D> = KubeApi<K, KubeJsonApiDataFor<K>>,
|
||||
@ -90,7 +92,7 @@ export abstract class KubeObjectStore<
|
||||
> extends ItemStore<K> {
|
||||
static readonly defaultContext = observable.box<ClusterContext>(); // TODO: support multiple cluster contexts
|
||||
|
||||
public readonly api: A;
|
||||
public readonly api!: A;
|
||||
public readonly limit: number | undefined;
|
||||
public readonly bufferSize: number;
|
||||
@observable private loadedNamespaces: string[] | undefined = undefined;
|
||||
@ -103,9 +105,18 @@ export abstract class KubeObjectStore<
|
||||
return when(() => Boolean(this.loadedNamespaces));
|
||||
}
|
||||
|
||||
constructor(api: A, opts?: KubeObjectStoreOptions) {
|
||||
constructor(api: A, opts?: KubeObjectStoreOptions);
|
||||
/**
|
||||
* @deprecated Supply API instance through constructor
|
||||
*/
|
||||
constructor();
|
||||
constructor(api?: A, opts?: KubeObjectStoreOptions) {
|
||||
super();
|
||||
this.api = api;
|
||||
|
||||
if (api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
this.limit = opts?.limit;
|
||||
this.bufferSize = opts?.bufferSize ?? 50_000;
|
||||
|
||||
@ -376,7 +387,7 @@ export abstract class KubeObjectStore<
|
||||
return newItem;
|
||||
}
|
||||
|
||||
async patch(item: K, patch: Patch): Promise<K> {
|
||||
async patch(item: K, patch: JsonPatch): Promise<K> {
|
||||
const rawItem = await this.api.patch(
|
||||
{
|
||||
name: item.getName(), namespace: item.getNs(),
|
||||
|
@ -15,8 +15,8 @@ import type { Patch } from "rfc6902";
|
||||
import assert from "assert";
|
||||
import type { JsonObject } from "type-fest";
|
||||
|
||||
export type KubeJsonApiDataFor<K> = K extends KubeObject<infer Status, infer Spec, infer Scope>
|
||||
? KubeJsonApiData<KubeObjectMetadata<Scope>, Status, Spec>
|
||||
export type KubeJsonApiDataFor<K> = K extends KubeObject<infer Metadata, infer Status, infer Spec>
|
||||
? KubeJsonApiData<Metadata, Status, Spec>
|
||||
: never;
|
||||
|
||||
export interface KubeObjectConstructorData {
|
||||
@ -25,7 +25,7 @@ export interface KubeObjectConstructorData {
|
||||
readonly apiBase?: string;
|
||||
}
|
||||
|
||||
export type KubeObjectConstructor<K extends KubeObject<any, any, KubeObjectScope>, Data> = (new (data: Data) => K) & KubeObjectConstructorData;
|
||||
export type KubeObjectConstructor<K extends KubeObject, Data> = (new (data: Data) => K) & KubeObjectConstructorData;
|
||||
|
||||
export interface OwnerReference {
|
||||
apiVersion: string;
|
||||
@ -199,9 +199,11 @@ export interface BaseKubeJsonApiObjectMetadata<Namespaced extends KubeObjectScop
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export type KubeJsonApiObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = Namespaced extends KubeObjectScope.Namespace
|
||||
? BaseKubeJsonApiObjectMetadata<KubeObjectScope.Namespace> & { readonly namespace: string }
|
||||
: BaseKubeJsonApiObjectMetadata<Namespaced>;
|
||||
export type KubeJsonApiObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = BaseKubeJsonApiObjectMetadata<Namespaced> & (
|
||||
Namespaced extends KubeObjectScope.Namespace
|
||||
? { readonly namespace: string }
|
||||
: {}
|
||||
);
|
||||
|
||||
export type KubeObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = KubeJsonApiObjectMetadata<Namespaced> & {
|
||||
readonly selfLink: string;
|
||||
@ -210,6 +212,9 @@ export type KubeObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectSc
|
||||
readonly resourceVersion: string;
|
||||
};
|
||||
|
||||
export type NamespaceScopedMetadata = KubeObjectMetadata<KubeObjectScope.Namespace>;
|
||||
export type ClusterScopedMetadata = KubeObjectMetadata<KubeObjectScope.Cluster>;
|
||||
|
||||
export interface KubeStatusData {
|
||||
kind: string;
|
||||
apiVersion: string;
|
||||
@ -371,9 +376,9 @@ export type ScopedNamespace<Namespaced extends KubeObjectScope> = (
|
||||
);
|
||||
|
||||
export class KubeObject<
|
||||
Metadata extends KubeObjectMetadata<KubeObjectScope> = KubeObjectMetadata<KubeObjectScope>,
|
||||
Status = unknown,
|
||||
Spec = unknown,
|
||||
Namespaced extends KubeObjectScope = KubeObjectScope,
|
||||
> implements ItemObject {
|
||||
static readonly kind?: string;
|
||||
static readonly namespaced?: boolean;
|
||||
@ -381,7 +386,7 @@ export class KubeObject<
|
||||
|
||||
apiVersion!: string;
|
||||
kind!: string;
|
||||
metadata!: KubeObjectMetadata<Namespaced>;
|
||||
metadata!: Metadata;
|
||||
status?: Status;
|
||||
spec!: Spec;
|
||||
|
||||
@ -393,7 +398,7 @@ export class KubeObject<
|
||||
return new KubeObject(data);
|
||||
}
|
||||
|
||||
static isNonSystem(item: KubeJsonApiData | KubeObject<unknown, unknown, KubeObjectScope>) {
|
||||
static isNonSystem(item: KubeJsonApiData | KubeObject<KubeObjectMetadata<KubeObjectScope>, unknown, unknown>) {
|
||||
return !item.metadata.name?.startsWith("system:");
|
||||
}
|
||||
|
||||
@ -488,7 +493,7 @@ export class KubeObject<
|
||||
...KubeObject.nonEditablePathPrefixes,
|
||||
]);
|
||||
|
||||
constructor(data: KubeJsonApiData<KubeObjectMetadata<Namespaced>, Status, Spec>) {
|
||||
constructor(data: KubeJsonApiData<Metadata, Status, Spec>) {
|
||||
if (typeof data !== "object") {
|
||||
throw new TypeError(`Cannot create a KubeObject from ${typeof data}`);
|
||||
}
|
||||
@ -524,7 +529,7 @@ export class KubeObject<
|
||||
return this.metadata.name;
|
||||
}
|
||||
|
||||
getNs(): ScopedNamespace<Namespaced> {
|
||||
getNs(): Metadata["namespace"] {
|
||||
// avoid "null" serialization via JSON.stringify when post data
|
||||
return (this.metadata.namespace || undefined) as never;
|
||||
}
|
||||
|
@ -25,14 +25,22 @@ export {
|
||||
export {
|
||||
KubeObject,
|
||||
KubeStatus,
|
||||
type OwnerReference,
|
||||
type KubeObjectMetadata,
|
||||
type NamespaceScopedMetadata,
|
||||
type ClusterScopedMetadata,
|
||||
type BaseKubeJsonApiObjectMetadata,
|
||||
type KubeJsonApiObjectMetadata,
|
||||
type KubeStatusData,
|
||||
} from "../../common/k8s-api/kube-object";
|
||||
|
||||
export {
|
||||
type KubeJsonApiData,
|
||||
} from "../../common/k8s-api/kube-json-api";
|
||||
|
||||
export {
|
||||
KubeObjectStore,
|
||||
type JsonPatch,
|
||||
type KubeObjectStoreLoadAllParams,
|
||||
type KubeObjectStoreLoadingParams,
|
||||
type KubeObjectStoreSubscribeParams,
|
||||
|
@ -16,7 +16,7 @@ import { Input } from "../input";
|
||||
import type { AdditionalPrinterColumnsV1 } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import { convertKubectlJsonPathToNodeJsonPath } from "../../utils/jsonPath";
|
||||
import type { KubeObjectStatus } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectStatus } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import logger from "../../../common/logger";
|
||||
import { JSONPath } from "@astronautlabs/jsonpath";
|
||||
@ -71,7 +71,8 @@ export class CustomResourceDetails extends React.Component<CustomResourceDetails
|
||||
));
|
||||
}
|
||||
|
||||
renderStatus(customResource: KubeObject<KubeObjectStatus, unknown>, columns: AdditionalPrinterColumnsV1[]) {
|
||||
renderStatus(cr: KubeObject, columns: AdditionalPrinterColumnsV1[]) {
|
||||
const customResource = cr as KubeObject<KubeObjectMetadata, KubeObjectStatus, unknown>;
|
||||
const showStatus = !columns.find(column => column.name == "Status") && Array.isArray(customResource.status?.conditions);
|
||||
|
||||
if (!showStatus) {
|
||||
|
@ -9,7 +9,7 @@ import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import { cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
||||
import type { Pod, PodMetrics, PodApi, PodMetricsApi } from "../../../common/k8s-api/endpoints";
|
||||
import type { KubeObject, KubeObjectScope } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject, NamespaceScopedMetadata } from "../../../common/k8s-api/kube-object";
|
||||
|
||||
export interface PodStoreDependencies {
|
||||
readonly podMetricsApi: PodMetricsApi;
|
||||
@ -36,7 +36,7 @@ export class PodStore extends KubeObjectStore<Pod, PodApi> {
|
||||
}
|
||||
}
|
||||
|
||||
getPodsByOwner(workload: KubeObject<unknown, unknown, KubeObjectScope.Namespace>): Pod[] {
|
||||
getPodsByOwner(workload: KubeObject<NamespaceScopedMetadata, unknown, unknown>): Pod[] {
|
||||
return this.items.filter(pod => (
|
||||
pod.getOwnerRefs()
|
||||
.find(owner => owner.uid === workload.getId())
|
||||
|
Loading…
Reference in New Issue
Block a user