mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
handle invalid character in kubectl version output (#11460)
This commit is contained in:
@@ -14,6 +14,13 @@ const localize = nls.loadMessageBundle();
|
|||||||
const defaultInstallationRoot = '/usr/local/bin';
|
const defaultInstallationRoot = '/usr/local/bin';
|
||||||
export const KubeCtlToolName = 'kubectl';
|
export const KubeCtlToolName = 'kubectl';
|
||||||
|
|
||||||
|
interface KubeCtlVersion {
|
||||||
|
clientVersion: {
|
||||||
|
major: string;
|
||||||
|
minor: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export class KubeCtlTool extends ToolBase {
|
export class KubeCtlTool extends ToolBase {
|
||||||
constructor(platformService: IPlatformService) {
|
constructor(platformService: IPlatformService) {
|
||||||
super(platformService);
|
super(platformService);
|
||||||
@@ -42,8 +49,9 @@ export class KubeCtlTool extends ToolBase {
|
|||||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||||
let version: SemVer | undefined = undefined;
|
let version: SemVer | undefined = undefined;
|
||||||
if (output) {
|
if (output) {
|
||||||
const versionJson = JSON.parse(output);
|
const versionJson: KubeCtlVersion = JSON.parse(output);
|
||||||
version = new SemVer(`${versionJson.clientVersion.major}.${versionJson.clientVersion.minor}.0`);
|
// 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`);
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user