mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace KubeObject scope strings with enum
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
0e3bf40e21
commit
d4e2848f90
@ -6,17 +6,17 @@ import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { KubeObjectMetadata } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { RoleRef } from "./types/role-ref";
|
||||
import type { Subject } from "./types/subject";
|
||||
|
||||
export interface ClusterRoleBindingData extends KubeJsonApiData<KubeObjectMetadata<"cluster-scoped">, void, void> {
|
||||
export interface ClusterRoleBindingData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Cluster>, void, void> {
|
||||
subjects?: Subject[];
|
||||
roleRef: RoleRef;
|
||||
}
|
||||
|
||||
export class ClusterRoleBinding extends KubeObject<void, void, "cluster-scoped"> {
|
||||
export class ClusterRoleBinding extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
static kind = "ClusterRoleBinding";
|
||||
static namespaced = false;
|
||||
static apiBase = "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings";
|
||||
|
||||
@ -7,17 +7,17 @@ import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { KubeObjectMetadata } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { AggregationRule } from "./types/aggregation-rule";
|
||||
import type { PolicyRule } from "./types/policy-rule";
|
||||
|
||||
export interface ClusterRoleData extends KubeJsonApiData<KubeObjectMetadata<"cluster-scoped">, void, void> {
|
||||
export interface ClusterRoleData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Cluster>, void, void> {
|
||||
rules?: PolicyRule[];
|
||||
aggregationRule?: AggregationRule;
|
||||
}
|
||||
|
||||
export class ClusterRole extends KubeObject<void, void, "cluster-scoped"> {
|
||||
export class ClusterRole extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
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 } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
@ -11,13 +11,13 @@ import { KubeApi } from "../kube-api";
|
||||
import { autoBind } from "../../utils";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
|
||||
export interface ConfigMapData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface ConfigMapData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
data?: Partial<Record<string, string>>;
|
||||
binaryData?: Partial<Record<string, string>>;
|
||||
immutable?: boolean;
|
||||
}
|
||||
|
||||
export class ConfigMap extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class ConfigMap extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
static kind = "ConfigMap";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/configmaps";
|
||||
|
||||
@ -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 } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -102,7 +102,7 @@ export interface CustomResourceDefinitionStatus {
|
||||
storedVersions: string[];
|
||||
}
|
||||
|
||||
export class CustomResourceDefinition extends KubeObject<CustomResourceDefinitionStatus, CustomResourceDefinitionSpec, "cluster-scoped"> {
|
||||
export class CustomResourceDefinition extends KubeObject<CustomResourceDefinitionStatus, CustomResourceDefinitionSpec, KubeObjectScope.Cluster> {
|
||||
static kind = "CustomResourceDefinition";
|
||||
static namespaced = false;
|
||||
static apiBase = "/apis/apiextensions.k8s.io/v1/customresourcedefinitions";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import moment from "moment";
|
||||
import type { ObjectReference } from "../kube-object";
|
||||
import type { KubeObjectScope, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { formatDuration } from "../../utils/formatDuration";
|
||||
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
@ -67,7 +67,7 @@ export interface CronJobStatus {
|
||||
active?: ObjectReference[];
|
||||
}
|
||||
|
||||
export class CronJob extends KubeObject<CronJobStatus, CronJobSpec, "namespace-scoped"> {
|
||||
export class CronJob extends KubeObject<CronJobStatus, CronJobSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "CronJob";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/batch/v1beta1/cronjobs";
|
||||
|
||||
@ -8,7 +8,7 @@ import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||
|
||||
@ -42,7 +42,7 @@ export interface DaemonSetStatus extends KubeObjectStatus {
|
||||
updatedNumberScheduled?: number;
|
||||
}
|
||||
|
||||
export class DaemonSet extends KubeObject<DaemonSetStatus, DaemonSetSpec, "namespace-scoped"> {
|
||||
export class DaemonSet extends KubeObject<DaemonSetStatus, DaemonSetSpec, KubeObjectScope.Namespace> {
|
||||
static kind = "DaemonSet";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/daemonsets";
|
||||
|
||||
@ -10,7 +10,7 @@ import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData, PodSpec } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { hasTypedProperty, isNumber, isObject } from "../../utils";
|
||||
|
||||
@ -117,7 +117,7 @@ export interface DeploymentStatus extends KubeObjectStatus {
|
||||
unavailableReplicas?: number;
|
||||
}
|
||||
|
||||
export class Deployment extends KubeObject<DeploymentStatus, DeploymentSpec, "namespace-scoped"> {
|
||||
export class Deployment extends KubeObject<DeploymentStatus, DeploymentSpec, KubeObjectScope.Namespace> {
|
||||
static kind = "Deployment";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/deployments";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { autoBind } from "../../utils";
|
||||
import type { KubeObjectMetadata, ObjectReference } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -72,11 +72,11 @@ export interface EndpointSubset {
|
||||
ports?: EndpointPort[];
|
||||
}
|
||||
|
||||
export interface EndpointsData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface EndpointsData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
subsets?: EndpointSubset[];
|
||||
}
|
||||
|
||||
export class Endpoints extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class Endpoints extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
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, LabelSelector } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -98,7 +98,7 @@ interface MetricCurrentTarget {
|
||||
target?: string | undefined;
|
||||
}
|
||||
|
||||
export class HorizontalPodAutoscaler extends KubeObject<HorizontalPodAutoscalerStatus, HorizontalPodAutoscalerSpec, "namespace-scoped"> {
|
||||
export class HorizontalPodAutoscaler extends KubeObject<HorizontalPodAutoscalerStatus, HorizontalPodAutoscalerSpec, KubeObjectScope.Namespace> {
|
||||
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 { TypedLocalObjectReference } from "../kube-object";
|
||||
import type { KubeObjectScope, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { hasTypedProperty, isString, iter } from "../../utils";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
@ -141,7 +141,7 @@ export interface IngressStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export class Ingress extends KubeObject<IngressStatus, IngressSpec, "namespace-scoped"> {
|
||||
export class Ingress extends KubeObject<IngressStatus, IngressSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "Ingress";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/networking.k8s.io/v1/ingresses";
|
||||
|
||||
@ -8,7 +8,7 @@ import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { IPodContainer, PodMetricData, PodSpec } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
|
||||
export interface JobSpec {
|
||||
@ -39,7 +39,7 @@ export interface JobStatus extends KubeObjectStatus {
|
||||
succeeded: number;
|
||||
}
|
||||
|
||||
export class Job extends KubeObject<JobStatus, JobSpec, "namespace-scoped"> {
|
||||
export class Job extends KubeObject<JobStatus, JobSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "Job";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/batch/v1/jobs";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -39,7 +40,7 @@ export interface LimitRangeSpec {
|
||||
limits: LimitRangeItem[];
|
||||
}
|
||||
|
||||
export class LimitRange extends KubeObject<void, LimitRangeSpec, "namespace-scoped"> {
|
||||
export class LimitRange extends KubeObject<void, LimitRangeSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "LimitRange";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/limitranges";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeObjectStatus } from "../kube-object";
|
||||
import type { KubeObjectScope, KubeObjectStatus } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pods.api";
|
||||
@ -23,7 +23,7 @@ export interface NamespaceStatus extends KubeObjectStatus {
|
||||
phase?: string;
|
||||
}
|
||||
|
||||
export class Namespace extends KubeObject<NamespaceStatus, NamespaceSpec, "cluster-scoped"> {
|
||||
export class Namespace extends KubeObject<NamespaceStatus, NamespaceSpec, KubeObjectScope.Cluster> {
|
||||
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 { LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -104,7 +104,7 @@ export interface NetworkPolicy {
|
||||
spec: NetworkPolicySpec;
|
||||
}
|
||||
|
||||
export class NetworkPolicy extends KubeObject<void, NetworkPolicySpec, "namespace-scoped"> {
|
||||
export class NetworkPolicy extends KubeObject<void, NetworkPolicySpec, KubeObjectScope.Namespace> {
|
||||
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 } from "../kube-object";
|
||||
import type { BaseKubeObjectCondition, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { cpuUnitsToNumber, unitsToBytes } from "../../../renderer/utils";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
@ -166,7 +166,7 @@ export interface NodeStatus {
|
||||
volumesAttached?: AttachedVolume[];
|
||||
}
|
||||
|
||||
export class Node extends KubeObject<NodeStatus, NodeSpec, "cluster-scoped"> {
|
||||
export class Node extends KubeObject<NodeStatus, NodeSpec, KubeObjectScope.Cluster> {
|
||||
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 { LabelSelector, TypedLocalObjectReference } from "../kube-object";
|
||||
import type { KubeObjectScope, LabelSelector, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { MetricData } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
@ -54,7 +54,7 @@ export interface PersistentVolumeClaimStatus {
|
||||
phase: string; // Pending
|
||||
}
|
||||
|
||||
export class PersistentVolumeClaim extends KubeObject<PersistentVolumeClaimStatus, PersistentVolumeClaimSpec, "namespace-scoped"> {
|
||||
export class PersistentVolumeClaim extends KubeObject<PersistentVolumeClaimStatus, PersistentVolumeClaimSpec, KubeObjectScope.Namespace> {
|
||||
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 { LabelSelector, ObjectReference, TypedLocalObjectReference } from "../kube-object";
|
||||
import type { KubeObjectScope, LabelSelector, ObjectReference, TypedLocalObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { unitsToBytes } from "../../utils";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
@ -65,7 +65,7 @@ export interface PersistentVolumeStatus {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export class PersistentVolume extends KubeObject<PersistentVolumeStatus, PersistentVolumeSpec, "cluster-scoped"> {
|
||||
export class PersistentVolume extends KubeObject<PersistentVolumeStatus, PersistentVolumeSpec, KubeObjectScope.Cluster> {
|
||||
static kind = "PersistentVolume";
|
||||
static namespaced = false;
|
||||
static apiBase = "/api/v1/persistentvolumes";
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
|
||||
export interface PodMetricsData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface PodMetricsData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
timestamp: string;
|
||||
window: string;
|
||||
containers: PodMetricsContainer[];
|
||||
@ -26,7 +26,7 @@ export interface PodMetricsContainer {
|
||||
usage: PodMetricsContainerUsage;
|
||||
}
|
||||
|
||||
export class PodMetrics extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class PodMetrics extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
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 { LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -22,7 +22,7 @@ export interface PodDisruptionBudgetStatus {
|
||||
expectedPods: number;
|
||||
}
|
||||
|
||||
export class PodDisruptionBudget extends KubeObject<PodDisruptionBudgetStatus, PodDisruptionBudgetSpec, "namespace-scoped"> {
|
||||
export class PodDisruptionBudget extends KubeObject<PodDisruptionBudgetStatus, PodDisruptionBudgetSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "PodDisruptionBudget";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/apis/policy/v1beta1/poddisruptionbudgets";
|
||||
|
||||
@ -9,7 +9,7 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { RequireExactlyOne } from "type-fest";
|
||||
import type { KubeObjectMetadata, LocalObjectReference, Affinity, Toleration, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectMetadata, LocalObjectReference, Affinity, Toleration, LabelSelector, KubeObjectScope } from "../kube-object";
|
||||
import type { SecretReference } from "./secret.api";
|
||||
import type { PersistentVolumeClaimSpec } from "./persistent-volume-claims.api";
|
||||
import { KubeObject } from "../kube-object";
|
||||
@ -759,7 +759,7 @@ export interface PodStatus {
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export class Pod extends KubeObject<PodStatus, PodSpec, "namespace-scoped"> {
|
||||
export class Pod extends KubeObject<PodStatus, PodSpec, KubeObjectScope.Namespace> {
|
||||
static kind = "Pod";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/pods";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -80,7 +81,7 @@ export interface PodSecurityPolicySpec {
|
||||
volumes?: string[];
|
||||
}
|
||||
|
||||
export class PodSecurityPolicy extends KubeObject<void, PodSecurityPolicySpec, "cluster-scoped"> {
|
||||
export class PodSecurityPolicy extends KubeObject<void, PodSecurityPolicySpec, KubeObjectScope.Cluster> {
|
||||
static readonly kind = "PodSecurityPolicy";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/policy/v1beta1/podsecuritypolicies";
|
||||
|
||||
@ -8,7 +8,7 @@ import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||
|
||||
@ -74,7 +74,7 @@ export interface ReplicaSetStatus extends KubeObjectStatus {
|
||||
observedGeneration?: number;
|
||||
}
|
||||
|
||||
export class ReplicaSet extends KubeObject<ReplicaSetStatus, ReplicaSetSpec, "namespace-scoped"> {
|
||||
export class ReplicaSet extends KubeObject<ReplicaSetStatus, ReplicaSetSpec, KubeObjectScope.Namespace> {
|
||||
static kind = "ReplicaSet";
|
||||
static namespaced = true;
|
||||
static apiBase = "/apis/apps/v1/replicasets";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -50,7 +51,7 @@ export interface ResourceQuotaStatus {
|
||||
used: IResourceQuotaValues;
|
||||
}
|
||||
|
||||
export class ResourceQuota extends KubeObject<ResourceQuotaStatus, ResourceQuotaSpec, "namespace-scoped"> {
|
||||
export class ResourceQuota extends KubeObject<ResourceQuotaStatus, ResourceQuotaSpec, KubeObjectScope.Namespace> {
|
||||
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 } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -12,12 +12,12 @@ import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { RoleRef } from "./types/role-ref";
|
||||
import type { Subject } from "./types/subject";
|
||||
|
||||
export interface RoleBindingData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface RoleBindingData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
subjects?: Subject[];
|
||||
roleRef: RoleRef;
|
||||
}
|
||||
|
||||
export class RoleBinding extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class RoleBinding extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
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 } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -11,11 +11,11 @@ import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { PolicyRule } from "./types/policy-rule";
|
||||
|
||||
export interface RoleData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface RoleData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
rules?: PolicyRule[];
|
||||
}
|
||||
|
||||
export class Role extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class Role extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
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 } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import { autoBind } from "../../utils";
|
||||
@ -27,12 +27,12 @@ export interface SecretReference {
|
||||
namespace?: string;
|
||||
}
|
||||
|
||||
export interface SecretData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface SecretData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
type: SecretType;
|
||||
data?: Partial<Record<string, string>>;
|
||||
}
|
||||
|
||||
export class Secret extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class Secret extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "Secret";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/secrets";
|
||||
|
||||
@ -3,20 +3,20 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, LocalObjectReference, ObjectReference } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, LocalObjectReference, ObjectReference } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
|
||||
export interface ServiceAccountData extends KubeJsonApiData<KubeObjectMetadata<"namespace-scoped">, void, void> {
|
||||
export interface ServiceAccountData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||
automountServiceAccountToken?: boolean;
|
||||
imagePullSecrets?: LocalObjectReference[];
|
||||
secrets?: ObjectReference[];
|
||||
}
|
||||
|
||||
export class ServiceAccount extends KubeObject<void, void, "namespace-scoped"> {
|
||||
export class ServiceAccount extends KubeObject<void, void, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "ServiceAccount";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/serviceaccounts";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -60,7 +61,7 @@ export interface ServiceStatus {
|
||||
};
|
||||
}
|
||||
|
||||
export class Service extends KubeObject<ServiceStatus, ServiceSpec, "namespace-scoped"> {
|
||||
export class Service extends KubeObject<ServiceStatus, ServiceSpec, KubeObjectScope.Namespace> {
|
||||
static readonly kind = "Service";
|
||||
static readonly namespaced = true;
|
||||
static readonly apiBase = "/api/v1/services";
|
||||
|
||||
@ -8,7 +8,7 @@ import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { PodMetricData } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
import type { LabelSelector } from "../kube-object";
|
||||
import type { KubeObjectScope, LabelSelector } 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";
|
||||
@ -82,7 +82,7 @@ export interface StatefulSetStatus {
|
||||
collisionCount: number;
|
||||
}
|
||||
|
||||
export class StatefulSet extends KubeObject<StatefulSetStatus, StatefulSetSpec, "namespace-scoped"> {
|
||||
export class StatefulSet extends KubeObject<StatefulSetStatus, StatefulSetSpec, KubeObjectScope.Namespace> {
|
||||
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 } from "../kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
@ -20,7 +20,7 @@ export interface TopologySelectorTerm {
|
||||
matchLabelExpressions?: TopologySelectorLabelRequirement[];
|
||||
}
|
||||
|
||||
export interface StorageClassData extends KubeJsonApiData<KubeObjectMetadata<"cluster-scoped">, void, void> {
|
||||
export interface StorageClassData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Cluster>, void, void> {
|
||||
allowVolumeExpansion?: boolean;
|
||||
allowedTopologies?: TopologySelectorTerm[];
|
||||
mountOptions?: string[];
|
||||
@ -30,7 +30,7 @@ export interface StorageClassData extends KubeJsonApiData<KubeObjectMetadata<"cl
|
||||
volumeBindingMode?: string;
|
||||
}
|
||||
|
||||
export class StorageClass extends KubeObject<void, void, "cluster-scoped"> {
|
||||
export class StorageClass extends KubeObject<void, void, KubeObjectScope.Cluster> {
|
||||
static readonly kind = "StorageClass";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/storage.k8s.io/v1/storageclasses";
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { KubeObjectScope, KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { JobSpec } from "../job.api";
|
||||
|
||||
export interface JobTemplateSpec {
|
||||
metadata?: KubeTemplateObjectMetadata<"namespace-scoped">;
|
||||
metadata?: KubeTemplateObjectMetadata<KubeObjectScope.Namespace>;
|
||||
spec?: JobSpec;
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { KubeObjectScope, KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { PersistentVolumeSpec } from "../persistent-volume.api";
|
||||
|
||||
export interface PersistentVolumeClaimTemplateSpec {
|
||||
metadata?: KubeTemplateObjectMetadata<"cluster-scoped">;
|
||||
metadata?: KubeTemplateObjectMetadata<KubeObjectScope.Cluster>;
|
||||
spec?: PersistentVolumeSpec;
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { KubeObjectScope, KubeTemplateObjectMetadata } from "../../kube-object";
|
||||
import type { PodSpec } from "../pods.api";
|
||||
|
||||
export interface PodTemplateSpec {
|
||||
metadata?: KubeTemplateObjectMetadata<"namespace-scoped">;
|
||||
metadata?: KubeTemplateObjectMetadata<KubeObjectScope.Namespace>;
|
||||
spec?: PodSpec;
|
||||
}
|
||||
|
||||
@ -200,8 +200,8 @@ interface BaseKubeJsonApiObjectMetadata<Namespaced extends KubeObjectScope> {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export type KubeJsonApiObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = Namespaced extends "namespace-scoped"
|
||||
? BaseKubeJsonApiObjectMetadata<"namespace-scoped"> & { readonly namespace: string }
|
||||
export type KubeJsonApiObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = Namespaced extends KubeObjectScope.Namespace
|
||||
? BaseKubeJsonApiObjectMetadata<KubeObjectScope.Namespace> & { readonly namespace: string }
|
||||
: BaseKubeJsonApiObjectMetadata<Namespaced>;
|
||||
|
||||
export type KubeObjectMetadata<Namespaced extends KubeObjectScope = KubeObjectScope> = KubeJsonApiObjectMetadata<Namespaced> & {
|
||||
@ -359,11 +359,14 @@ export interface LabelSelector {
|
||||
matchExpressions?: LabelMatchExpression[];
|
||||
}
|
||||
|
||||
export type KubeObjectScope = "namespace-scoped" | "cluster-scoped";
|
||||
export enum KubeObjectScope {
|
||||
Namespace,
|
||||
Cluster,
|
||||
}
|
||||
export type ScopedNamespace<Namespaced extends KubeObjectScope> = (
|
||||
Namespaced extends "namespace-scoped"
|
||||
Namespaced extends KubeObjectScope.Namespace
|
||||
? string
|
||||
: Namespaced extends "cluster-scoped"
|
||||
: Namespaced extends KubeObjectScope.Cluster
|
||||
? undefined
|
||||
: string | undefined
|
||||
);
|
||||
|
||||
@ -10,7 +10,7 @@ import { cpuUnitsToNumber, isClusterPageContext, unitsToBytes } from "../../util
|
||||
import type { Pod, PodMetrics, PodApi } from "../../../common/k8s-api/endpoints";
|
||||
import { podMetricsApi, podApi } from "../../../common/k8s-api/endpoints";
|
||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject, KubeObjectScope } from "../../../common/k8s-api/kube-object";
|
||||
|
||||
export class PodsStore extends KubeObjectStore<Pod, PodApi> {
|
||||
readonly kubeMetrics = observable.array<PodMetrics>([]);
|
||||
@ -25,7 +25,7 @@ export class PodsStore extends KubeObjectStore<Pod, PodApi> {
|
||||
}
|
||||
}
|
||||
|
||||
getPodsByOwner(workload: KubeObject<any, any, "namespace-scoped">): Pod[] {
|
||||
getPodsByOwner(workload: KubeObject<unknown, unknown, KubeObjectScope.Namespace>): Pod[] {
|
||||
return this.items.filter(pod => (
|
||||
pod.getOwnerRefs()
|
||||
.find(owner => owner.uid === workload.getId())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user