🌳
pt0/deployF/k8sF/tryDryRunApplyAI.mts
8import type { KubeResource } from './ctxF/klusterCtxF.mts'
10type TryDryRunApplyProps = { resource: KubeResource, cluster_name: string }
12export const tryDryRunApply = async ({resource, cluster_name}: TryDryRunApplyProps): Promise<boolean> => {
13 const contents = JSON.stringify(resource, null, 2)
14 const tmpResPath = pathDownJoin(await ensureTmpDirExists('kubetmp'), calcHash(contents) + '.json')
15 await write1File(tmpResPath, contents)
17 const kubeConfigPath = await getResolvedKubeConfigPath(cluster_name)
18 const {kubeTlsInsecure = false} = getCurKlusterCfg(cluster_name) as {kubeTlsInsecure?: boolean}
20 const cmdA = [
21 'kubectl',
22 kubeTlsInsecure && '--insecure-skip-tls-verify',
23 'apply', '--dry-run=server', '-f', tmpResPath,
24 ].filter(Boolean) as string[]
26 const result = await do2ExecFile({
27 cmdA,
28 opts: {env: {...process.env, KUBECONFIG: kubeConfigPath}},
29 })
30 return result.isSuccess ?? false