1
0
mirror of https://github.com/lensapp/lens.git synced 2024-10-26 09:47:18 +03:00

chore: kube-api lint fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2023-05-08 13:19:31 +03:00 committed by Sebastian Malton
parent 7b8bd1e758
commit 0298b36a9f
23 changed files with 71 additions and 63 deletions

View File

@ -11,20 +11,24 @@ import { DaemonSet } from "@k8slens/kube-object";
export class DaemonSetApi extends KubeApi<DaemonSet> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: DaemonSet,
});
}
restart(params: NamespacedResourceDescriptor) {
return this.patch(params, {
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() },
return this.patch(
params,
{
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt": moment.utc().format() },
},
},
},
},
}, "strategic");
"strategic",
);
}
}

View File

@ -12,7 +12,7 @@ import { Deployment } from "@k8slens/kube-object";
export class DeploymentApi extends KubeApi<Deployment> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Deployment,
});
}
@ -24,18 +24,22 @@ export class DeploymentApi extends KubeApi<Deployment> {
}
scale(params: NamespacedResourceDescriptor, replicas: number) {
return this.scaleResource(params, { spec: { replicas }});
return this.scaleResource(params, { spec: { replicas } });
}
restart(params: NamespacedResourceDescriptor) {
return this.patch(params, {
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() },
return this.patch(
params,
{
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt": moment.utc().format() },
},
},
},
},
}, "strategic");
"strategic",
);
}
}

View File

@ -11,14 +11,9 @@ export class HorizontalPodAutoscalerApi extends KubeApi<HorizontalPodAutoscaler>
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
allowedUsableVersions: {
autoscaling: [
"v2",
"v2beta2",
"v2beta1",
"v1",
],
autoscaling: ["v2", "v2beta2", "v2beta1", "v1"],
},
...opts ?? {},
...(opts ?? {}),
objectConstructor: HorizontalPodAutoscaler,
checkPreferredVersion: true,
});

View File

@ -17,12 +17,16 @@ export class IngressClassApi extends KubeApi<IngressClass> {
}
setAsDefault({ name }: ResourceDescriptor, isDefault = true) {
return this.patch({ name }, {
metadata: {
annotations: {
[IngressClass.ANNOTATION_IS_DEFAULT]: String(isDefault),
return this.patch(
{ name },
{
metadata: {
annotations: {
[IngressClass.ANNOTATION_IS_DEFAULT]: String(isDefault),
},
},
},
}, "strategic");
"strategic",
);
}
}

View File

@ -10,7 +10,7 @@ import { KubeApi } from "../kube-api";
export class IngressApi extends KubeApi<Ingress> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Ingress,
// Add fallback for Kubernetes <1.19
checkPreferredVersion: true,

View File

@ -10,7 +10,7 @@ import { Job } from "@k8slens/kube-object";
export class JobApi extends KubeApi<Job> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Job,
});
}

View File

@ -10,7 +10,7 @@ import { Lease } from "@k8slens/kube-object";
export class LeaseApi extends KubeApi<Lease> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Lease,
});
}

View File

@ -7,12 +7,11 @@ import { LimitRange } from "@k8slens/kube-object";
import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api";
import { KubeApi } from "../kube-api";
export class LimitRangeApi extends KubeApi<LimitRange> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
objectConstructor: LimitRange,
...opts ?? {},
...(opts ?? {}),
});
}
}

View File

@ -9,7 +9,7 @@ import { KubeApi } from "../kube-api";
export class MutatingWebhookConfigurationApi extends KubeApi<MutatingWebhookConfiguration> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: MutatingWebhookConfiguration,
});
}

View File

@ -10,7 +10,7 @@ import { Namespace } from "@k8slens/kube-object";
export class NamespaceApi extends KubeApi<Namespace> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Namespace,
});
}

View File

@ -10,7 +10,7 @@ import { KubeApi } from "../kube-api";
export class NodeApi extends KubeApi<Node> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Node,
});
}

View File

@ -10,9 +10,8 @@ import { PersistentVolumeClaim } from "@k8slens/kube-object";
export class PersistentVolumeClaimApi extends KubeApi<PersistentVolumeClaim> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: PersistentVolumeClaim,
});
}
}

View File

@ -12,7 +12,6 @@ export class PodSecurityPolicyApi extends KubeApi<PodSecurityPolicy> {
super(deps, {
...opts,
objectConstructor: PodSecurityPolicy,
});
}
}

View File

@ -13,11 +13,10 @@ import { KubeApi } from "../kube-api";
import type { KubeStatusData, PodLogsQuery } from "@k8slens/kube-object";
import { isKubeStatusData, KubeStatus, Pod } from "@k8slens/kube-object";
export class PodApi extends KubeApi<Pod> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: Pod,
});
}
@ -47,6 +46,7 @@ export class PodApi extends KubeApi<Pod> {
if (status.code >= 200 && status.code < 300) {
return status.getExplanation();
} else {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw status.getExplanation();
}
}

View File

@ -8,7 +8,6 @@ import { KubeApi } from "../kube-api";
import type { PriorityClassData } from "@k8slens/kube-object";
import { PriorityClass } from "@k8slens/kube-object";
export class PriorityClassApi extends KubeApi<PriorityClass, PriorityClassData> {
constructor(deps: KubeApiDependencies, opts: DerivedKubeApiOptions = {}) {
super(deps, {

View File

@ -10,7 +10,7 @@ import { ReplicaSet } from "@k8slens/kube-object";
export class ReplicaSetApi extends KubeApi<ReplicaSet> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: ReplicaSet,
});
}
@ -22,6 +22,6 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
}
scale(params: NamespacedResourceDescriptor, replicas: number) {
return this.scaleResource(params, { spec: { replicas }});
return this.scaleResource(params, { spec: { replicas } });
}
}

View File

@ -11,7 +11,7 @@ import type { Scale } from "@k8slens/kube-object";
export class ReplicationControllerApi extends KubeApi<ReplicationController> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: ReplicationController,
});
}
@ -25,6 +25,6 @@ export class ReplicationControllerApi extends KubeApi<ReplicationController> {
}
scale(params: NamespacedResourceDescriptor, replicas: number): Promise<Scale> {
return this.scaleResource(params, { spec: { replicas }});
return this.scaleResource(params, { spec: { replicas } });
}
}

View File

@ -8,7 +8,6 @@ import { RoleBinding } from "@k8slens/kube-object";
import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api";
import { KubeApi } from "../kube-api";
export class RoleBindingApi extends KubeApi<RoleBinding, RoleBindingData> {
constructor(deps: KubeApiDependencies, opts: DerivedKubeApiOptions = {}) {
super(deps, {

View File

@ -10,16 +10,19 @@ import { KubeApi } from "../kube-api";
export class SelfSubjectRulesReviewApi extends KubeApi<SelfSubjectRulesReview> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: SelfSubjectRulesReview,
});
}
create({ namespace = "default" }) {
return super.create({}, {
spec: {
namespace,
return super.create(
{},
{
spec: {
namespace,
},
},
});
);
}
}

View File

@ -12,7 +12,7 @@ import { StatefulSet } from "@k8slens/kube-object";
export class StatefulSetApi extends KubeApi<StatefulSet> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: StatefulSet,
});
}
@ -24,18 +24,22 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
}
scale(params: NamespacedResourceDescriptor, replicas: number) {
return this.scaleResource(params, { spec: { replicas }});
return this.scaleResource(params, { spec: { replicas } });
}
restart(params: NamespacedResourceDescriptor) {
return this.patch(params, {
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() },
return this.patch(
params,
{
spec: {
template: {
metadata: {
annotations: { "kubectl.kubernetes.io/restartedAt": moment.utc().format() },
},
},
},
},
}, "strategic");
"strategic",
);
}
}

View File

@ -9,7 +9,7 @@ import { KubeApi } from "../kube-api";
export class ValidatingWebhookConfigurationApi extends KubeApi<ValidatingWebhookConfiguration> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: ValidatingWebhookConfiguration,
});
}

View File

@ -7,11 +7,10 @@ import { VerticalPodAutoscaler } from "@k8slens/kube-object";
import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api";
import { KubeApi } from "../kube-api";
export class VerticalPodAutoscalerApi extends KubeApi<VerticalPodAutoscaler> {
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
super(deps, {
...opts ?? {},
...(opts ?? {}),
objectConstructor: VerticalPodAutoscaler,
});
}

View File

@ -543,7 +543,7 @@ export class KubeApi<
// custom apis might return array for list response, e.g. users, groups, etc.
return data
.filter(isJsonApiData)
.map((data) => (this.ensureMetadataSelfLink(data.metadata), data))
.map((data) => (this.ensureMetadataSelfLink(data.metadata), data)) // eslint-disable-line no-sequences
.map((data) => new KubeObjectConstructor(data as Data));
}