-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*----------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
/* eslint-disable @typescript-eslint/camelcase */ | ||
|
||
|
||
import { cli } from './cli'; | ||
import { Command } from './cli-command'; | ||
|
||
interface Versions { | ||
openshift_Version: string; | ||
kubernetes_Version: string; | ||
} | ||
|
||
export async function getClusterVersions(): Promise<Versions> { | ||
const result = await cli.execute(Command.printOcVersionJson()); | ||
const versions: Versions = { | ||
kubernetes_Version: undefined, | ||
openshift_Version: undefined | ||
}; | ||
if (!result.error) { | ||
try { | ||
const versionsJson = JSON.parse(result.stdout); | ||
if (versionsJson?.serverVersion?.major && versionsJson?.serverVersion?.minor) { | ||
versions.kubernetes_Version = `${versionsJson.serverVersion.major}.${versionsJson.serverVersion.minor}`; | ||
} | ||
if (versionsJson?.openshiftVersion) { | ||
versions.openshift_Version = versionsJson.openshiftVersion; | ||
} | ||
|
||
} catch (err) { | ||
// ignore and return undefined | ||
} | ||
} | ||
return versions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters