diff --git a/lib/helm.js b/lib/helm.js index bfd6eab..186f455 100644 --- a/lib/helm.js +++ b/lib/helm.js @@ -69,10 +69,16 @@ module.exports = function Helm(exec) { 3: 'helm template --namespace default release-name .' }; - const helmVersion = exec.commandSync('helm version --client --short').stdout - let version = 2 - if (helmVersion && helmVersion.startsWith('Client: v')) { - version = parseInt(helmVersion.replace('Client: v', '')[0]) + let version = -1; + + const helmVersion = exec.commandSync('helm version --client --short').stdout; + const helmVersionRegExp = new RegExp('v(?[0-9])+\.[0-9]+\.[0-9]+'); + const helmVersionRegExpMatches = helmVersion ? helmVersion.match(helmVersionRegExp) : null; + + if (helmVersionRegExpMatches) { + version = parseInt(helmVersionRegExpMatches.groups.major); + } else { + throw new Error(`Cannot parse helm version: ${helmVersion}`); } if (version !== 2 && version !== 3) {