[ADF-4733] AdfCli - Kubectl-image add option to install the kubectl (#4941)

* add the npm install kubectl option

* fix tslint

* add docs
This commit is contained in:
Maurizio Vitale 2019-07-16 12:49:01 +01:00 committed by Eugenio Romano
parent 601f975485
commit 7791205077
2 changed files with 21 additions and 7 deletions

View File

@ -52,3 +52,5 @@ This command allows you to update a specific service on the rancher env with a s
```bash
adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --deployName ${deployName} --dockerRepo ${dockerRepo} --tag ${tag}
```
You can use the option --installCheck to install kubectl as part of the command

View File

@ -22,12 +22,12 @@ import { spawnSync } from 'child_process';
export interface KubeArgs {
tag?: string;
installCheck?: boolean;
username?: string;
token?: string;
clusterEnv?: string;
clusterUrl?: string;
dockerRepo?: string;
dockerTag?: string;
deployName?: string;
}
@ -82,10 +82,22 @@ function _setImage(args: KubeArgs, logger: logging.Logger) {
logger.info(response);
}
export default async function (args: KubeArgs, logger: logging.Logger) {
_setCluster(args, logger);
_setCredentials(args, logger);
_setContext(args, logger);
_useContext(args, logger);
_setImage(args, logger);
function _installPerform(args: KubeArgs, logger: logging.Logger) {
logger.info('Perform install...');
const responseK8sStable = _exec('curl', [`-s`, `https://storage.googleapis.com/kubernetes-release/release/stable.txt`], {}, logger).trim();
const k8sRelease = `https://storage.googleapis.com/kubernetes-release/release/${responseK8sStable}/bin/linux/amd64/kubectl`;
_exec('curl', [`LO`, `${k8sRelease}`], {}, logger);
}
export default async function (args: KubeArgs, logger: logging.Logger) {
if (args.installCheck === true) {
_installPerform(args, logger);
}
if (args.tag !== undefined) {
_setCluster(args, logger);
_setCredentials(args, logger);
_setContext(args, logger);
_useContext(args, logger);
_setImage(args, logger);
}
}