mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use propagationPolicy=Background by default for delete (#4337)
This commit is contained in:
parent
4292968f82
commit
882f216368
@ -234,4 +234,40 @@ describe("KubeApi", () => {
|
||||
], "json");
|
||||
});
|
||||
});
|
||||
|
||||
describe("delete", () => {
|
||||
let api: TestKubeApi;
|
||||
|
||||
beforeEach(() => {
|
||||
api = new TestKubeApi({
|
||||
request,
|
||||
objectConstructor: TestKubeObject,
|
||||
});
|
||||
});
|
||||
|
||||
it("sends correct request", async () => {
|
||||
expect.hasAssertions();
|
||||
(fetch as any).mockResponse(async (request: Request) => {
|
||||
console.log(request.url);
|
||||
expect(request.method).toEqual("DELETE");
|
||||
expect(request.url).toEqual("http://127.0.0.1:9999/api-kube/api/v1/namespaces/default/pods/foo?propagationPolicy=Background");
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
await api.delete({ name: "foo", namespace: "default" });
|
||||
});
|
||||
|
||||
it("allows to change propagationPolicy", async () => {
|
||||
expect.hasAssertions();
|
||||
(fetch as any).mockResponse(async (request: Request) => {
|
||||
expect(request.method).toEqual("DELETE");
|
||||
expect(request.url).toMatch("propagationPolicy=Orphan");
|
||||
|
||||
return {};
|
||||
});
|
||||
|
||||
await api.delete({ name: "foo", namespace: "default", propagationPolicy: "Orphan" });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -24,7 +24,6 @@ import { autoBind } from "../../utils";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import type { JsonApiParams } from "../json-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { IPodContainer, IPodMetrics } from "./pods.api";
|
||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
||||
@ -121,14 +120,6 @@ export class Job extends WorkloadKubeObject {
|
||||
|
||||
return [...containers].map(container => container.image);
|
||||
}
|
||||
|
||||
delete() {
|
||||
const params: JsonApiParams = {
|
||||
query: { propagationPolicy: "Background" },
|
||||
};
|
||||
|
||||
return super.delete(params);
|
||||
}
|
||||
}
|
||||
|
||||
export class JobApi extends KubeApi<Job> {
|
||||
|
||||
@ -98,6 +98,8 @@ export interface ILocalKubeApiConfig {
|
||||
}
|
||||
}
|
||||
|
||||
export type PropagationPolicy = undefined | "Orphan" | "Foreground" | "Background";
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@ -502,11 +504,16 @@ export class KubeApi<T extends KubeObject> {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
async delete({ name = "", namespace = "default" }) {
|
||||
async delete({ name = "", namespace = "default", propagationPolicy = "Background" }: { name: string, namespace: string, propagationPolicy?: PropagationPolicy }) {
|
||||
await this.checkPreferredVersion();
|
||||
const apiUrl = this.getUrl({ namespace, name });
|
||||
const reqInit = {
|
||||
query: {
|
||||
propagationPolicy,
|
||||
},
|
||||
};
|
||||
|
||||
return this.request.del(apiUrl);
|
||||
return this.request.del(apiUrl, reqInit);
|
||||
}
|
||||
|
||||
getWatchUrl(namespace = "", query: IKubeApiQueryParams = {}) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user