From baab211790abf5673d8c8243e7ce5bd123a2187c Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Tue, 16 Jun 2020 14:42:46 +0100 Subject: [PATCH] Revert "Ability to set the image of pods based on label (#5781)" (#5783) This reverts commit 5dc3e4c46b649fe2de3e6970abb77a8330073991. --- lib/cli/README.md | 2 +- lib/cli/scripts/kubectl-image.ts | 48 ++++++-------------------------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/lib/cli/README.md b/lib/cli/README.md index 253a5540ab..7763e8a44a 100644 --- a/lib/cli/README.md +++ b/lib/cli/README.md @@ -47,7 +47,7 @@ In develop mode, the CLI takes the prebuilt scripts from the dist folder. |docker-publish |publish docker image| |init-aae-env |Init env| |kubectl-delete |delete kubectl | -|kubectl-image |This command allows you to update a specific service on the rancher env with a specific tag | +|kubectl-image |This command allows you to update a specific service on the rancher env with a specifig tag | |npm-publish | publish on npm | | update-commit-sha | his command allows you to update the commit sha as part of the `package.json`. Your `package.json` must to have an existing property called "commit" | |update-version |This command allows you to update the adf dependencies and js-api with different versions Update adf libs and js-api with latest alpha| diff --git a/lib/cli/scripts/kubectl-image.ts b/lib/cli/scripts/kubectl-image.ts index 378545a65c..1f3e8bbf57 100644 --- a/lib/cli/scripts/kubectl-image.ts +++ b/lib/cli/scripts/kubectl-image.ts @@ -28,8 +28,9 @@ export interface KubeArgs { token?: string; clusterEnv?: string; clusterUrl?: string; + serviceName?: string; dockerRepo?: string; - label?: string; + deployName?: string; } function setCluster(args: KubeArgs) { @@ -56,30 +57,9 @@ function useContext(args: KubeArgs) { logger.info(response); } -function getContainersName(args: KubeArgs): string[] { - logger.info('Perform get containers name...'); - const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*].spec.containers[*].name}`], {}); - logger.info(`container ${result}`); - return result ? result.split(' ') : []; -} - -function getUiName(args: KubeArgs): string[] { - logger.info('Perform get ui name...'); - const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*]..uiName}`], {}); - logger.info(`ui ${result}`); - return result ? result.split(' ') : []; -} - -function getNamespace(args: KubeArgs): string[] { - logger.info('Perform get ui namespace...'); - const result = exec('kubectl', [`get`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`, `-o`, `jsonpath={.items[*]..namespace}`], {}); - logger.info(`namespace ${result}`); - return result ? result.split(' ') : []; -} - -function setImage(args: KubeArgs, uiName: string, serviceName: string, namespace: string) { +function setImage(args: KubeArgs) { logger.info('Perform set image...'); - const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `deployment/${uiName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {}); + const response = exec('kubectl', [`set`, `image`, `deployment/${args.deployName}`, `${args.serviceName}=${args.dockerRepo}:${args.tag}`], {}); logger.info(response); } @@ -98,15 +78,16 @@ function main(args) { program .version('0.1.0') - .description('his command allows you to update a specific service on the rancher env with a specific tag \n\n' + - 'adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --label ${label} --dockerRepo ${dockerRepo} --tag ${tag}') + .description('his command allows you to update a specific service on the rancher env with a specifig tag \n\n' + + 'adf-cli kubectl-image --clusterEnv ${clusterEnv} --clusterUrl ${clusterUrl} --username ${username} --token ${token} --deployName ${deployName} --dockerRepo ${dockerRepo} --tag ${tag}') .option('--tag [type]', 'tag') .option('--installCheck [type]', 'install kube ctl') .option('--username [type]', 'username') .option('--clusterEnv [type]', 'cluster Env') .option('--clusterUrl [type]', 'cluster Url') + .option('--serviceName [type]', 'serviceName') .option('--dockerRepo [type]', 'docker Repo') - .option('--label [type]', 'pod label') + .option('--deployName [type]', 'deploy Name') .parse(process.argv); if (process.argv.includes('-h') || process.argv.includes('--help')) { @@ -123,17 +104,6 @@ function main(args) { setCredentials(args); setContext(args); useContext(args); - const containers: string [] = getContainersName(args); - logger.info(`container ${containers[0]}, ${containers.length}`); - - const uiNames = getUiName(args); - const namespaces = getNamespace(args); - for (let i = 0; i < containers.length; i++) { - const container = containers[i]; - const uiName = uiNames[i]; - const namespace = namespaces[i]; - logger.info(`Set image for ${container} with name ${uiName} of namespace: ${namespace}`); - setImage(args, uiName, container, namespace); - } + setImage(args); } }