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

- Merging interfaces & classses to avoid overwriting fields from parent's super(data)-call with Object.assign(this, data). Otherwise use "declare" keyword at class field definition.

- Revamping {useDefineForClassFields: true} to avoid issues with non-observable class fields in some cases (from previous commit):

```
@observer
export class CommandContainer extends React.Component<CommandContainerProps> {
  // without some defined initial value "commandComponent" is non-observable for some reasons
  // when tsconfig.ts has {useDefineForClassFields:false}
  @observable.ref commandComponent: React.ReactNode = null;

  constructor(props: CommandContainerProps) {
    super(props);
    makeObservable(this);
  }
```

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-05-14 15:52:00 +03:00
parent 291595d476
commit 6addce21fb
39 changed files with 283 additions and 236 deletions

View File

@ -71,10 +71,7 @@ export interface IClusterMetrics<T = IMetrics> {
fsUsage: T; fsUsage: T;
} }
export class Cluster extends KubeObject { export interface Cluster {
static kind = "Cluster";
static apiBase = "/apis/cluster.k8s.io/v1alpha1/clusters";
spec: { spec: {
clusterNetwork?: { clusterNetwork?: {
serviceDomain?: string; serviceDomain?: string;
@ -106,6 +103,11 @@ export class Cluster extends KubeObject {
errorMessage?: string; errorMessage?: string;
errorReason?: string; errorReason?: string;
}; };
}
export class Cluster extends KubeObject {
static kind = "Cluster";
static apiBase = "/apis/cluster.k8s.io/v1alpha1/clusters";
getStatus() { getStatus() {
if (this.metadata.deletionTimestamp) return ClusterStatus.REMOVING; if (this.metadata.deletionTimestamp) return ClusterStatus.REMOVING;

View File

@ -28,13 +28,15 @@ export interface IComponentStatusCondition {
message: string; message: string;
} }
export interface ComponentStatus {
conditions: IComponentStatusCondition[];
}
export class ComponentStatus extends KubeObject { export class ComponentStatus extends KubeObject {
static kind = "ComponentStatus"; static kind = "ComponentStatus";
static namespaced = false; static namespaced = false;
static apiBase = "/api/v1/componentstatuses"; static apiBase = "/api/v1/componentstatuses";
conditions: IComponentStatusCondition[];
getTruthyConditions() { getTruthyConditions() {
return this.conditions.filter(c => c.status === "True"); return this.conditions.filter(c => c.status === "True");
} }

View File

@ -22,6 +22,13 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { autoBind } from "../../../common/utils";
export interface ConfigMap {
data: {
[param: string]: string;
};
}
export class ConfigMap extends KubeObject { export class ConfigMap extends KubeObject {
static kind = "ConfigMap"; static kind = "ConfigMap";
@ -30,12 +37,10 @@ export class ConfigMap extends KubeObject {
constructor(data: KubeJsonApiData) { constructor(data: KubeJsonApiData) {
super(data); super(data);
this.data = this.data || {}; autoBind(this);
}
data: { this.data ??= {};
[param: string]: string; }
};
getKeys(): string[] { getKeys(): string[] {
return Object.keys(this.data); return Object.keys(this.data);

View File

@ -38,11 +38,7 @@ type AdditionalPrinterColumnsV1Beta = AdditionalPrinterColumnsCommon & {
JSONPath: string; JSONPath: string;
}; };
export class CustomResourceDefinition extends KubeObject { export interface CustomResourceDefinition {
static kind = "CustomResourceDefinition";
static namespaced = false;
static apiBase = "/apis/apiextensions.k8s.io/v1/customresourcedefinitions";
spec: { spec: {
group: string; group: string;
version?: string; // deprecated in v1 api version?: string; // deprecated in v1 api
@ -84,6 +80,12 @@ export class CustomResourceDefinition extends KubeObject {
}; };
storedVersions: string[]; storedVersions: string[];
}; };
}
export class CustomResourceDefinition extends KubeObject {
static kind = "CustomResourceDefinition";
static namespaced = false;
static apiBase = "/apis/apiextensions.k8s.io/v1/customresourcedefinitions";
getResourceUrl() { getResourceUrl() {
return crdResourcesURL({ return crdResourcesURL({

View File

@ -59,16 +59,7 @@ export class CronJobApi extends KubeApi<CronJob> {
} }
} }
export class CronJob extends KubeObject { export interface CronJob {
static kind = "CronJob";
static namespaced = true;
static apiBase = "/apis/batch/v1beta1/cronjobs";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
schedule: string; schedule: string;
concurrencyPolicy: string; concurrencyPolicy: string;
@ -105,6 +96,17 @@ export class CronJob extends KubeObject {
status: { status: {
lastScheduleTime?: string; lastScheduleTime?: string;
}; };
}
export class CronJob extends KubeObject {
static kind = "CronJob";
static namespaced = true;
static apiBase = "/apis/batch/v1beta1/cronjobs";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getSuspendFlag() { getSuspendFlag() {
return this.spec.suspend.toString(); return this.spec.suspend.toString();

View File

@ -36,7 +36,7 @@ export class DaemonSet extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
selector: { selector: {
matchLabels: { matchLabels: {
[name: string]: string; [name: string]: string;
@ -78,7 +78,7 @@ export class DaemonSet extends WorkloadKubeObject {
}; };
revisionHistoryLimit: number; revisionHistoryLimit: number;
}; };
status: { declare status: {
currentNumberScheduled: number; currentNumberScheduled: number;
numberMisscheduled: number; numberMisscheduled: number;
desiredNumberScheduled: number; desiredNumberScheduled: number;

View File

@ -98,7 +98,7 @@ export class Deployment extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
replicas: number; replicas: number;
selector: { matchLabels: { [app: string]: string } }; selector: { matchLabels: { [app: string]: string } };
template: { template: {
@ -177,7 +177,7 @@ export class Deployment extends WorkloadKubeObject {
}; };
}; };
}; };
status: { declare status: {
observedGeneration: number; observedGeneration: number;
replicas: number; replicas: number;
updatedReplicas: number; updatedReplicas: number;

View File

@ -122,13 +122,15 @@ export class EndpointSubset implements IEndpointSubset {
} }
} }
export interface Endpoint {
subsets: IEndpointSubset[];
}
export class Endpoint extends KubeObject { export class Endpoint extends KubeObject {
static kind = "Endpoints"; static kind = "Endpoints";
static namespaced = true; static namespaced = true;
static apiBase = "/api/v1/endpoints"; static apiBase = "/api/v1/endpoints";
subsets: IEndpointSubset[];
constructor(data: KubeJsonApiData) { constructor(data: KubeJsonApiData) {
super(data); super(data);
autoBind(this); autoBind(this);

View File

@ -24,11 +24,7 @@ import { KubeObject } from "../kube-object";
import { formatDuration } from "../../utils/formatDuration"; import { formatDuration } from "../../utils/formatDuration";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
export class KubeEvent extends KubeObject { export interface KubeEvent {
static kind = "Event";
static namespaced = true;
static apiBase = "/api/v1/events";
involvedObject: { involvedObject: {
kind: string; kind: string;
namespace: string; namespace: string;
@ -51,6 +47,12 @@ export class KubeEvent extends KubeObject {
eventTime: null; eventTime: null;
reportingComponent: string; reportingComponent: string;
reportingInstance: string; reportingInstance: string;
}
export class KubeEvent extends KubeObject {
static kind = "Event";
static namespaced = true;
static apiBase = "/api/v1/events";
isWarning() { isWarning() {
return this.type === "Warning"; return this.type === "Warning";

View File

@ -83,16 +83,7 @@ export async function getChartValues(repo: string, name: string, version: string
return apiBase.get<string>(`/v2/charts/${repo}/${name}/values?${stringify({ version })}`); return apiBase.get<string>(`/v2/charts/${repo}/${name}/values?${stringify({ version })}`);
} }
export class HelmChart { export interface HelmChart {
constructor(data: any) {
Object.assign(this, data);
autoBind(this);
}
static create(data: any) {
return new HelmChart(data);
}
apiVersion: string; apiVersion: string;
name: string; name: string;
version: string; version: string;
@ -114,6 +105,17 @@ export class HelmChart {
appVersion?: string; appVersion?: string;
deprecated?: boolean; deprecated?: boolean;
tillerVersion?: string; tillerVersion?: string;
}
export class HelmChart {
constructor(data: HelmChart) {
Object.assign(this, data);
autoBind(this);
}
static create(data: any) {
return new HelmChart(data);
}
getId() { getId() {
return `${this.repo}:${this.apiVersion}/${this.name}@${this.getAppVersion()}+${this.digest}`; return `${this.repo}:${this.apiVersion}/${this.name}@${this.getAppVersion()}+${this.digest}`;

View File

@ -155,6 +155,16 @@ export async function rollbackRelease(name: string, namespace: string, revision:
}); });
} }
export interface HelmRelease {
appVersion: string;
name: string;
namespace: string;
chart: string;
status: string;
updated: string;
revision: string;
}
export class HelmRelease implements ItemObject { export class HelmRelease implements ItemObject {
constructor(data: any) { constructor(data: any) {
Object.assign(this, data); Object.assign(this, data);
@ -165,14 +175,6 @@ export class HelmRelease implements ItemObject {
return new HelmRelease(data); return new HelmRelease(data);
} }
appVersion: string;
name: string;
namespace: string;
chart: string;
status: string;
updated: string;
revision: string;
getId() { getId() {
return this.namespace + this.name; return this.namespace + this.name;
} }

View File

@ -59,11 +59,7 @@ export interface IHpaMetric {
}>; }>;
} }
export class HorizontalPodAutoscaler extends KubeObject { export interface HorizontalPodAutoscaler {
static kind = "HorizontalPodAutoscaler";
static namespaced = true;
static apiBase = "/apis/autoscaling/v2beta1/horizontalpodautoscalers";
spec: { spec: {
scaleTargetRef: { scaleTargetRef: {
kind: string; kind: string;
@ -86,6 +82,12 @@ export class HorizontalPodAutoscaler extends KubeObject {
type: string; type: string;
}[]; }[];
}; };
}
export class HorizontalPodAutoscaler extends KubeObject {
static kind = "HorizontalPodAutoscaler";
static namespaced = true;
static apiBase = "/apis/autoscaling/v2beta1/horizontalpodautoscalers";
getMaxPods() { getMaxPods() {
return this.spec.maxReplicas || 0; return this.spec.maxReplicas || 0;

View File

@ -83,16 +83,7 @@ export const getBackendServiceNamePort = (backend: IIngressBackend) => {
return { serviceName, servicePort }; return { serviceName, servicePort };
}; };
export class Ingress extends KubeObject { export interface Ingress {
static kind = "Ingress";
static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/ingresses";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
tls: { tls: {
secretName: string; secretName: string;
@ -122,6 +113,17 @@ export class Ingress extends KubeObject {
ingress: ILoadBalancerIngress[]; ingress: ILoadBalancerIngress[];
}; };
}; };
}
export class Ingress extends KubeObject {
static kind = "Ingress";
static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/ingresses";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getRoutes() { getRoutes() {
const { spec: { tls, rules } } = this; const { spec: { tls, rules } } = this;

View File

@ -37,7 +37,7 @@ export class Job extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
parallelism?: number; parallelism?: number;
completions?: number; completions?: number;
backoffLimit?: number; backoffLimit?: number;
@ -83,7 +83,7 @@ export class Job extends WorkloadKubeObject {
serviceAccount?: string; serviceAccount?: string;
schedulerName?: string; schedulerName?: string;
}; };
status: { declare status: {
conditions: { conditions: {
type: string; type: string;
status: string; status: string;

View File

@ -51,6 +51,12 @@ export interface LimitRangeItem extends LimitRangeParts {
type: string type: string
} }
export interface LimitRange {
spec: {
limits: LimitRangeItem[];
};
}
export class LimitRange extends KubeObject { export class LimitRange extends KubeObject {
static kind = "LimitRange"; static kind = "LimitRange";
static namespaced = true; static namespaced = true;
@ -61,10 +67,6 @@ export class LimitRange extends KubeObject {
autoBind(this); autoBind(this);
} }
spec: {
limits: LimitRangeItem[];
};
getContainerLimits() { getContainerLimits() {
return this.spec.limits.filter(limit => limit.type === LimitType.CONTAINER); return this.spec.limits.filter(limit => limit.type === LimitType.CONTAINER);
} }

View File

@ -29,6 +29,12 @@ export enum NamespaceStatus {
TERMINATING = "Terminating", TERMINATING = "Terminating",
} }
export interface Namespace {
status?: {
phase: string;
};
}
export class Namespace extends KubeObject { export class Namespace extends KubeObject {
static kind = "Namespace"; static kind = "Namespace";
static namespaced = false; static namespaced = false;
@ -39,12 +45,8 @@ export class Namespace extends KubeObject {
autoBind(this); autoBind(this);
} }
status?: {
phase: string;
};
getStatus() { getStatus() {
return this.status ? this.status.phase : "-"; return this.status?.phase ?? "-";
} }
} }

View File

@ -57,16 +57,7 @@ export interface IPolicyEgress {
}[]; }[];
} }
export class NetworkPolicy extends KubeObject { export interface NetworkPolicy {
static kind = "NetworkPolicy";
static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/networkpolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
podSelector: { podSelector: {
matchLabels: { matchLabels: {
@ -78,6 +69,17 @@ export class NetworkPolicy extends KubeObject {
ingress: IPolicyIngress[]; ingress: IPolicyIngress[];
egress: IPolicyEgress[]; egress: IPolicyEgress[];
}; };
}
export class NetworkPolicy extends KubeObject {
static kind = "NetworkPolicy";
static namespaced = true;
static apiBase = "/apis/networking.k8s.io/v1/networkpolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getMatchLabels(): string[] { getMatchLabels(): string[] {
if (!this.spec.podSelector || !this.spec.podSelector.matchLabels) return []; if (!this.spec.podSelector || !this.spec.podSelector.matchLabels) return [];

View File

@ -27,7 +27,7 @@ import { KubeJsonApiData } from "../kube-json-api";
export class NodesApi extends KubeApi<Node> { export class NodesApi extends KubeApi<Node> {
getMetrics(): Promise<INodeMetrics> { getMetrics(): Promise<INodeMetrics> {
const opts = { category: "nodes"}; const opts = { category: "nodes" };
return metricsApi.getMetrics({ return metricsApi.getMetrics({
memoryUsage: opts, memoryUsage: opts,
@ -50,16 +50,7 @@ export interface INodeMetrics<T = IMetrics> {
fsSize: T; fsSize: T;
} }
export class Node extends KubeObject { export interface Node {
static kind = "Node";
static namespaced = false;
static apiBase = "/api/v1/nodes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
podCIDR: string; podCIDR: string;
externalID: string; externalID: string;
@ -110,6 +101,17 @@ export class Node extends KubeObject {
sizeBytes: number; sizeBytes: number;
}[]; }[];
}; };
}
export class Node extends KubeObject {
static kind = "Node";
static namespaced = false;
static apiBase = "/api/v1/nodes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getNodeConditionText() { getNodeConditionText() {
const { conditions } = this.status; const { conditions } = this.status;

View File

@ -43,16 +43,7 @@ export interface IPvcMetrics<T = IMetrics> {
diskCapacity: T; diskCapacity: T;
} }
export class PersistentVolumeClaim extends KubeObject { export interface PersistentVolumeClaim {
static kind = "PersistentVolumeClaim";
static namespaced = true;
static apiBase = "/api/v1/persistentvolumeclaims";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
accessModes: string[]; accessModes: string[];
storageClassName: string; storageClassName: string;
@ -75,6 +66,17 @@ export class PersistentVolumeClaim extends KubeObject {
status: { status: {
phase: string; // Pending phase: string; // Pending
}; };
}
export class PersistentVolumeClaim extends KubeObject {
static kind = "PersistentVolumeClaim";
static namespaced = true;
static apiBase = "/api/v1/persistentvolumeclaims";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getPods(allPods: Pod[]): Pod[] { getPods(allPods: Pod[]): Pod[] {
const pods = allPods.filter(pod => pod.getNs() === this.getNs()); const pods = allPods.filter(pod => pod.getNs() === this.getNs());

View File

@ -25,16 +25,7 @@ import { autoBind } from "../../utils";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export class PersistentVolume extends KubeObject { export interface PersistentVolume {
static kind = "PersistentVolume";
static namespaced = false;
static apiBase = "/api/v1/persistentvolumes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
capacity: { capacity: {
storage: string; // 8Gi storage: string; // 8Gi
@ -70,6 +61,17 @@ export class PersistentVolume extends KubeObject {
phase: string; phase: string;
reason?: string; reason?: string;
}; };
}
export class PersistentVolume extends KubeObject {
static kind = "PersistentVolume";
static namespaced = false;
static apiBase = "/api/v1/persistentvolumes";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getCapacity(inBytes = false) { getCapacity(inBytes = false) {
const capacity = this.spec.capacity; const capacity = this.spec.capacity;

View File

@ -22,11 +22,7 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
export class PodMetrics extends KubeObject { export interface PodMetrics {
static kind = "PodMetrics";
static namespaced = true;
static apiBase = "/apis/metrics.k8s.io/v1beta1/pods";
timestamp: string; timestamp: string;
window: string; window: string;
containers: { containers: {
@ -38,6 +34,12 @@ export class PodMetrics extends KubeObject {
}[]; }[];
} }
export class PodMetrics extends KubeObject {
static kind = "PodMetrics";
static namespaced = true;
static apiBase = "/apis/metrics.k8s.io/v1beta1/pods";
}
export const podMetricsApi = new KubeApi({ export const podMetricsApi = new KubeApi({
objectConstructor: PodMetrics, objectConstructor: PodMetrics,
}); });

View File

@ -24,16 +24,7 @@ import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export class PodDisruptionBudget extends KubeObject { export interface PodDisruptionBudget {
static kind = "PodDisruptionBudget";
static namespaced = true;
static apiBase = "/apis/policy/v1beta1/poddisruptionbudgets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
minAvailable: string; minAvailable: string;
maxUnavailable: string; maxUnavailable: string;
@ -45,6 +36,17 @@ export class PodDisruptionBudget extends KubeObject {
disruptionsAllowed: number disruptionsAllowed: number
expectedPods: number expectedPods: number
}; };
}
export class PodDisruptionBudget extends KubeObject {
static kind = "PodDisruptionBudget";
static namespaced = true;
static apiBase = "/apis/policy/v1beta1/poddisruptionbudgets";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getSelectors() { getSelectors() {
const selector = this.spec.selector; const selector = this.spec.selector;

View File

@ -213,7 +213,7 @@ export class Pod extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
volumes?: { volumes?: {
name: string; name: string;
persistentVolumeClaim: { persistentVolumeClaim: {
@ -270,7 +270,7 @@ export class Pod extends WorkloadKubeObject {
}; };
affinity?: IAffinity; affinity?: IAffinity;
}; };
status?: { declare status?: {
phase: string; phase: string;
conditions: { conditions: {
type: string; type: string;

View File

@ -24,16 +24,7 @@ import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export class PodSecurityPolicy extends KubeObject { export interface PodSecurityPolicy {
static kind = "PodSecurityPolicy";
static namespaced = false;
static apiBase = "/apis/policy/v1beta1/podsecuritypolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
allowPrivilegeEscalation?: boolean; allowPrivilegeEscalation?: boolean;
allowedCSIDrivers?: { allowedCSIDrivers?: {
@ -93,6 +84,17 @@ export class PodSecurityPolicy extends KubeObject {
}; };
volumes?: string[]; volumes?: string[];
}; };
}
export class PodSecurityPolicy extends KubeObject {
static kind = "PodSecurityPolicy";
static namespaced = false;
static apiBase = "/apis/policy/v1beta1/podsecuritypolicies";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
isPrivileged() { isPrivileged() {
return !!this.spec.privileged; return !!this.spec.privileged;

View File

@ -59,7 +59,7 @@ export class ReplicaSet extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
replicas?: number; replicas?: number;
selector: { matchLabels: { [app: string]: string } }; selector: { matchLabels: { [app: string]: string } };
template?: { template?: {
@ -72,7 +72,7 @@ export class ReplicaSet extends WorkloadKubeObject {
}; };
minReadySeconds?: number; minReadySeconds?: number;
}; };
status: { declare status: {
replicas: number; replicas: number;
fullyLabeledReplicas?: number; fullyLabeledReplicas?: number;
readyReplicas?: number; readyReplicas?: number;

View File

@ -21,7 +21,6 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api";
export interface IResourceQuotaValues { export interface IResourceQuotaValues {
[quota: string]: string; [quota: string]: string;
@ -51,16 +50,7 @@ export interface IResourceQuotaValues {
"count/deployments.extensions"?: string; "count/deployments.extensions"?: string;
} }
export class ResourceQuota extends KubeObject { export interface ResourceQuota {
static kind = "ResourceQuota";
static namespaced = true;
static apiBase = "/api/v1/resourcequotas";
constructor(data: KubeJsonApiData) {
super(data);
this.spec = this.spec || {} as any;
}
spec: { spec: {
hard: IResourceQuotaValues; hard: IResourceQuotaValues;
scopeSelector?: { scopeSelector?: {
@ -76,6 +66,12 @@ export class ResourceQuota extends KubeObject {
hard: IResourceQuotaValues; hard: IResourceQuotaValues;
used: IResourceQuotaValues; used: IResourceQuotaValues;
}; };
}
export class ResourceQuota extends KubeObject {
static kind = "ResourceQuota";
static namespaced = true;
static apiBase = "/api/v1/resourcequotas";
getScopeSelector() { getScopeSelector() {
const { matchExpressions = [] } = this.spec.scopeSelector || {}; const { matchExpressions = [] } = this.spec.scopeSelector || {};

View File

@ -31,6 +31,15 @@ export interface IRoleBindingSubject {
apiGroup?: string; apiGroup?: string;
} }
export interface RoleBinding {
subjects?: IRoleBindingSubject[];
roleRef: {
kind: string;
name: string;
apiGroup?: string;
};
}
export class RoleBinding extends KubeObject { export class RoleBinding extends KubeObject {
static kind = "RoleBinding"; static kind = "RoleBinding";
static namespaced = true; static namespaced = true;
@ -41,13 +50,6 @@ export class RoleBinding extends KubeObject {
autoBind(this); autoBind(this);
} }
subjects?: IRoleBindingSubject[];
roleRef: {
kind: string;
name: string;
apiGroup?: string;
};
getSubjects() { getSubjects() {
return this.subjects || []; return this.subjects || [];
} }

View File

@ -22,17 +22,19 @@
import { KubeObject } from "../kube-object"; import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
export class Role extends KubeObject { export interface Role {
static kind = "Role";
static namespaced = true;
static apiBase = "/apis/rbac.authorization.k8s.io/v1/roles";
rules: { rules: {
verbs: string[]; verbs: string[];
apiGroups: string[]; apiGroups: string[];
resources: string[]; resources: string[];
resourceNames?: string[]; resourceNames?: string[];
}[]; }[];
}
export class Role extends KubeObject {
static kind = "Role";
static namespaced = true;
static apiBase = "/apis/rbac.authorization.k8s.io/v1/roles";
getRules() { getRules() {
return this.rules || []; return this.rules || [];

View File

@ -40,6 +40,14 @@ export interface ISecretRef {
name: string; name: string;
} }
export interface Secret {
type: SecretType;
data: {
[prop: string]: string;
token?: string;
};
}
export class Secret extends KubeObject { export class Secret extends KubeObject {
static kind = "Secret"; static kind = "Secret";
static namespaced = true; static namespaced = true;
@ -48,13 +56,9 @@ export class Secret extends KubeObject {
constructor(data: KubeJsonApiData) { constructor(data: KubeJsonApiData) {
super(data); super(data);
autoBind(this); autoBind(this);
}
type: SecretType; this.data ??= {};
data: { }
[prop: string]: string;
token?: string;
} = {};
getKeys(): string[] { getKeys(): string[] {
return Object.keys(this.data); return Object.keys(this.data);

View File

@ -28,8 +28,7 @@ export class SelfSubjectRulesReviewApi extends KubeApi<SelfSubjectRulesReview> {
spec: { spec: {
namespace namespace
}, },
} });
);
} }
} }
@ -41,21 +40,21 @@ export interface ISelfSubjectReviewRule {
nonResourceURLs?: string[]; nonResourceURLs?: string[];
} }
export class SelfSubjectRulesReview extends KubeObject { export interface SelfSubjectRulesReview {
static kind = "SelfSubjectRulesReview";
static namespaced = false;
static apiBase = "/apis/authorization.k8s.io/v1/selfsubjectrulesreviews";
spec: { spec: {
// todo: add more types from api docs
namespace?: string; namespace?: string;
}; };
status: { status: {
resourceRules: ISelfSubjectReviewRule[]; resourceRules: ISelfSubjectReviewRule[];
nonResourceRules: ISelfSubjectReviewRule[]; nonResourceRules: ISelfSubjectReviewRule[];
incomplete: boolean; incomplete: boolean;
}; };
}
export class SelfSubjectRulesReview extends KubeObject {
static kind = "SelfSubjectRulesReview";
static namespaced = false;
static apiBase = "/apis/authorization.k8s.io/v1/selfsubjectrulesreviews";
getResourceRules() { getResourceRules() {
const rules = this.status && this.status.resourceRules || []; const rules = this.status && this.status.resourceRules || [];

View File

@ -24,6 +24,15 @@ import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export interface ServiceAccount {
secrets?: {
name: string;
}[];
imagePullSecrets?: {
name: string;
}[];
}
export class ServiceAccount extends KubeObject { export class ServiceAccount extends KubeObject {
static kind = "ServiceAccount"; static kind = "ServiceAccount";
static namespaced = true; static namespaced = true;
@ -34,13 +43,6 @@ export class ServiceAccount extends KubeObject {
autoBind(this); autoBind(this);
} }
secrets?: {
name: string;
}[];
imagePullSecrets?: {
name: string;
}[];
getSecrets() { getSecrets() {
return this.secrets || []; return this.secrets || [];
} }

View File

@ -24,21 +24,16 @@ import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export interface IServicePort { export interface ServicePort {
name?: string;
protocol: string;
port: number;
targetPort: number;
}
export class ServicePort implements IServicePort {
name?: string; name?: string;
protocol: string; protocol: string;
port: number; port: number;
targetPort: number; targetPort: number;
nodePort?: number; nodePort?: number;
}
constructor(data: IServicePort) { export class ServicePort {
constructor(data: ServicePort) {
Object.assign(this, data); Object.assign(this, data);
} }
@ -51,16 +46,7 @@ export class ServicePort implements IServicePort {
} }
} }
export class Service extends KubeObject { export interface Service {
static kind = "Service";
static namespaced = true;
static apiBase = "/api/v1/services";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
spec: { spec: {
type: string; type: string;
clusterIP: string; clusterIP: string;
@ -80,6 +66,17 @@ export class Service extends KubeObject {
}[]; }[];
}; };
}; };
}
export class Service extends KubeObject {
static kind = "Service";
static namespaced = true;
static apiBase = "/api/v1/services";
constructor(data: KubeJsonApiData) {
super(data);
autoBind(this);
}
getClusterIp() { getClusterIp() {
return this.spec.clusterIP; return this.spec.clusterIP;

View File

@ -59,7 +59,7 @@ export class StatefulSet extends WorkloadKubeObject {
autoBind(this); autoBind(this);
} }
spec: { declare spec: {
serviceName: string; serviceName: string;
replicas: number; replicas: number;
selector: { selector: {
@ -112,7 +112,7 @@ export class StatefulSet extends WorkloadKubeObject {
}; };
}[]; }[];
}; };
status: { declare status: {
observedGeneration: number; observedGeneration: number;
replicas: number; replicas: number;
currentReplicas: number; currentReplicas: number;

View File

@ -24,6 +24,16 @@ import { KubeObject } from "../kube-object";
import { KubeApi } from "../kube-api"; import { KubeApi } from "../kube-api";
import { KubeJsonApiData } from "../kube-json-api"; import { KubeJsonApiData } from "../kube-json-api";
export interface StorageClass {
provisioner: string; // e.g. "storage.k8s.io/v1"
mountOptions?: string[];
volumeBindingMode: string;
reclaimPolicy: string;
parameters: {
[param: string]: string; // every provisioner has own set of these parameters
};
}
export class StorageClass extends KubeObject { export class StorageClass extends KubeObject {
static kind = "StorageClass"; static kind = "StorageClass";
static namespaced = false; static namespaced = false;
@ -34,14 +44,6 @@ export class StorageClass extends KubeObject {
autoBind(this); autoBind(this);
} }
provisioner: string; // e.g. "storage.k8s.io/v1"
mountOptions?: string[];
volumeBindingMode: string;
reclaimPolicy: string;
parameters: {
[param: string]: string; // every provisioner has own set of these parameters
};
isDefault() { isDefault() {
const annotations = this.metadata.annotations || {}; const annotations = this.metadata.annotations || {};

View File

@ -91,6 +91,12 @@ export class KubeObject implements ItemObject {
static readonly kind: string; static readonly kind: string;
static readonly namespaced: boolean; static readonly namespaced: boolean;
apiVersion: string;
kind: string;
metadata: IKubeObjectMetadata;
status?: any;
spec?: any = {};
static create(data: any) { static create(data: any) {
return new KubeObject(data); return new KubeObject(data);
} }
@ -178,12 +184,6 @@ export class KubeObject implements ItemObject {
autoBind(this); autoBind(this);
} }
apiVersion: string;
kind: string;
metadata: IKubeObjectMetadata;
status?: any;
spec?: any;
get selfLink() { get selfLink() {
return this.metadata.selfLink; return this.metadata.selfLink;
} }

View File

@ -53,7 +53,7 @@ export interface CommandContainerProps {
@observer @observer
export class CommandContainer extends React.Component<CommandContainerProps> { export class CommandContainer extends React.Component<CommandContainerProps> {
@observable.ref commandComponent: React.ReactNode = null; @observable.ref commandComponent: React.ReactNode;
constructor(props: CommandContainerProps) { constructor(props: CommandContainerProps) {
super(props); super(props);

View File

@ -347,7 +347,7 @@ export class MenuItem extends React.Component<MenuItemProps> {
static defaultProps = defaultPropsMenuItem as object; static defaultProps = defaultPropsMenuItem as object;
static contextType = MenuContext; static contextType = MenuContext;
public context: MenuContextValue; declare context: MenuContextValue;
public elem: HTMLElement; public elem: HTMLElement;
constructor(props: MenuItemProps) { constructor(props: MenuItemProps) {

View File

@ -83,7 +83,7 @@ export interface TabProps<D = any> extends DOMAttributes<HTMLElement> {
export class Tab extends React.PureComponent<TabProps> { export class Tab extends React.PureComponent<TabProps> {
static contextType = TabsContext; static contextType = TabsContext;
public context: TabsContextValue; declare context: TabsContextValue;
public elem: HTMLElement; public elem: HTMLElement;
get isActive() { get isActive() {

View File

@ -23,7 +23,7 @@
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"traceResolution": false, "traceResolution": false,
"resolveJsonModule": true, "resolveJsonModule": true,
"useDefineForClassFields": false, "useDefineForClassFields": true,
"paths": { "paths": {
"*": [ "*": [
"node_modules/*", "node_modules/*",