mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
let semver to parse the version (#11463)
* let semver to parse the version * check
This commit is contained in:
@@ -16,8 +16,7 @@ export const KubeCtlToolName = 'kubectl';
|
|||||||
|
|
||||||
interface KubeCtlVersion {
|
interface KubeCtlVersion {
|
||||||
clientVersion: {
|
clientVersion: {
|
||||||
major: string;
|
gitVersion: string;
|
||||||
minor: string;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,8 +49,11 @@ export class KubeCtlTool extends ToolBase {
|
|||||||
let version: SemVer | undefined = undefined;
|
let version: SemVer | undefined = undefined;
|
||||||
if (output) {
|
if (output) {
|
||||||
const versionJson: KubeCtlVersion = JSON.parse(output);
|
const versionJson: KubeCtlVersion = JSON.parse(output);
|
||||||
// kubectl version output might contain '+' character in the minor version, e.g. 16+, we have to remove it to make it a valid semantic version string.
|
if (versionJson && versionJson.clientVersion && versionJson.clientVersion.gitVersion) {
|
||||||
version = new SemVer(`${versionJson.clientVersion.major}.${versionJson.clientVersion.minor.replace(/\+/g, '')}.0`);
|
version = new SemVer(versionJson.clientVersion.gitVersion);
|
||||||
|
} else {
|
||||||
|
throw new Error(localize('resourceDeployment.invalidKubectlVersionOutput', "Unable to parse the kubectl version command output: \"{0}\"", output));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user