1
1
import { pathExists } from 'fs-extra'
2
2
import { mkdir , unlink , writeFile } from 'fs/promises'
3
- import { cloneDeep , get , isEmpty , isEqual , merge , omit , pick , set } from 'lodash'
3
+ import { cloneDeep , get , isEmpty , isEqual , merge , mergeWith , omit , pick , set } from 'lodash'
4
4
import path from 'path'
5
5
import { supportedK8sVersions } from 'src/supportedK8sVersions.json'
6
6
import { stringify } from 'yaml'
@@ -102,6 +102,12 @@ export const getRepo = (values: Record<string, any>): Repo => {
102
102
return { remote, branch, email, username, password }
103
103
}
104
104
105
+ function mergeCustomizer ( prev , next ) {
106
+ console . info ( 'PREVIOUS: ' , prev )
107
+ console . info ( 'NEXT: ' , next )
108
+ return next
109
+ }
110
+
105
111
let hasSops = false
106
112
/**
107
113
* Writes new values to a file. Will keep the original values if `overwrite` is `false`.
@@ -121,7 +127,7 @@ export const writeValuesToFile = async (
121
127
const values = cloneDeep ( inValues )
122
128
const originalValues = ( await loadYaml ( targetPath + suffix , { noError : true } ) ) ?? { }
123
129
d . debug ( 'originalValues: ' , JSON . stringify ( originalValues , null , 2 ) )
124
- const mergeResult = merge ( cloneDeep ( originalValues ) , values )
130
+ const mergeResult = mergeWith ( cloneDeep ( originalValues ) , values , mergeCustomizer )
125
131
const cleanedValues = removeBlankAttributes ( values )
126
132
const cleanedMergeResult = removeBlankAttributes ( mergeResult )
127
133
if ( ( ( overwrite && isEmpty ( cleanedValues ) ) || ( ! overwrite && isEmpty ( cleanedMergeResult ) ) ) && isSecretsFile ) {
0 commit comments