mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 01:25:38 -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 {
|
||||
clientVersion: {
|
||||
major: string;
|
||||
minor: string;
|
||||
gitVersion: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -50,8 +49,11 @@ export class KubeCtlTool extends ToolBase {
|
||||
let version: SemVer | undefined = undefined;
|
||||
if (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.
|
||||
version = new SemVer(`${versionJson.clientVersion.major}.${versionJson.clientVersion.minor.replace(/\+/g, '')}.0`);
|
||||
if (versionJson && versionJson.clientVersion && versionJson.clientVersion.gitVersion) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user