From f5934054187f8fcf93f5c35f285e7dbee621b469 Mon Sep 17 00:00:00 2001 From: ansheno Date: Tue, 6 Mar 2018 12:36:49 +0530 Subject: [PATCH 1/3] Added secrets section in Kubernetes Task --- .../resources.resjson/en-US/resources.resjson | 18 +++-- Tasks/Kubernetes/src/kubernetes.ts | 4 +- ...sregistrysecret.ts => kubernetessecret.ts} | 48 ++++++++++- Tasks/Kubernetes/task.json | 79 +++++++++++++------ Tasks/Kubernetes/task.loc.json | 69 +++++++++++----- 5 files changed, 160 insertions(+), 58 deletions(-) rename Tasks/Kubernetes/src/{kubernetesregistrysecret.ts => kubernetessecret.ts} (64%) diff --git a/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson index c56a1118ca8a..db054ab7319c 100644 --- a/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson @@ -4,11 +4,13 @@ "loc.description": "Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.", "loc.instanceNameFormat": "kubectl $(command)", "loc.group.displayName.commands": "Commands", - "loc.group.displayName.registry": "Container Registry Details", + "loc.group.displayName.secrets": "Secrets", "loc.group.displayName.advanced": "Advanced", "loc.group.displayName.output": "Output", "loc.input.label.kubernetesServiceEndpoint": "Kubernetes Service Connection", "loc.input.help.kubernetesServiceEndpoint": "Select a Kubernetes service connection.", + "loc.input.label.namespace": "Namespace", + "loc.input.help.namespace": "Name of the namespace to run the command in.", "loc.input.label.command": "Command", "loc.input.help.command": "Select a kubectl command.", "loc.input.label.useConfigurationFile": "Use Configuration files", @@ -17,6 +19,10 @@ "loc.input.help.configuration": "Filename, directory, or URL to kubernetes configuration files that will be used with the commands.", "loc.input.label.arguments": "Arguments", "loc.input.help.arguments": "Command arguments.", + "loc.input.label.secretType": "Type of secret", + "loc.input.help.secretType": "Select a type of secret", + "loc.input.label.secretArguments": "Arguments", + "loc.input.help.secretArguments": "Secret arguments.", "loc.input.label.containerRegistryType": "Container Registry type", "loc.input.help.containerRegistryType": "Select a Container registry type.", "loc.input.label.dockerRegistryEndpoint": "Docker Registry Connection", @@ -26,9 +32,9 @@ "loc.input.label.azureContainerRegistry": "Azure Container Registry", "loc.input.help.azureContainerRegistry": "Select an Azure Container Registry. Required for commands that need to authenticate with a registry.", "loc.input.label.secretName": "Secret name", - "loc.input.help.secretName": "Name of the docker-registry secret. You can use this secret name in the Kubernetes YAML configuration file.", + "loc.input.help.secretName": "Name of the secret. You can use this secret name in the Kubernetes YAML configuration file.", "loc.input.label.forceUpdate": "Force update secret", - "loc.input.help.forceUpdate": "Delete the docker-registry secret if it exists and create a new one with updated values.", + "loc.input.help.forceUpdate": "Delete the secret if it exists and create a new one with updated values.", "loc.input.label.versionOrLocation": "Kubectl", "loc.input.label.versionSpec": "Version Spec", "loc.input.help.versionSpec": "Version Spec of version to get. Examples: 1.7.0, 1.x.0, 4.x.0, 6.10.0, >=6.10.0", @@ -36,8 +42,6 @@ "loc.input.help.checkLatest": "Always checks online for the latest available version (stable.txt) that satisfies the version spec. This is typically false unless you have a specific scenario to always get latest. This will cause it to incur download costs when potentially not necessary, especially with the hosted build pool.", "loc.input.label.specifyLocation": "Path to Kubectl", "loc.input.help.specifyLocation": "Full path to the kubectl.exe", - "loc.input.label.namespace": "Namespace", - "loc.input.help.namespace": "Name of the namespace to run the command in.", "loc.input.label.cwd": "Working directory", "loc.input.help.cwd": "Working directory for the Kubectl command.", "loc.input.label.outputFormat": "Output format", @@ -45,8 +49,8 @@ "loc.input.label.kubectlOutput": "Output variable name", "loc.input.help.kubectlOutput": "Name of the variable in which output of the command should be saved.", "loc.messages.DownloadingClient": "Downloading kubernetes client.", - "loc.messages.CreatingSecret": "Executing create docker-registry %s secret.", - "loc.messages.DeleteSecret": "Executing delete docker-registry %s secret", + "loc.messages.CreatingSecret": "Executing create %s secret.", + "loc.messages.DeleteSecret": "Executing delete %s secret", "loc.messages.DockerRegistryConnectionNotSpecified": "Docker Registry connection details not specified", "loc.messages.FileNotFoundException": "Can not find file at location: %s", "loc.messages.DownloadingKubeCtlFromUrl": "Downloading Kubectl from Url: %s", diff --git a/Tasks/Kubernetes/src/kubernetes.ts b/Tasks/Kubernetes/src/kubernetes.ts index 6feb51e3bd53..ac73eac7f582 100644 --- a/Tasks/Kubernetes/src/kubernetes.ts +++ b/Tasks/Kubernetes/src/kubernetes.ts @@ -5,7 +5,7 @@ import path = require('path'); import ClusterConnection from "./clusterconnection"; import * as kubectl from "./kubernetescommand"; -import * as kubectlRegistrySecret from "./kubernetesregistrysecret"; +import * as kubectlSecret from "./kubernetessecret"; import AuthenticationTokenProvider from "docker-common/registryauthenticationprovider/authenticationtokenprovider" import ACRAuthenticationTokenProvider from "docker-common/registryauthenticationprovider/acrauthenticationtokenprovider" @@ -42,7 +42,7 @@ function run(clusterConnection: ClusterConnection, registryAuthenticationToken: var secretName = tl.getInput("secretName", false); if(secretName) { - kubectlRegistrySecret.run(clusterConnection, registryAuthenticationToken, secretName).fin(function cleanup(){ + kubectlSecret.run(clusterConnection, registryAuthenticationToken, secretName).fin(function cleanup(){ clusterConnection.close(); }).then(function success() { executeKubectlCommand(clusterConnection); diff --git a/Tasks/Kubernetes/src/kubernetesregistrysecret.ts b/Tasks/Kubernetes/src/kubernetessecret.ts similarity index 64% rename from Tasks/Kubernetes/src/kubernetesregistrysecret.ts rename to Tasks/Kubernetes/src/kubernetessecret.ts index 6da4e5e8ce46..4a42f90479b7 100644 --- a/Tasks/Kubernetes/src/kubernetesregistrysecret.ts +++ b/Tasks/Kubernetes/src/kubernetessecret.ts @@ -8,19 +8,32 @@ import ClusterConnection from "./clusterconnection"; import AuthenticationToken from "docker-common/registryauthenticationprovider/registryauthenticationtoken" export function run(connection: ClusterConnection, authenticationToken: AuthenticationToken, secret: string): any { - + if(tl.getBoolInput("forceUpdate") == true) { return deleteSecret(connection, secret).fin(() =>{ return createSecret(connection, authenticationToken, secret); }); } else { return createSecret(connection, authenticationToken, secret); + } +} + +function createSecret(connection: ClusterConnection, authenticationToken: AuthenticationToken, secret: string): any { + var typeOfSecret = tl.getInput("secretType", true); + if (typeOfSecret === "dockerRegistry") + { + return createDockerRegistrySecret(connection, authenticationToken, secret); + } + else if (typeOfSecret === "generic") + { + return createGenericSecret(connection, secret); } } function deleteSecret(connection: ClusterConnection, secret: string): any { tl.debug(tl.loc('DeleteSecret', secret)); var command = connection.createCommand(); + command.arg(getNameSpace()); command.arg("delete"); command.arg("secret"); command.arg(secret); @@ -33,12 +46,13 @@ function deleteSecret(connection: ClusterConnection, secret: string): any { return connection.execCommand(command, executionOption); } -function createSecret(connection: ClusterConnection, authenticationToken: AuthenticationToken, secret: string): any { +function createDockerRegistrySecret(connection: ClusterConnection, authenticationToken: AuthenticationToken, secret: string): any { if(authenticationToken) { tl.debug(tl.loc('CreatingSecret', secret)); var command = connection.createCommand(); + command.arg(getNameSpace()); command.arg("create") command.arg("secret"); command.arg("docker-registry"); @@ -47,6 +61,7 @@ function createSecret(connection: ClusterConnection, authenticationToken: Authen command.arg("--docker-username="+ authenticationToken.getUsername()); command.arg("--docker-password="+ authenticationToken.getPassword()); command.arg("--docker-email="+ authenticationToken.getEmail()); + return connection.execCommand(command); } else @@ -55,4 +70,33 @@ function createSecret(connection: ClusterConnection, authenticationToken: Authen throw new Error(tl.loc("DockerRegistryConnectionNotSpecified")); } +} + +function createGenericSecret(connection: ClusterConnection, secret: string): any { + + tl.debug(tl.loc('CreatingSecret', secret)); + var command = connection.createCommand(); + command.arg(getNameSpace()); + command.arg("create") + command.arg("secret"); + command.arg("generic"); + command.arg(secret); + var secretArguments = tl.getInput("secretArguments", false); + if (secretArguments) + { + command.line(secretArguments); + } + + return connection.execCommand(command); +} + +function getNameSpace(): string[] { + var args: string[] =[]; + var namespace = tl.getInput("namespace", false); + if(namespace) { + args[0] = "-n"; + args[1] = namespace; + } + + return args; } \ No newline at end of file diff --git a/Tasks/Kubernetes/task.json b/Tasks/Kubernetes/task.json index cf9cf6ddd837..5bca337a70d3 100644 --- a/Tasks/Kubernetes/task.json +++ b/Tasks/Kubernetes/task.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 14 + "Patch": 16 }, "demands": [], "preview": "false", @@ -24,10 +24,10 @@ "isExpanded": true }, { - "name": "registry", - "displayName": "Container Registry Details", + "name": "secrets", + "displayName": "Secrets", "isExpanded": false - }, + }, { "name": "advanced", "displayName": "Advanced", @@ -47,6 +47,14 @@ "label": "Kubernetes Service Connection", "helpMarkDown": "Select a Kubernetes service connection." }, + { + "name": "namespace", + "type": "string", + "label": "Namespace", + "required": false, + "defaultValue": "", + "helpMarkDown": "Name of the namespace to run the command in." + }, { "name": "command", "type": "pickList", @@ -101,6 +109,33 @@ "helpMarkDown": "Command arguments.", "groupName": "commands" }, + { + "name": "secretType", + "type": "pickList", + "label": "Type of secret", + "defaultValue": "dockerRegistry", + "required": true, + "options": { + "dockerRegistry": "dockerRegistry", + "generic": "generic" + }, + "helpMarkDown": "Select a type of secret", + "groupName": "secrets" + }, + { + "name": "secretArguments", + "type": "multiLine", + "properties": { + "resizable": "true", + "rows": "2", + "editorExtension": "ms.vss-services-azure.kubernetes-parameters-grid" + }, + "label": "Arguments", + "defaultValue":"", + "helpMarkDown": "Secret arguments.", + "visibleRule": "secretType = generic", + "groupName": "secrets" + }, { "name": "containerRegistryType", "type": "pickList", @@ -112,7 +147,8 @@ "Container Registry": "Container Registry" }, "helpMarkDown": "Select a Container registry type.", - "groupName": "registry" + "visibleRule": "secretType = dockerRegistry", + "groupName": "secrets" }, { "name": "dockerRegistryEndpoint", @@ -120,8 +156,8 @@ "type": "connectedService:dockerregistry", "label": "Docker Registry Connection", "helpMarkDown": "Select a Docker registry connection. Required for commands that need to authenticate with a registry.", - "visibleRule": "containerRegistryType = Container Registry", - "groupName": "registry" + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Container Registry", + "groupName": "secrets" }, { "name": "azureSubscriptionEndpoint", @@ -129,18 +165,18 @@ "type": "connectedService:AzureRM", "label": "Azure subscription", "helpMarkDown": "Select an Azure subscription, which has your Azure Container Registry.", - "visibleRule": "containerRegistryType = Azure Container Registry", + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Azure Container Registry", "defaultValue": "", - "groupName": "registry" + "groupName": "secrets" }, { "name": "azureContainerRegistry", "label": "Azure Container Registry", "type": "pickList", "helpMarkDown": "Select an Azure Container Registry. Required for commands that need to authenticate with a registry.", - "visibleRule": "containerRegistryType = Azure Container Registry", + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Azure Container Registry", "defaultValue": "", - "groupName": "registry" + "groupName": "secrets" }, { "name": "secretName", @@ -148,16 +184,16 @@ "label": "Secret name", "required": false, "defaultValue": "", - "helpMarkDown": "Name of the docker-registry secret. You can use this secret name in the Kubernetes YAML configuration file.", - "groupName": "registry" + "helpMarkDown": "Name of the secret. You can use this secret name in the Kubernetes YAML configuration file.", + "groupName": "secrets" }, { "name": "forceUpdate", "type": "boolean", "label": "Force update secret", "defaultValue": "true", - "helpMarkDown": "Delete the docker-registry secret if it exists and create a new one with updated values.", - "groupName": "registry" + "helpMarkDown": "Delete the secret if it exists and create a new one with updated values.", + "groupName": "secrets" }, { "name": "versionOrLocation", @@ -200,15 +236,6 @@ "groupName": "advanced", "visibleRule": "versionOrLocation = location" }, - { - "name": "namespace", - "type": "string", - "label": "Namespace", - "required": false, - "defaultValue": "", - "helpMarkDown": "Name of the namespace to run the command in.", - "groupName": "commands" - }, { "name": "cwd", "aliases": ["workingDirectory"], @@ -260,8 +287,8 @@ }, "messages": { "DownloadingClient": "Downloading kubernetes client.", - "CreatingSecret": "Executing create docker-registry %s secret.", - "DeleteSecret": "Executing delete docker-registry %s secret", + "CreatingSecret": "Executing create %s secret.", + "DeleteSecret": "Executing delete %s secret", "DockerRegistryConnectionNotSpecified": "Docker Registry connection details not specified", "FileNotFoundException": "Can not find file at location: %s", "DownloadingKubeCtlFromUrl": "Downloading Kubectl from Url: %s", diff --git a/Tasks/Kubernetes/task.loc.json b/Tasks/Kubernetes/task.loc.json index 81295ec6274e..2a16d63d0f2c 100644 --- a/Tasks/Kubernetes/task.loc.json +++ b/Tasks/Kubernetes/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 14 + "Patch": 16 }, "demands": [], "preview": "false", @@ -24,8 +24,8 @@ "isExpanded": true }, { - "name": "registry", - "displayName": "ms-resource:loc.group.displayName.registry", + "name": "secrets", + "displayName": "ms-resource:loc.group.displayName.secrets", "isExpanded": false }, { @@ -49,6 +49,14 @@ "label": "ms-resource:loc.input.label.kubernetesServiceEndpoint", "helpMarkDown": "ms-resource:loc.input.help.kubernetesServiceEndpoint" }, + { + "name": "namespace", + "type": "string", + "label": "ms-resource:loc.input.label.namespace", + "required": false, + "defaultValue": "", + "helpMarkDown": "ms-resource:loc.input.help.namespace" + }, { "name": "command", "type": "pickList", @@ -103,6 +111,33 @@ "helpMarkDown": "ms-resource:loc.input.help.arguments", "groupName": "commands" }, + { + "name": "secretType", + "type": "pickList", + "label": "ms-resource:loc.input.label.secretType", + "defaultValue": "dockerRegistry", + "required": true, + "options": { + "dockerRegistry": "dockerRegistry", + "generic": "generic" + }, + "helpMarkDown": "ms-resource:loc.input.help.secretType", + "groupName": "secrets" + }, + { + "name": "secretArguments", + "type": "multiLine", + "properties": { + "resizable": "true", + "rows": "2", + "editorExtension": "ms.vss-services-azure.kubernetes-parameters-grid" + }, + "label": "ms-resource:loc.input.label.secretArguments", + "defaultValue": "", + "helpMarkDown": "ms-resource:loc.input.help.secretArguments", + "visibleRule": "secretType = generic", + "groupName": "secrets" + }, { "name": "containerRegistryType", "type": "pickList", @@ -114,7 +149,8 @@ "Container Registry": "Container Registry" }, "helpMarkDown": "ms-resource:loc.input.help.containerRegistryType", - "groupName": "registry" + "visibleRule": "secretType = dockerRegistry", + "groupName": "secrets" }, { "name": "dockerRegistryEndpoint", @@ -124,8 +160,8 @@ "type": "connectedService:dockerregistry", "label": "ms-resource:loc.input.label.dockerRegistryEndpoint", "helpMarkDown": "ms-resource:loc.input.help.dockerRegistryEndpoint", - "visibleRule": "containerRegistryType = Container Registry", - "groupName": "registry" + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Container Registry", + "groupName": "secrets" }, { "name": "azureSubscriptionEndpoint", @@ -135,18 +171,18 @@ "type": "connectedService:AzureRM", "label": "ms-resource:loc.input.label.azureSubscriptionEndpoint", "helpMarkDown": "ms-resource:loc.input.help.azureSubscriptionEndpoint", - "visibleRule": "containerRegistryType = Azure Container Registry", + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Azure Container Registry", "defaultValue": "", - "groupName": "registry" + "groupName": "secrets" }, { "name": "azureContainerRegistry", "label": "ms-resource:loc.input.label.azureContainerRegistry", "type": "pickList", "helpMarkDown": "ms-resource:loc.input.help.azureContainerRegistry", - "visibleRule": "containerRegistryType = Azure Container Registry", + "visibleRule": "secretType = dockerRegistry && containerRegistryType = Azure Container Registry", "defaultValue": "", - "groupName": "registry" + "groupName": "secrets" }, { "name": "secretName", @@ -155,7 +191,7 @@ "required": false, "defaultValue": "", "helpMarkDown": "ms-resource:loc.input.help.secretName", - "groupName": "registry" + "groupName": "secrets" }, { "name": "forceUpdate", @@ -163,7 +199,7 @@ "label": "ms-resource:loc.input.label.forceUpdate", "defaultValue": "true", "helpMarkDown": "ms-resource:loc.input.help.forceUpdate", - "groupName": "registry" + "groupName": "secrets" }, { "name": "versionOrLocation", @@ -206,15 +242,6 @@ "groupName": "advanced", "visibleRule": "versionOrLocation = location" }, - { - "name": "namespace", - "type": "string", - "label": "ms-resource:loc.input.label.namespace", - "required": false, - "defaultValue": "", - "helpMarkDown": "ms-resource:loc.input.help.namespace", - "groupName": "commands" - }, { "name": "cwd", "aliases": [ From 5bf057b19ff18b6e34cd99d0304dc1ddb64a839e Mon Sep 17 00:00:00 2001 From: ansheno Date: Tue, 6 Mar 2018 13:17:24 +0530 Subject: [PATCH 2/3] Update the patch version and added test cases --- Tasks/Kubernetes/Tests/L0.ts | 43 ++++++++++++++++++++++++++++ Tasks/Kubernetes/Tests/TestSetup.ts | 5 ++++ Tasks/Kubernetes/Tests/TestShared.ts | 2 ++ Tasks/Kubernetes/task.json | 2 +- Tasks/Kubernetes/task.loc.json | 2 +- 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Tasks/Kubernetes/Tests/L0.ts b/Tasks/Kubernetes/Tests/L0.ts index 1cb7ed85453e..fcc9123b340c 100644 --- a/Tasks/Kubernetes/Tests/L0.ts +++ b/Tasks/Kubernetes/Tests/L0.ts @@ -21,6 +21,8 @@ describe('Kubernetes Suite', function() { delete process.env[shared.TestEnvVars.namespace]; delete process.env[shared.TestEnvVars.arguments]; delete process.env[shared.TestEnvVars.useConfigurationFile]; + delete process.env[shared.TestEnvVars.secretType]; + delete process.env[shared.TestEnvVars.secretArguments]; delete process.env[shared.TestEnvVars.secretName]; delete process.env[shared.TestEnvVars.forceUpdate]; delete process.env[shared.TestEnvVars.outputFormat]; @@ -269,6 +271,47 @@ describe('Kubernetes Suite', function() { done(); }); + it('Runs successfully for kubectl generic secrets with forceUpdate', (done:MochaDone) => { + let tp = path.join(__dirname, 'TestSetup.js'); + let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp); + process.env[shared.TestEnvVars.command] = shared.Commands.get; + process.env[shared.TestEnvVars.arguments] = "pods"; + process.env[shared.TestEnvVars.secretType] = "generic"; + process.env[shared.TestEnvVars.secretArguments] = "--from-literal=key1=value1 --from-literal=key2=value2"; + process.env[shared.TestEnvVars.secretName] = "my-secret"; + tr.run(); + + assert(tr.invokedToolCount == 2, 'should have invoked tool one times. actual: ' + tr.invokedToolCount); + assert(tr.stderr.length == 0 || tr.errorIssues.length, 'should not have written to stderr'); + assert(tr.succeeded, 'task should have succeeded'); + assert(tr.stdout.indexOf(`DeleteSecret my-secret`) != -1, "kubectl delete should run"); + assert(tr.stdout.indexOf(`[command]kubectl --kubeconfig ${shared.formatPath("newUserDir/config")} create secret generic my-secret --from-literal=key1=value1 --from-literal=key2=value2`) != -1, "kubectl create should run"); + assert(tr.stdout.indexOf(`[command]kubectl --kubeconfig ${shared.formatPath("newUserDir/config")} get pods`) != -1, "kubectl get should run"); + console.log(tr.stderr); + done(); + }); + + it('Runs successfully for kubectl generic secrets without forceUpdate', (done:MochaDone) => { + let tp = path.join(__dirname, 'TestSetup.js'); + let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp); + process.env[shared.TestEnvVars.command] = shared.Commands.get; + process.env[shared.TestEnvVars.arguments] = "pods"; + process.env[shared.TestEnvVars.secretType] = "generic"; + process.env[shared.TestEnvVars.secretArguments] = "--from-literal=key1=value1 --from-literal=key2=value2"; + process.env[shared.TestEnvVars.secretName] = "my-secret"; + process.env[shared.TestEnvVars.forceUpdate] = "false"; + tr.run(); + + assert(tr.invokedToolCount == 2, 'should have invoked tool one times. actual: ' + tr.invokedToolCount); + assert(tr.stderr.length == 0 || tr.errorIssues.length, 'should not have written to stderr'); + assert(tr.succeeded, 'task should have succeeded'); + assert(tr.stdout.indexOf(`DeleteSecret my-secret`) == -1, "kubectl delete should not run"); + assert(tr.stdout.indexOf(`[command]kubectl --kubeconfig ${shared.formatPath("newUserDir/config")} create secret generic my-secret --from-literal=key1=value1 --from-literal=key2=value2`) != -1, "kubectl create should run"); + assert(tr.stdout.indexOf(`[command]kubectl --kubeconfig ${shared.formatPath("newUserDir/config")} get pods`) != -1, "kubectl get should run"); + console.log(tr.stderr); + done(); + }); + it('Runs successfully for kubectl get and print the output in a particular format', (done:MochaDone) => { let tp = path.join(__dirname, 'TestSetup.js'); let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp); diff --git a/Tasks/Kubernetes/Tests/TestSetup.ts b/Tasks/Kubernetes/Tests/TestSetup.ts index 524a0a5ee258..69c421e9cd62 100644 --- a/Tasks/Kubernetes/Tests/TestSetup.ts +++ b/Tasks/Kubernetes/Tests/TestSetup.ts @@ -18,6 +18,8 @@ tr.setInput('useConfigurationFile', process.env[shared.TestEnvVars.useConfigurat tr.setInput('configuration', ConfigurationFilePath); tr.setInput('arguments', process.env[shared.TestEnvVars.arguments] || ''); tr.setInput('namespace', process.env[shared.TestEnvVars.namespace] || ''); +tr.setInput('secretType', process.env[shared.TestEnvVars.secretType] || 'dockerRegistry'); +tr.setInput('secretArguments', process.env[shared.TestEnvVars.secretArguments] || ''); tr.setInput('secretName', process.env[shared.TestEnvVars.secretName] || ''); tr.setInput('forceUpdate', process.env[shared.TestEnvVars.forceUpdate] || "true"); tr.setInput('versionOrLocation', process.env[shared.TestEnvVars.versionOrLocation] || 'version'); @@ -98,6 +100,9 @@ a.exec[`kubectl --kubeconfig ${KubconfigFile} create secret docker-registry my-s a.exec[`kubectl --kubeconfig ${KubconfigFile} create secret docker-registry my-secret --docker-server=https://index.docker.io/v1/ --docker-username=test --docker-password=regpassword --docker-email=test@microsoft.com`] = { "code": 0 }; +a.exec[`kubectl --kubeconfig ${KubconfigFile} create secret generic my-secret --from-literal=key1=value1 --from-literal=key2=value2`] = { + "code": 0 +}; a.exec[`kubectl --kubeconfig ${KubconfigFile} get secrets my-secret -o yaml`] = { "code": 0, "stdout": "successfully got secret my-secret and printed it in the specified format" diff --git a/Tasks/Kubernetes/Tests/TestShared.ts b/Tasks/Kubernetes/Tests/TestShared.ts index f8d1a5885379..fcc10c7c35b3 100644 --- a/Tasks/Kubernetes/Tests/TestShared.ts +++ b/Tasks/Kubernetes/Tests/TestShared.ts @@ -8,6 +8,8 @@ export let TestEnvVars = { configuration: "__configuration__", arguments: "__arguments__", namespace: "__namespace__", + secretType: "__secretType__", + secretArguments: "__secretArguments__", secretName: "__secretName__", forceUpdate: "__forceUpdate__", versionOrLocation: "__versionOrLocation__", diff --git a/Tasks/Kubernetes/task.json b/Tasks/Kubernetes/task.json index 5bca337a70d3..376c5b25b559 100644 --- a/Tasks/Kubernetes/task.json +++ b/Tasks/Kubernetes/task.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 16 + "Patch": 15 }, "demands": [], "preview": "false", diff --git a/Tasks/Kubernetes/task.loc.json b/Tasks/Kubernetes/task.loc.json index 2a16d63d0f2c..0ce7790f6930 100644 --- a/Tasks/Kubernetes/task.loc.json +++ b/Tasks/Kubernetes/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 16 + "Patch": 15 }, "demands": [], "preview": "false", From 2578ff7ea912d61484abe80934469bd378221203 Mon Sep 17 00:00:00 2001 From: ansheno Date: Wed, 7 Mar 2018 15:50:53 +0530 Subject: [PATCH 3/3] Added proper help text for secrets arguments in kubernetes --- .../Strings/resources.resjson/en-US/resources.resjson | 2 +- Tasks/Kubernetes/task.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson b/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson index db054ab7319c..98ea879e471d 100644 --- a/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/Kubernetes/Strings/resources.resjson/en-US/resources.resjson @@ -22,7 +22,7 @@ "loc.input.label.secretType": "Type of secret", "loc.input.help.secretType": "Select a type of secret", "loc.input.label.secretArguments": "Arguments", - "loc.input.help.secretArguments": "Secret arguments.", + "loc.input.help.secretArguments": "Specify keys and literal values to insert in secret.For example, --from-literal=key1=value1 --from-literal=key2=\"top secret\". Please use double quotes to specify any literals that have spaces.", "loc.input.label.containerRegistryType": "Container Registry type", "loc.input.help.containerRegistryType": "Select a Container registry type.", "loc.input.label.dockerRegistryEndpoint": "Docker Registry Connection", diff --git a/Tasks/Kubernetes/task.json b/Tasks/Kubernetes/task.json index 376c5b25b559..4f0149ea8964 100644 --- a/Tasks/Kubernetes/task.json +++ b/Tasks/Kubernetes/task.json @@ -132,7 +132,7 @@ }, "label": "Arguments", "defaultValue":"", - "helpMarkDown": "Secret arguments.", + "helpMarkDown": "Specify keys and literal values to insert in secret.For example, --from-literal=key1=value1 --from-literal=key2=\"top secret\". Please use double quotes to specify any literals that have spaces.", "visibleRule": "secretType = generic", "groupName": "secrets" },