🌳
pt0/deployF/k8sF/pvcF/kubeActionPvcF.mts
1import * as _ from 'lodash-es'
5import { getKlusterCtx, type KubeResource } from '../ctxF/klusterCtxF.mts'
6import { isPvc } from '../isKubeResF.mts'
11type KubeActionPvcProps = {
12 softdeleted?: boolean
13 [key: string]: any
16export const kubeActionPvc = async (props: KubeActionPvcProps) => {
17 let {cluster_name} = getKlusterCtx(props)
18 let action = getAction()
19 if (action == 'delete') {
20 props.softdeleted = true
21 action = 'patch'
22 }
23 let noDelPvcs = true
24 const resources: KubeResource[] = await genericPvcTmplA(props as any)
25 if (action == 'delpvcs') {
26 console.log(..._.map(resources, (resource) => inspect2KubeRes({resource, cluster_name})))
27 await guardPromptEq('Are you sure delete pvcs^? Your data is throw-away or backed up (y/n)? ', 'y')
28 action = 'delete'
29 noDelPvcs = false
30 }
31 if (props.softdeleted) {
32 const resource = _.find(resources, isPvc)
33 const existingPvc = await read2Resource({resource: resource!, cluster_name})
34 if (!existingPvc) return
35 }
37 resources,
38 action, cluster_name,
39 noDelPvcs,
40 })