mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Lint: comma-spacing (error) & comma-dangle (error) (#4200)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
02e77afcd1
commit
c6dce043a7
406 files changed
+1590
-1580
No files matched your search
@@ -119,7 +119,7 @@ describe("Crds", () => {
|
||||
},
|
||||
spec: {
|
||||
version: "abc",
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
expect(crd.getVersion()).toBe("abc");
|
||||
|
||||
@@ -46,14 +46,14 @@ describe("DeploymentApi", () => {
|
||||
expect(patchSpy).toHaveBeenCalledWith("/apis/apps/v1/namespaces/default/deployments/deployment-1/scale", {
|
||||
data: {
|
||||
spec: {
|
||||
replicas: 5
|
||||
}
|
||||
}
|
||||
replicas: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/merge-patch+json"
|
||||
}
|
||||
"content-type": "application/merge-patch+json",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -282,7 +282,7 @@ describe("HelmChart tests", () => {
|
||||
|
||||
expect(warnFn).toHaveBeenCalledWith("HelmChart data has unexpected fields", {
|
||||
original: anyObject(),
|
||||
unknownFields: ["asdjhajksdhadjks"]
|
||||
unknownFields: ["asdjhajksdhadjks"],
|
||||
});
|
||||
console.warn = warn;
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ jest.mock("../api-manager", () => ({
|
||||
return {
|
||||
registerStore: jest.fn(),
|
||||
};
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
import { IKubeApiParsed, parseKubeApi } from "../kube-api-parse";
|
||||
@@ -45,7 +45,7 @@ const tests: KubeApiParseTestData[] = [
|
||||
apiVersionWithGroup: "apiextensions.k8s.io/v1beta1",
|
||||
namespace: undefined,
|
||||
resource: "customresourcedefinitions",
|
||||
name: "prometheuses.monitoring.coreos.com"
|
||||
name: "prometheuses.monitoring.coreos.com",
|
||||
}],
|
||||
["/api/v1/namespaces/kube-system/pods/coredns-6955765f44-v8p27", {
|
||||
apiBase: "/api/v1/pods",
|
||||
@@ -55,7 +55,7 @@ const tests: KubeApiParseTestData[] = [
|
||||
apiVersionWithGroup: "v1",
|
||||
namespace: "kube-system",
|
||||
resource: "pods",
|
||||
name: "coredns-6955765f44-v8p27"
|
||||
name: "coredns-6955765f44-v8p27",
|
||||
}],
|
||||
["/apis/stable.example.com/foo1/crontabs", {
|
||||
apiBase: "/apis/stable.example.com/foo1/crontabs",
|
||||
@@ -132,7 +132,7 @@ const tests: KubeApiParseTestData[] = [
|
||||
const throwtests = [
|
||||
undefined,
|
||||
"",
|
||||
"ajklsmh"
|
||||
"ajklsmh",
|
||||
];
|
||||
|
||||
describe("parseApi unit tests", () => {
|
||||
|
||||
@@ -28,11 +28,11 @@ describe("forRemoteCluster", () => {
|
||||
it("builds api client", async (done) => {
|
||||
const api = forRemoteCluster({
|
||||
cluster: {
|
||||
server: "https://127.0.0.1:6443"
|
||||
server: "https://127.0.0.1:6443",
|
||||
},
|
||||
user: {
|
||||
token: "daa"
|
||||
}
|
||||
token: "daa",
|
||||
},
|
||||
}, Pod);
|
||||
|
||||
(fetch as any).mockResponse(async (request: any) => {
|
||||
@@ -41,7 +41,7 @@ describe("forRemoteCluster", () => {
|
||||
done();
|
||||
|
||||
return {
|
||||
body: ""
|
||||
body: "",
|
||||
};
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ describe("KubeApi", () => {
|
||||
beforeEach(() => {
|
||||
request = new KubeJsonApi({
|
||||
serverAddress: `http://127.0.0.1:9999`,
|
||||
apiBase: "/api-kube"
|
||||
apiBase: "/api-kube",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,24 +65,24 @@ describe("KubeApi", () => {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any[]
|
||||
})
|
||||
name: "ingresses",
|
||||
}] as any[],
|
||||
}),
|
||||
};
|
||||
} else if (request.url === "http://127.0.0.1:9999/api-kube/apis/extensions/v1beta1") {
|
||||
// Even if the old API contains ingresses, KubeApi should prefer the apiBase url
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any[]
|
||||
})
|
||||
name: "ingresses",
|
||||
}] as any[],
|
||||
}),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any[]
|
||||
})
|
||||
resources: [] as any[],
|
||||
}),
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -107,22 +107,22 @@ describe("KubeApi", () => {
|
||||
if (request.url === "http://127.0.0.1:9999/api-kube/apis/networking.k8s.io/v1") {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any[]
|
||||
})
|
||||
resources: [] as any[],
|
||||
}),
|
||||
};
|
||||
} else if (request.url === "http://127.0.0.1:9999/api-kube/apis/extensions/v1beta1") {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [{
|
||||
name: "ingresses"
|
||||
}] as any[]
|
||||
})
|
||||
name: "ingresses",
|
||||
}] as any[],
|
||||
}),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
body: JSON.stringify({
|
||||
resources: [] as any[]
|
||||
})
|
||||
resources: [] as any[],
|
||||
}),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,8 +45,8 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
||||
uid: "1",
|
||||
name: "test",
|
||||
resourceVersion: "v1",
|
||||
selfLink: "http"
|
||||
}
|
||||
selfLink: "http",
|
||||
},
|
||||
});
|
||||
|
||||
pod.spec = {
|
||||
@@ -82,9 +82,9 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
||||
restartCount: i,
|
||||
state: {
|
||||
running: {
|
||||
startedAt: "before"
|
||||
startedAt: "before",
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
||||
startedAt: "before",
|
||||
exitCode: i+1,
|
||||
finishedAt: "later",
|
||||
reason: `reason_${i}`
|
||||
}
|
||||
}
|
||||
reason: `reason_${i}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
||||
restartCount: i,
|
||||
state: {
|
||||
running: {
|
||||
startedAt: "before"
|
||||
}
|
||||
}
|
||||
startedAt: "before",
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ function getDummyPod(opts: GetDummyPodOptions = getDummyPodDefaultOptions()): Po
|
||||
startedAt: "before",
|
||||
exitCode: i+1,
|
||||
finishedAt: "later",
|
||||
reason: `reason_${i}`
|
||||
}
|
||||
}
|
||||
reason: `reason_${i}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ describe("Pods", () => {
|
||||
return {
|
||||
image: "dummy",
|
||||
imagePullPolicy: "dummy",
|
||||
name
|
||||
name,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ describe("Pods", () => {
|
||||
const pod = getDummyPod();
|
||||
|
||||
pod.spec.nodeSelector = {
|
||||
"kubernetes.io/os": "foobar"
|
||||
"kubernetes.io/os": "foobar",
|
||||
};
|
||||
|
||||
expect(pod.getSelectedNodeOs()).toStrictEqual("foobar");
|
||||
@@ -241,7 +241,7 @@ describe("Pods", () => {
|
||||
const pod = getDummyPod();
|
||||
|
||||
pod.spec.nodeSelector = {
|
||||
"beta.kubernetes.io/os": "foobar1"
|
||||
"beta.kubernetes.io/os": "foobar1",
|
||||
};
|
||||
|
||||
expect(pod.getSelectedNodeOs()).toStrictEqual("foobar1");
|
||||
@@ -252,7 +252,7 @@ describe("Pods", () => {
|
||||
|
||||
pod.spec.nodeSelector = {
|
||||
"kubernetes.io/os": "foobar2",
|
||||
"beta.kubernetes.io/os": "foobar3"
|
||||
"beta.kubernetes.io/os": "foobar3",
|
||||
};
|
||||
|
||||
expect(pod.getSelectedNodeOs()).toStrictEqual("foobar2");
|
||||
@@ -273,7 +273,7 @@ describe("Pods", () => {
|
||||
type: "Ready",
|
||||
status: "foobar",
|
||||
lastProbeTime: 1,
|
||||
lastTransitionTime: "longer ago"
|
||||
lastTransitionTime: "longer ago",
|
||||
});
|
||||
|
||||
expect(pod.hasIssues()).toStrictEqual(true);
|
||||
@@ -286,7 +286,7 @@ describe("Pods", () => {
|
||||
type: "dummy",
|
||||
status: "foobar",
|
||||
lastProbeTime: 1,
|
||||
lastTransitionTime: "longer ago"
|
||||
lastTransitionTime: "longer ago",
|
||||
});
|
||||
|
||||
expect(pod.hasIssues()).toStrictEqual(false);
|
||||
@@ -298,8 +298,8 @@ describe("Pods", () => {
|
||||
pod.status.containerStatuses[0].state = {
|
||||
waiting: {
|
||||
reason: "CrashLookBackOff",
|
||||
message: "too much foobar"
|
||||
}
|
||||
message: "too much foobar",
|
||||
},
|
||||
};
|
||||
|
||||
expect(pod.hasIssues()).toStrictEqual(true);
|
||||
|
||||
@@ -46,14 +46,14 @@ describe("StatefulSetApi", () => {
|
||||
expect(patchSpy).toHaveBeenCalledWith("/apis/apps/v1/namespaces/default/statefulsets/statefulset-1/scale", {
|
||||
data: {
|
||||
spec: {
|
||||
replicas: 5
|
||||
}
|
||||
}
|
||||
replicas: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/merge-patch+json"
|
||||
}
|
||||
"content-type": "application/merge-patch+json",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ export class ApiManager {
|
||||
lookupApiLink(ref: IKubeObjectRef, parentObject: KubeObject): string {
|
||||
const {
|
||||
kind, apiVersion, name,
|
||||
namespace = parentObject.getNs()
|
||||
namespace = parentObject.getNs(),
|
||||
} = ref;
|
||||
|
||||
if (!kind) return "";
|
||||
|
||||
@@ -66,5 +66,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
clusterRoleBindingApi
|
||||
clusterRoleBindingApi,
|
||||
};
|
||||
@@ -54,5 +54,5 @@ if (isClusterPageContext()) { // initialize automatically only when within a clu
|
||||
}
|
||||
|
||||
export {
|
||||
clusterRoleApi
|
||||
clusterRoleApi,
|
||||
};
|
||||
@@ -49,7 +49,7 @@ export function getMetricsByNodeNames(nodeNames: string[], params?: IMetricsReqP
|
||||
podCapacity: opts,
|
||||
podAllocatableCapacity: opts,
|
||||
fsSize: opts,
|
||||
fsUsage: opts
|
||||
fsUsage: opts,
|
||||
}, params);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export enum ClusterStatus {
|
||||
ACTIVE = "Active",
|
||||
CREATING = "Creating",
|
||||
REMOVING = "Removing",
|
||||
ERROR = "Error"
|
||||
ERROR = "Error",
|
||||
}
|
||||
|
||||
export interface IClusterMetrics<T = IMetrics> {
|
||||
@@ -135,5 +135,5 @@ if (isClusterPageContext()) { // initialize automatically only when within a clu
|
||||
}
|
||||
|
||||
export {
|
||||
clusterApi
|
||||
clusterApi,
|
||||
};
|
||||
@@ -60,5 +60,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
configMapApi
|
||||
configMapApi,
|
||||
};
|
||||
@@ -117,7 +117,7 @@ export class CustomResourceDefinition extends KubeObject {
|
||||
params: {
|
||||
group: this.getGroup(),
|
||||
name: this.getPluralName(),
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ export class CustomResourceDefinition extends KubeObject {
|
||||
return {
|
||||
...condition,
|
||||
isReady: status === "True",
|
||||
tooltip: `${message || reason} (${lastTransitionTime})`
|
||||
tooltip: `${message || reason} (${lastTransitionTime})`,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -236,5 +236,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
crdApi
|
||||
crdApi,
|
||||
};
|
||||
@@ -33,14 +33,14 @@ export class CronJobApi extends KubeApi<CronJob> {
|
||||
return this.request.patch(this.getUrl(params), {
|
||||
data: {
|
||||
spec: {
|
||||
suspend: true
|
||||
}
|
||||
}
|
||||
suspend: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/strategic-merge-patch+json"
|
||||
}
|
||||
"content-type": "application/strategic-merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ export class CronJobApi extends KubeApi<CronJob> {
|
||||
return this.request.patch(this.getUrl(params), {
|
||||
data: {
|
||||
spec: {
|
||||
suspend: false
|
||||
}
|
||||
}
|
||||
suspend: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/strategic-merge-patch+json"
|
||||
}
|
||||
"content-type": "application/strategic-merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -153,5 +153,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
cronJobApi
|
||||
cronJobApi,
|
||||
};
|
||||
@@ -129,5 +129,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
daemonSetApi
|
||||
daemonSetApi,
|
||||
};
|
||||
@@ -44,14 +44,14 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
||||
return this.request.patch(this.getScaleApiUrl(params), {
|
||||
data: {
|
||||
spec: {
|
||||
replicas
|
||||
}
|
||||
}
|
||||
replicas,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/merge-patch+json"
|
||||
}
|
||||
"content-type": "application/merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,16 +61,16 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
||||
spec: {
|
||||
template: {
|
||||
metadata: {
|
||||
annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
annotations: { "kubectl.kubernetes.io/restartedAt" : moment.utc().format() },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/strategic-merge-patch+json"
|
||||
}
|
||||
"content-type": "application/strategic-merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -246,5 +246,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
deploymentApi
|
||||
deploymentApi,
|
||||
};
|
||||
@@ -159,5 +159,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
endpointApi
|
||||
endpointApi,
|
||||
};
|
||||
@@ -87,5 +87,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
eventApi
|
||||
eventApi,
|
||||
};
|
||||
@@ -191,7 +191,7 @@ const helmChartValidator = Joi.object<RawHelmChart>({
|
||||
.items(Joi.string())
|
||||
.options({
|
||||
stripUnknown: {
|
||||
arrays: true
|
||||
arrays: true,
|
||||
},
|
||||
})
|
||||
.default(() => ([])),
|
||||
@@ -200,7 +200,7 @@ const helmChartValidator = Joi.object<RawHelmChart>({
|
||||
.items(Joi.string())
|
||||
.options({
|
||||
stripUnknown: {
|
||||
arrays: true
|
||||
arrays: true,
|
||||
},
|
||||
})
|
||||
.default(() => ([])),
|
||||
@@ -209,7 +209,7 @@ const helmChartValidator = Joi.object<RawHelmChart>({
|
||||
.items(Joi.string())
|
||||
.options({
|
||||
stripUnknown: {
|
||||
arrays: true
|
||||
arrays: true,
|
||||
},
|
||||
})
|
||||
.default(() => ([])),
|
||||
@@ -218,7 +218,7 @@ const helmChartValidator = Joi.object<RawHelmChart>({
|
||||
.items(helmChartMaintainerValidator)
|
||||
.options({
|
||||
stripUnknown: {
|
||||
arrays: true
|
||||
arrays: true,
|
||||
},
|
||||
})
|
||||
.default(() => ([])),
|
||||
@@ -227,7 +227,7 @@ const helmChartValidator = Joi.object<RawHelmChart>({
|
||||
.items(helmChartDependencyValidator)
|
||||
.options({
|
||||
stripUnknown: {
|
||||
arrays: true
|
||||
arrays: true,
|
||||
},
|
||||
})
|
||||
.default(() => ([])),
|
||||
|
||||
@@ -108,7 +108,7 @@ export async function getRelease(name: string, namespace: string): Promise<IRele
|
||||
|
||||
return {
|
||||
...details,
|
||||
resources
|
||||
resources,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export async function createRelease(payload: IReleaseCreatePayload): Promise<IRe
|
||||
chart,
|
||||
values,
|
||||
...data,
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export async function updateRelease(name: string, namespace: string, payload: IR
|
||||
chart,
|
||||
values,
|
||||
...data,
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ export class HorizontalPodAutoscaler extends KubeObject {
|
||||
return {
|
||||
...condition,
|
||||
isReady: status === "True",
|
||||
tooltip: `${message || reason} (${lastTransitionTime})`
|
||||
tooltip: `${message || reason} (${lastTransitionTime})`,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -143,7 +143,7 @@ export class HorizontalPodAutoscaler extends KubeObject {
|
||||
getMetricValues(metric: IHpaMetric): string {
|
||||
const metricType = metric.type.toLowerCase();
|
||||
const currentMetric = this.getCurrentMetrics().find(current =>
|
||||
metric.type == current.type && this.getMetricName(metric) == this.getMetricName(current)
|
||||
metric.type == current.type && this.getMetricName(metric) == this.getMetricName(current),
|
||||
);
|
||||
const current = currentMetric ? currentMetric[metricType] : null;
|
||||
const target = metric[metricType];
|
||||
@@ -173,5 +173,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
hpaApi
|
||||
hpaApi,
|
||||
};
|
||||
@@ -36,7 +36,7 @@ export function getMetricsForIngress(ingress: string, namespace: string): Promis
|
||||
bytesSentSuccess: opts,
|
||||
bytesSentFailure: opts,
|
||||
requestDurationSeconds: opts,
|
||||
responseDurationSeconds: opts
|
||||
responseDurationSeconds: opts,
|
||||
}, {
|
||||
namespace,
|
||||
});
|
||||
@@ -160,7 +160,7 @@ export class Ingress extends KubeObject {
|
||||
|
||||
return {
|
||||
serviceName,
|
||||
servicePort
|
||||
servicePort,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -216,5 +216,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
ingressApi
|
||||
ingressApi,
|
||||
};
|
||||
@@ -124,7 +124,7 @@ export class Job extends WorkloadKubeObject {
|
||||
|
||||
delete() {
|
||||
const params: JsonApiParams = {
|
||||
query: { propagationPolicy: "Background" }
|
||||
query: { propagationPolicy: "Background" },
|
||||
};
|
||||
|
||||
return super.delete(params);
|
||||
@@ -158,5 +158,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
jobApi
|
||||
jobApi,
|
||||
};
|
||||
@@ -90,5 +90,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
limitRangeApi
|
||||
limitRangeApi,
|
||||
};
|
||||
@@ -87,13 +87,13 @@ export const metricsApi = {
|
||||
query: {
|
||||
start, end, step,
|
||||
"kubernetes_namespace": namespace,
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async getMetricProviders(): Promise<MetricProviderInfo[]> {
|
||||
return apiBase.get("/metrics/providers");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export function normalizeMetrics(metrics: IMetrics, frames = 60): IMetrics {
|
||||
@@ -103,7 +103,7 @@ export function normalizeMetrics(metrics: IMetrics, frames = 60): IMetrics {
|
||||
resultType: "",
|
||||
result: [{
|
||||
metric: {},
|
||||
values: []
|
||||
values: [],
|
||||
} as IMetricsResult],
|
||||
},
|
||||
status: "",
|
||||
@@ -144,7 +144,7 @@ export function normalizeMetrics(metrics: IMetrics, frames = 60): IMetrics {
|
||||
// always return at least empty values array
|
||||
result.push({
|
||||
metric: {},
|
||||
values: []
|
||||
values: [],
|
||||
} as IMetricsResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,5 +79,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
namespacesApi
|
||||
namespacesApi,
|
||||
};
|
||||
@@ -106,5 +106,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
networkPolicyApi
|
||||
networkPolicyApi,
|
||||
};
|
||||
@@ -40,7 +40,7 @@ export function getMetricsForAllNodes(): Promise<INodeMetrics> {
|
||||
cpuUsage: opts,
|
||||
cpuCapacity: opts,
|
||||
fsSize: opts,
|
||||
fsUsage: opts
|
||||
fsUsage: opts,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -259,5 +259,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
nodesApi
|
||||
nodesApi,
|
||||
};
|
||||
@@ -35,9 +35,9 @@ export function getMetricsForPvc(pvc: PersistentVolumeClaim): Promise<IPvcMetric
|
||||
|
||||
return metricsApi.getMetrics({
|
||||
diskUsage: opts,
|
||||
diskCapacity: opts
|
||||
diskCapacity: opts,
|
||||
}, {
|
||||
namespace: opts.namespace
|
||||
namespace: opts.namespace,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class PersistentVolumeClaim extends KubeObject {
|
||||
return pods.filter(pod => {
|
||||
return pod.getVolumes().filter(volume =>
|
||||
volume.persistentVolumeClaim &&
|
||||
volume.persistentVolumeClaim.claimName === this.getName()
|
||||
volume.persistentVolumeClaim.claimName === this.getName(),
|
||||
).length > 0;
|
||||
});
|
||||
}
|
||||
@@ -128,5 +128,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
pvcApi
|
||||
pvcApi,
|
||||
};
|
||||
@@ -111,5 +111,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
persistentVolumeApi
|
||||
persistentVolumeApi,
|
||||
};
|
||||
@@ -50,5 +50,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
podMetricsApi
|
||||
podMetricsApi,
|
||||
};
|
||||
@@ -82,5 +82,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
pdbApi
|
||||
pdbApi,
|
||||
};
|
||||
@@ -82,7 +82,7 @@ export enum PodStatus {
|
||||
PENDING = "Pending",
|
||||
RUNNING = "Running",
|
||||
SUCCEEDED = "Succeeded",
|
||||
EVICTED = "Evicted"
|
||||
EVICTED = "Evicted",
|
||||
}
|
||||
|
||||
export interface IPodContainer extends Partial<Record<PodContainerProbe, IContainerProbe>> {
|
||||
@@ -310,7 +310,7 @@ export class Pod extends WorkloadKubeObject {
|
||||
const runningContainerNames = new Set(
|
||||
this.getContainerStatuses()
|
||||
.filter(({ state }) => state.running)
|
||||
.map(({ name }) => name)
|
||||
.map(({ name }) => name),
|
||||
);
|
||||
|
||||
return this.getAllContainers()
|
||||
@@ -466,7 +466,7 @@ export class Pod extends WorkloadKubeObject {
|
||||
timeoutSeconds = 0,
|
||||
periodSeconds = 0,
|
||||
successThreshold = 0,
|
||||
failureThreshold = 0
|
||||
failureThreshold = 0,
|
||||
} = probeData;
|
||||
|
||||
// HTTP Request
|
||||
@@ -529,5 +529,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
podsApi
|
||||
podsApi,
|
||||
};
|
||||
@@ -127,5 +127,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
pspApi
|
||||
pspApi,
|
||||
};
|
||||
@@ -44,9 +44,9 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
||||
data: {
|
||||
metadata: params,
|
||||
spec: {
|
||||
replicas
|
||||
}
|
||||
}
|
||||
replicas,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -133,5 +133,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
replicaSetApi
|
||||
replicaSetApi,
|
||||
};
|
||||
@@ -25,7 +25,7 @@ import { apiBase } from "../index";
|
||||
import type { Patch } from "rfc6902";
|
||||
|
||||
export const annotations = [
|
||||
"kubectl.kubernetes.io/last-applied-configuration"
|
||||
"kubectl.kubernetes.io/last-applied-configuration",
|
||||
];
|
||||
|
||||
export async function update(resource: object | string): Promise<KubeJsonApiData> {
|
||||
|
||||
@@ -90,5 +90,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
resourceQuotaApi
|
||||
resourceQuotaApi,
|
||||
};
|
||||
@@ -71,5 +71,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
roleBindingApi
|
||||
roleBindingApi,
|
||||
};
|
||||
@@ -51,5 +51,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export{
|
||||
roleApi
|
||||
roleApi,
|
||||
};
|
||||
@@ -79,5 +79,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
secretsApi
|
||||
secretsApi,
|
||||
};
|
||||
@@ -27,7 +27,7 @@ export class SelfSubjectRulesReviewApi extends KubeApi<SelfSubjectRulesReview> {
|
||||
create({ namespace = "default" }): Promise<SelfSubjectRulesReview> {
|
||||
return super.create({}, {
|
||||
spec: {
|
||||
namespace
|
||||
namespace,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -82,7 +82,7 @@ export class SelfSubjectRulesReview extends KubeObject {
|
||||
const separator = apiGroup == "" ? "" : ".";
|
||||
|
||||
return resource + separator + apiGroup;
|
||||
})
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,6 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
selfSubjectRulesReviewApi
|
||||
selfSubjectRulesReviewApi,
|
||||
};
|
||||
|
||||
@@ -62,5 +62,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
serviceAccountsApi
|
||||
serviceAccountsApi,
|
||||
};
|
||||
@@ -157,5 +157,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
serviceApi
|
||||
serviceApi,
|
||||
};
|
||||
@@ -42,14 +42,14 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
|
||||
return this.request.patch(this.getScaleApiUrl(params), {
|
||||
data: {
|
||||
spec: {
|
||||
replicas
|
||||
}
|
||||
}
|
||||
replicas,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"content-type": "application/merge-patch+json"
|
||||
}
|
||||
"content-type": "application/merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -162,5 +162,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
statefulSetApi
|
||||
statefulSetApi,
|
||||
};
|
||||
@@ -72,5 +72,5 @@ if (isClusterPageContext()) {
|
||||
}
|
||||
|
||||
export {
|
||||
storageClassApi
|
||||
storageClassApi,
|
||||
};
|
||||
@@ -42,8 +42,8 @@ if (typeof window === "undefined") {
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `localhost:${params.port}`
|
||||
}
|
||||
"Host": `localhost:${params.port}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -53,8 +53,8 @@ if (typeof window === "undefined") {
|
||||
debug: isDevelopment || isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host
|
||||
}
|
||||
"Host": window.location.host,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,15 +62,15 @@ if (isClusterPageContext()) {
|
||||
apiKube = new KubeJsonApi({
|
||||
serverAddress: `http://127.0.0.1:${window.location.port}`,
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDevelopment
|
||||
debug: isDevelopment,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": window.location.host
|
||||
}
|
||||
"Host": window.location.host,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
apiBase,
|
||||
apiKube
|
||||
apiKube,
|
||||
};
|
||||
@@ -57,12 +57,12 @@ export interface JsonApiConfig {
|
||||
export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||
static reqInitDefault: RequestInit = {
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
"content-type": "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
static configDefault: Partial<JsonApiConfig> = {
|
||||
debug: false
|
||||
debug: false,
|
||||
};
|
||||
|
||||
constructor(public readonly config: JsonApiConfig, protected reqInit?: RequestInit) {
|
||||
@@ -87,7 +87,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||
{},
|
||||
this.reqInit,
|
||||
await this.getRequestOptions(),
|
||||
init
|
||||
init,
|
||||
);
|
||||
const { query } = params || {} as P;
|
||||
|
||||
@@ -126,7 +126,7 @@ export class JsonApi<D = JsonApiData, P extends JsonApiParams = JsonApiParams> {
|
||||
{},
|
||||
this.reqInit,
|
||||
await this.getRequestOptions(),
|
||||
init
|
||||
init,
|
||||
);
|
||||
const { data, query } = params || {} as P;
|
||||
|
||||
|
||||
@@ -123,13 +123,13 @@ export function forCluster<T extends KubeObject>(cluster: ILocalKubeApiConfig, k
|
||||
debug: isDevelopment,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `${cluster.metadata.uid}.localhost:${url.port}`
|
||||
}
|
||||
"Host": `${cluster.metadata.uid}.localhost:${url.port}`,
|
||||
},
|
||||
});
|
||||
|
||||
return new KubeApi({
|
||||
objectConstructor: kubeClass,
|
||||
request
|
||||
request,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -166,15 +166,15 @@ export function forRemoteCluster<T extends KubeObject>(config: IRemoteKubeApiCon
|
||||
...(token ? {
|
||||
getRequestOptions: async () => ({
|
||||
headers: {
|
||||
"Authorization": `Bearer ${isFunction(token) ? await token() : token}`
|
||||
}
|
||||
})
|
||||
} : {})
|
||||
"Authorization": `Bearer ${isFunction(token) ? await token() : token}`,
|
||||
},
|
||||
}),
|
||||
} : {}),
|
||||
}, reqInit);
|
||||
|
||||
return new KubeApi({
|
||||
objectConstructor: kubeClass,
|
||||
request
|
||||
request,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ export class KubeApi<T extends KubeObject> {
|
||||
objectConstructor,
|
||||
request = apiKube,
|
||||
kind = options.objectConstructor?.kind,
|
||||
isNamespaced = options.objectConstructor?.namespaced
|
||||
isNamespaced = options.objectConstructor?.namespaced,
|
||||
} = options || {};
|
||||
|
||||
if (!options.apiBase) {
|
||||
@@ -292,7 +292,7 @@ export class KubeApi<T extends KubeObject> {
|
||||
|
||||
return {
|
||||
apiPrefix: this.apiPrefix,
|
||||
apiGroup: this.apiGroup
|
||||
apiGroup: this.apiGroup,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -306,10 +306,10 @@ export class KubeApi<T extends KubeObject> {
|
||||
|
||||
// The apiPrefix and apiGroup might change due to fallbackApiBases, so we must override them
|
||||
Object.defineProperty(this, "apiPrefix", {
|
||||
value: apiPrefix
|
||||
value: apiPrefix,
|
||||
});
|
||||
Object.defineProperty(this, "apiGroup", {
|
||||
value: apiGroup
|
||||
value: apiGroup,
|
||||
});
|
||||
|
||||
const res = await this.request.get<IKubePreferredVersion>(`${this.apiPrefix}/${this.apiGroup}`);
|
||||
@@ -444,9 +444,9 @@ export class KubeApi<T extends KubeObject> {
|
||||
apiVersion: this.apiVersionWithGroup,
|
||||
metadata: {
|
||||
name,
|
||||
namespace
|
||||
}
|
||||
}, data)
|
||||
namespace,
|
||||
},
|
||||
}, data),
|
||||
});
|
||||
const parsed = this.parseResponse(res);
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
||||
|
||||
protected bindWatchEventsUpdater(delay = 1000) {
|
||||
reaction(() => this.eventsBuffer.length, this.updateFromEventsBuffer, {
|
||||
delay
|
||||
delay,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ export abstract class KubeObjectStore<T extends KubeObject> extends ItemStore<T>
|
||||
const watch = () => this.api.watch({
|
||||
namespace,
|
||||
abortController,
|
||||
callback
|
||||
callback,
|
||||
});
|
||||
|
||||
const { signal } = abortController;
|
||||
|
||||
@@ -82,7 +82,7 @@ export class KubeWatchApi {
|
||||
}
|
||||
|
||||
subscribeStores(stores: KubeObjectStore<KubeObject>[], opts: IKubeWatchSubscribeStoreOptions = {}): Disposer {
|
||||
const { preload = true, waitUntilLoaded = true, loadOnce = false, } = opts;
|
||||
const { preload = true, waitUntilLoaded = true, loadOnce = false } = opts;
|
||||
const subscribingNamespaces = opts.namespaces ?? this.context?.allNamespaces ?? [];
|
||||
const unsubscribeList: Function[] = [];
|
||||
let isUnsubscribed = false;
|
||||
|
||||
Reference in new issue
Block a user