From 027617fa02e5b04ba0d65a3fc349b3945266e8f6 Mon Sep 17 00:00:00 2001 From: Mykola Morhun Date: Thu, 10 Dec 2020 15:53:31 +0200 Subject: [PATCH] Use -f with yaml of helm patch Signed-off-by: Mykola Morhun --- src/tasks/installers/helm.ts | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) 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 - } - }