mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
adc1dd3bd3
commit
ff6cef38e7
@ -3,7 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { access, mkdir, writeFile } from "fs/promises";
|
||||
import { writeFile } from "fs/promises";
|
||||
import { ensureDir } from "fs-extra";
|
||||
import directoryForUserDataInjectable from "../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import { getKubeAuthProxyCertificatePath } from "./kube-auth-proxy-cert";
|
||||
import * as selfsigned from "selfsigned";
|
||||
@ -18,7 +19,8 @@ const createKubeAuthProxyCertFilesInjectable = getInjectable({
|
||||
|
||||
return createKubeAuthProxyCertFiles(certPath, {
|
||||
generate: selfsigned.generate,
|
||||
access, mkdir, writeFile,
|
||||
ensureDir,
|
||||
writeFile,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { access, mkdir, writeFile } from "fs/promises";
|
||||
import type { writeFile } from "fs/promises";
|
||||
import type { ensureDir } from "fs-extra";
|
||||
import path from "path";
|
||||
import type * as selfsigned from "selfsigned";
|
||||
|
||||
@ -11,8 +12,7 @@ type SelfSignedGenerate = typeof selfsigned.generate;
|
||||
|
||||
interface CreateKubeAuthProxyCertificateFilesDependencies {
|
||||
generate: SelfSignedGenerate;
|
||||
access: typeof access;
|
||||
mkdir: typeof mkdir;
|
||||
ensureDir: typeof ensureDir;
|
||||
writeFile: typeof writeFile;
|
||||
}
|
||||
|
||||
@ -39,12 +39,7 @@ function getKubeAuthProxyCertificate(generate: SelfSignedGenerate): selfsigned.S
|
||||
export async function createKubeAuthProxyCertFiles(dir: string, dependencies: CreateKubeAuthProxyCertificateFilesDependencies): Promise<string> {
|
||||
const cert = getKubeAuthProxyCertificate(dependencies.generate);
|
||||
|
||||
try {
|
||||
await dependencies.access(dir);
|
||||
} catch {
|
||||
await dependencies.mkdir(dir);
|
||||
}
|
||||
|
||||
await dependencies.ensureDir(dir);
|
||||
await dependencies.writeFile(path.join(dir, "proxy.key"), cert.private);
|
||||
await dependencies.writeFile(path.join(dir, "proxy.crt"), cert.cert);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user