Skip to content

Commit

Permalink
Merge pull request Stono#13 from messiahUA/master
Browse files Browse the repository at this point in the history
Fix helm version extraction
  • Loading branch information
Stono committed Feb 11, 2021
2 parents 8bac554 + f8caf15 commit 8e6dc19
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/helm.js
Expand Up @@ -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(?<major>[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) {
Expand Down

0 comments on commit 8e6dc19

Please sign in to comment.