1import * as _ from 'lodash-es' 10type BackupResource = KubeResource & { status?: unknown, metadata: { name: string, namespace?: string, resourceVersion?: string, annotations?: Record<string, string> } } 11type BackupProps = WithClusterAndResource & { resource: BackupResource } 13export const getResBackDir = ({resource, cluster_name}: BackupProps) => { 14 const { kind, metadata } = resource 15 const {namespace='default'} = metadata 20 [cluster_name, namespace].join('-'), 26const getResVersPath = ({resource, cluster_name}: BackupProps) => { 27 const res = _.clone(resource) 29 const {metadata} = res 30 delete metadata.resourceVersion 31 const {annotations} = res.metadata 33 delete annotations['kubectl.kubernetes.io/last-applied-configuration'] 38 getResBackDir({resource: res, cluster_name}), 39 `${resourceVersion}.json`, 43export const backupSeenKubeResource = async ({resource, cluster_name}: {resource?: BackupResource | null, cluster_name: string}) => { 44 if (!resource) return // TODO save "that it didn't exist" 46 const resVersPath = getResVersPath({resource, cluster_name})