🌳
pt0/deployF/k8sF/resActionsF/res1ActionF.mts
7import type { KubeResource } from '../ctxF/klusterCtxF.mts'
9export const resActionsH = () => _resActionsH
11type Res1ActionProps = {
12 action?: string
13 resource: KubeResource
14 cluster_name?: string
15 noDelPvcs?: boolean
18export const res1Action = async ({action, resource, cluster_name, noDelPvcs}: Res1ActionProps) => {
19 if (isApplyishAction(action) && action !== 'apply') action = 'apply'
20 if (action === 'apply' || action === 'resources') resource = await rewriteResourceImgRefs(resource)
21 const fncsH = {
22 ...resActionsH(),
23 ...filterObj(availActionsCtx.getStore() || {}, (val, key) => {
24 if (!(val as any)?.runActionPerK8sRes) return
25 return [key, val] as [string, unknown]
26 }),
27 } as Record<string, ((props: {resource: KubeResource, cluster_name?: string}) => Promise<void>) | undefined>
28 const resActionFnc = action ? fncsH[action] : undefined
29 if (resActionFnc) {
30 await resActionFnc({resource, cluster_name})
31 return
32 }
33 return await resPlainAction({action: action as Parameters<typeof resPlainAction>[0]['action'], resource, cluster_name, noDelPvcs})