diff --git a/README.md b/README.md index a791d9671..c19942873 100644 --- a/README.md +++ b/README.md @@ -524,7 +524,9 @@ OPTIONS The URL of the external Devfile registry. --helm-patch-yaml=helm-patch-yaml - Path to yaml file with Helm Chart values patch. The file format is identical to values.yaml from the chart. + Path to yaml file with Helm Chart values patch. + The file format is identical to values.yaml from the chart. + Note, Provided command line arguments take precedence over patch file. --k8spoddownloadimagetimeout=k8spoddownloadimagetimeout [default: 600000] Waiting time for Pod downloading image (in milliseconds) diff --git a/src/commands/server/deploy.ts b/src/commands/server/deploy.ts index f3a132458..9ca52ae1b 100644 --- a/src/commands/server/deploy.ts +++ b/src/commands/server/deploy.ts @@ -117,7 +117,9 @@ export default class Deploy extends Command { [CHE_OPERATOR_CR_YAML_KEY]: cheOperatorCRYaml, [CHE_OPERATOR_CR_PATCH_YAML_KEY]: cheOperatorCRPatchYaml, 'helm-patch-yaml': string({ - description: 'Path to yaml file with Helm Chart values patch. The file format is identical to values.yaml from the chart.', + description: `Path to yaml file with Helm Chart values patch. + The file format is identical to values.yaml from the chart. + Note, Provided command line arguments take precedence over patch file.`, default: '', }), 'workspace-pvc-storage-class-name': string({ diff --git a/src/tasks/installers/helm.ts b/src/tasks/installers/helm.ts index 8b7c02389..8481fa8b9 100644 --- a/src/tasks/installers/helm.ts +++ b/src/tasks/installers/helm.ts @@ -348,18 +348,9 @@ error: E_COMMAND_FAILED`) setOptions.push(`--set cheImage=${cheImage}`) setOptions.push(`--set che.disableProbes=${flags.debug}`) - if (flags['helm-patch-yaml']) { - // Read patch yaml. Has format the same as values.yaml - const patchTree: { [key: string]: any } = await this.kubeHelper.safeLoadFromYamlFile(flags['helm-patch-yaml']) - // Flat the yaml tree into key-value format - const patchProperties = this.prepareYamlPatch(patchTree) - // Add patch properties to the command - for (const property of patchProperties) { - setOptions.push(`--set ${property}`) - } - } + const patchFlags = flags['helm-patch-yaml'] ? '-f ' + flags['helm-patch-yaml'] : '' - let command = `helm upgrade --install che --force --namespace ${flags.chenamespace} ${setOptions.join(' ')} ${multiUserFlag} ${tlsFlag} ${destDir}` + let command = `helm upgrade --install che --force --namespace ${flags.chenamespace} ${setOptions.join(' ')} ${multiUserFlag} ${tlsFlag} ${patchFlags} ${destDir}` let { exitCode, stderr } = await execa(command, { timeout: execTimeout, reject: false, shell: true }) // if process failed, check the following @@ -389,25 +380,4 @@ error: E_COMMAND_FAILED`) } } - /** - * Returns flaten key=value structure of the given object. - * Nested object keys are separated by dot. - * @param patchTree object with properties and nested objects - */ - private prepareYamlPatch(patchTree: { [key: string]: any }): string[] { - const patches: string[] = [] - for (const key of Object.keys(patchTree)) { - const value = patchTree[key] - if (typeof value !== 'object') { - patches.push(`${key}=${value}`) - } else { - const subProperties = this.prepareYamlPatch(value) - for (const subProperty of subProperties) { - patches.push(`${key}.${subProperty}`) - } - } - } - return patches - } - }