🌳
pt0/deployF/decAppCfgResGitShaF.mts
2import * as _ from 'lodash-es'
4import type { AppCfg } from './k8sF/ctxF/appCfgCtxF.mts'
11export const decAppCfgResGitSha = async ({appConfig}: {appConfig: AppCfg}) => {
12 const {resourceTmpl, cluster_name} = appConfig
13 const action = getAction()
15 if (!['info', 'diff', 'gitlog'].includes(action)) return appConfig
17 const manualRange = getManualRange()
18 if (manualRange) {
19 appConfig.existingGitSha = (await liveRepoExec({cmd: `git rev-parse ${manualRange.from}`})).trim()
20 return appConfig
21 }
23 if (!cluster_name) {
24 if (action === 'gitlog') return appConfig
25 appConfig.existingGitSha = (await liveRepoExec({cmd: 'git rev-parse HEAD~1'})).trim()
26 return appConfig
27 }
29 const existingResource = await read2Resource({resource: resourceTmpl as KubeResource, cluster_name})
31 Object.assign(appConfig, {existingGitSha: _.get(existingResource, kubeResGitShaPath)})
33 return appConfig