From 7e5936376511b2d841829801a659a2cb040ff8d7 Mon Sep 17 00:00:00 2001 From: Deepak Sattiraju Date: Fri, 12 Apr 2019 18:02:24 +0530 Subject: [PATCH] [KubernetesManifestV0] Bug fixes (#10102) (#10104) * [KubernetesManifest] Bug fixes * build --- .../resources.resjson/en-US/resources.resjson | 6 +- Tasks/KubernetesManifestV0/Tests/TestSetup.ts | 2 +- .../src/models/constants.ts | 20 ++--- Tasks/KubernetesManifestV0/task.json | 74 +++++-------------- Tasks/KubernetesManifestV0/task.loc.json | 74 +++++-------------- 5 files changed, 53 insertions(+), 123 deletions(-) diff --git a/Tasks/KubernetesManifestV0/Strings/resources.resjson/en-US/resources.resjson b/Tasks/KubernetesManifestV0/Strings/resources.resjson/en-US/resources.resjson index 1b7664d49b29..691fdfd58421 100644 --- a/Tasks/KubernetesManifestV0/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/KubernetesManifestV0/Strings/resources.resjson/en-US/resources.resjson @@ -3,14 +3,12 @@ "loc.helpMarkDown": "[More Information](https://go.microsoft.com/fwlink/?linkid=851275)", "loc.description": "Manifest based deployments to Kubernetes", "loc.instanceNameFormat": "$(action)", - "loc.group.displayName.config": "Config", - "loc.group.displayName.kubernetesCluster": "Kubernetes Cluster", + "loc.input.label.action": "Action", + "loc.input.help.action": "Choose the action to be performed.", "loc.input.label.kubernetesServiceConnection": "Kubernetes service connection", "loc.input.help.kubernetesServiceConnection": "Select a Kubernetes service connection.", "loc.input.label.namespace": "Namespace", "loc.input.help.namespace": "Sets the namespace for the commands by using the –namespace flag. If the namespace is not provided, the commands will run in the default namespace.", - "loc.input.label.action": "Action", - "loc.input.help.action": "Choose the action to be performed.", "loc.input.label.strategy": "Strategy", "loc.input.help.strategy": "Deployment strategy to be used", "loc.input.label.percentage": "Percentage", diff --git a/Tasks/KubernetesManifestV0/Tests/TestSetup.ts b/Tasks/KubernetesManifestV0/Tests/TestSetup.ts index aa90ea579ab0..b0fad20926fa 100644 --- a/Tasks/KubernetesManifestV0/Tests/TestSetup.ts +++ b/Tasks/KubernetesManifestV0/Tests/TestSetup.ts @@ -50,7 +50,7 @@ process.env["BUILD_BUILDNUMBER"] = BuildNumber; process.env["BUILD_DEFINITIONNAME"] = DefinitionName; process.env["AGENT_JOBNAME"] = JobName; -process.env["TF_BUILD"] = "True"; +process.env["SYSTEM_HOSTTYPE"] = "build"; process.env[shared.TestEnvVars.manifests] = process.env[shared.TestEnvVars.manifests] || shared.ManifestFilesPath; process.env["ENDPOINT_DATA_kubernetesConnection_AUTHORIZATIONTYPE"] = process.env[shared.TestEnvVars.endpointAuthorizationType] || shared.AuthorizationType.Kubeconfig; diff --git a/Tasks/KubernetesManifestV0/src/models/constants.ts b/Tasks/KubernetesManifestV0/src/models/constants.ts index ffad1d9be793..f008c6e716ab 100644 --- a/Tasks/KubernetesManifestV0/src/models/constants.ts +++ b/Tasks/KubernetesManifestV0/src/models/constants.ts @@ -14,27 +14,27 @@ export class KubernetesWorkload { export const recognizedWorkloadTypes: string[] = ["deployment", "replicaset", "daemonset", "pod", "statefulset"]; export const recognizedWorkloadTypesWithRolloutStatus: string[] = ["deployment", "daemonset", "statefulset"]; -let isBuild = tl.getVariable("TF_BUILD"); +let isRelease = utils.isEqual(tl.getVariable("SYSTEM_HOSTTYPE"), "release", utils.StringComparer.OrdinalIgnoreCase); export let pipelineAnnotations: string[] = []; -if (isBuild && utils.isEqual(isBuild, "true", utils.StringComparer.OrdinalIgnoreCase)) { +if (isRelease) { pipelineAnnotations = [ - `azure-pipelines/execution=${tl.getVariable("Build.BuildNumber")}`, - `azure-pipelines/pipeline="${tl.getVariable("Build.DefinitionName")}"`, - `azure-pipelines/pipelineId="${tl.getVariable("System.DefinitionId")}"`, + `azure-pipelines/execution=${tl.getVariable("Release.ReleaseId")}`, + `azure-pipelines/pipeline="${tl.getVariable("Release.DefinitionName")}"`, + `azure-pipelines/pipelineId="${tl.getVariable("Release.DefinitionId")}"`, `azure-pipelines/jobName="${tl.getVariable("Agent.JobName")}"`, - `azure-pipelines/executionuri=${tl.getVariable("System.TeamFoundationCollectionUri")}${tl.getVariable("System.TeamProject")}/_build/results?buildId=${tl.getVariable("Build.BuildId")}`, + `azure-pipelines/executionuri=${tl.getVariable("System.TeamFoundationCollectionUri")}${tl.getVariable("System.TeamProject")}/_releaseProgress?releaseId=${tl.getVariable("Release.ReleaseId")}`, `azure-pipelines/project=${tl.getVariable("System.TeamProject")}`, `azure-pipelines/org=${tl.getVariable("System.CollectionId")}` ]; } else { pipelineAnnotations = [ - `azure-pipelines/execution=${tl.getVariable("Release.ReleaseId")}`, - `azure-pipelines/pipeline="${tl.getVariable("Release.DefinitionName")}"`, - `azure-pipelines/pipelineId="${tl.getVariable("Release.DefinitionId")}"`, + `azure-pipelines/execution=${tl.getVariable("Build.BuildNumber")}`, + `azure-pipelines/pipeline="${tl.getVariable("Build.DefinitionName")}"`, + `azure-pipelines/pipelineId="${tl.getVariable("System.DefinitionId")}"`, `azure-pipelines/jobName="${tl.getVariable("Agent.JobName")}"`, - `azure-pipelines/executionuri=${tl.getVariable("System.TeamFoundationCollectionUri")}${tl.getVariable("System.TeamProject")}/_releaseProgress?releaseId=${tl.getVariable("Release.ReleaseId")}`, + `azure-pipelines/executionuri=${tl.getVariable("System.TeamFoundationCollectionUri")}${tl.getVariable("System.TeamProject")}/_build/results?buildId=${tl.getVariable("Build.BuildId")}`, `azure-pipelines/project=${tl.getVariable("System.TeamProject")}`, `azure-pipelines/org=${tl.getVariable("System.CollectionId")}` ]; diff --git a/Tasks/KubernetesManifestV0/task.json b/Tasks/KubernetesManifestV0/task.json index 603495a9cf52..15d98a2239d3 100644 --- a/Tasks/KubernetesManifestV0/task.json +++ b/Tasks/KubernetesManifestV0/task.json @@ -15,47 +15,17 @@ "version": { "Major": 0, "Minor": 150, - "Patch": 2 + "Patch": 3 }, "demands": [], - "groups": [ - { - "name": "config", - "displayName": "Config", - "isExpanded": true - }, - { - "name": "kubernetesCluster", - "displayName": "Kubernetes Cluster", - "isExpanded": true, - "visibleRule": "action != bake" - } - ], + "groups": [], "inputs": [ - { - "name": "kubernetesServiceConnection", - "type": "connectedService:kubernetes", - "label": "Kubernetes service connection", - "helpMarkDown": "Select a Kubernetes service connection.", - "groupName": "kubernetesCluster", - "required": true - }, - { - "name": "namespace", - "type": "string", - "label": "Namespace", - "required": true, - "defaultValue": "default", - "groupName": "kubernetesCluster", - "helpMarkDown": "Sets the namespace for the commands by using the –namespace flag. If the namespace is not provided, the commands will run in the default namespace." - }, { "name": "action", "type": "pickList", "label": "Action", "required": false, "defaultValue": "deploy", - "groupName": "config", "options": { "bake": "bake", "createSecret": "create secret", @@ -68,12 +38,28 @@ }, "helpMarkDown": "Choose the action to be performed." }, + { + "name": "kubernetesServiceConnection", + "type": "connectedService:kubernetes", + "label": "Kubernetes service connection", + "helpMarkDown": "Select a Kubernetes service connection.", + "visibleRule": "action != bake", + "required": true + }, + { + "name": "namespace", + "type": "string", + "label": "Namespace", + "required": true, + "defaultValue": "default", + "visibleRule": "action != bake", + "helpMarkDown": "Sets the namespace for the commands by using the –namespace flag. If the namespace is not provided, the commands will run in the default namespace." + }, { "name": "strategy", "type": "pickList", "label": "Strategy", "required": false, - "groupName": "config", "defaultValue": "none", "options": { "canary": "Canary", @@ -87,7 +73,6 @@ "type": "string", "label": "Percentage", "required": true, - "groupName": "config", "helpMarkDown": "", "defaultValue": 0, "visibleRule": "strategy = Canary && action = deploy", @@ -102,7 +87,6 @@ "label": "Manifests", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Manifests to deploy", "visibleRule": "action = deploy || action = promote || action = reject" }, @@ -112,7 +96,6 @@ "label": "Containers", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Containers", "visibleRule": "action = deploy || action = promote" }, @@ -122,7 +105,6 @@ "label": "ImagePullSecrets", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ImagePullSecret to pull image from private registry", "visibleRule": "action = deploy || action = promote" }, @@ -132,7 +114,6 @@ "label": "Render Engine", "required": false, "defaultValue": "helm2", - "groupName": "config", "visibleRule": "action = bake", "options": { "helm2": "Helm 2" @@ -145,7 +126,6 @@ "label": "Helm Chart", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Helm chart path to bake", "visibleRule": "action = bake && renderType = helm2" }, @@ -155,7 +135,6 @@ "label": "Override Files", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Override files to set", "visibleRule": "action = bake && renderType = helm2" }, @@ -165,7 +144,6 @@ "label": "Overrides", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Override values to set", "visibleRule": "action = bake && renderType = helm2" }, @@ -179,7 +157,6 @@ "file": "file", "name": "name" }, - "groupName": "config", "helpMarkDown": "to identify the resource", "visibleRule": "action = patch" }, @@ -189,7 +166,6 @@ "label": "File path", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Path to the file used for patch", "visibleRule": "action = patch && resourceToPatch = file" }, @@ -199,7 +175,6 @@ "label": "Kind", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Kind of K8s object; deployment, replicaSet etc.", "visibleRule": "action = scale || resourceToPatch = name" }, @@ -209,7 +184,6 @@ "label": "Name", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Name of the k8s object", "visibleRule": "action = scale || resourceToPatch = name" }, @@ -219,7 +193,6 @@ "label": "Replica count", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "Number of replicas to scale to", "visibleRule": "action = scale" }, @@ -234,7 +207,6 @@ "merge": "merge", "strategic": "strategic" }, - "groupName": "config", "helpMarkDown": "The type of patch being provided; one of [json merge strategic]", "visibleRule": "action = patch" }, @@ -243,16 +215,14 @@ "type": "string", "label": "Arguments", "defaultValue": "", - "groupName": "config", "helpMarkDown": "Arguments for `kubectl delete` command", - "visibleRule": "action = delete || action = reject" + "visibleRule": "action = delete" }, { "name": "patch", "type": "string", "label": "Patch", "required": true, - "groupName": "config", "helpMarkDown": "Contents of patch", "visibleRule": "action = patch" }, @@ -263,7 +233,6 @@ "defaultValue": "dockerRegistry", "required": true, "visibleRule": "action = createSecret", - "groupName": "config", "options": { "dockerRegistry": "dockerRegistry", "generic": "generic" @@ -275,7 +244,6 @@ "type": "string", "label": "Secret name", "required": false, - "groupName": "config", "visibleRule": "action = createSecret", "defaultValue": "", "helpMarkDown": "Name of the secret. You can use this secret name in the Kubernetes YAML configuration file." @@ -283,7 +251,6 @@ { "name": "secretArguments", "type": "multiLine", - "groupName": "config", "properties": { "resizable": "true", "rows": "2", @@ -297,7 +264,6 @@ { "name": "dockerRegistryEndpoint", "type": "connectedService:dockerregistry", - "groupName": "config", "label": "Docker registry service connection", "helpMarkDown": "Select a Docker registry service connection. Required for commands that need to authenticate with a registry.", "visibleRule": "action = createSecret && secretType = dockerRegistry" diff --git a/Tasks/KubernetesManifestV0/task.loc.json b/Tasks/KubernetesManifestV0/task.loc.json index 30c0f4ab131a..ad95f061fbf7 100644 --- a/Tasks/KubernetesManifestV0/task.loc.json +++ b/Tasks/KubernetesManifestV0/task.loc.json @@ -15,47 +15,17 @@ "version": { "Major": 0, "Minor": 150, - "Patch": 2 + "Patch": 3 }, "demands": [], - "groups": [ - { - "name": "config", - "displayName": "ms-resource:loc.group.displayName.config", - "isExpanded": true - }, - { - "name": "kubernetesCluster", - "displayName": "ms-resource:loc.group.displayName.kubernetesCluster", - "isExpanded": true, - "visibleRule": "action != bake" - } - ], + "groups": [], "inputs": [ - { - "name": "kubernetesServiceConnection", - "type": "connectedService:kubernetes", - "label": "ms-resource:loc.input.label.kubernetesServiceConnection", - "helpMarkDown": "ms-resource:loc.input.help.kubernetesServiceConnection", - "groupName": "kubernetesCluster", - "required": true - }, - { - "name": "namespace", - "type": "string", - "label": "ms-resource:loc.input.label.namespace", - "required": true, - "defaultValue": "default", - "groupName": "kubernetesCluster", - "helpMarkDown": "ms-resource:loc.input.help.namespace" - }, { "name": "action", "type": "pickList", "label": "ms-resource:loc.input.label.action", "required": false, "defaultValue": "deploy", - "groupName": "config", "options": { "bake": "bake", "createSecret": "create secret", @@ -68,12 +38,28 @@ }, "helpMarkDown": "ms-resource:loc.input.help.action" }, + { + "name": "kubernetesServiceConnection", + "type": "connectedService:kubernetes", + "label": "ms-resource:loc.input.label.kubernetesServiceConnection", + "helpMarkDown": "ms-resource:loc.input.help.kubernetesServiceConnection", + "visibleRule": "action != bake", + "required": true + }, + { + "name": "namespace", + "type": "string", + "label": "ms-resource:loc.input.label.namespace", + "required": true, + "defaultValue": "default", + "visibleRule": "action != bake", + "helpMarkDown": "ms-resource:loc.input.help.namespace" + }, { "name": "strategy", "type": "pickList", "label": "ms-resource:loc.input.label.strategy", "required": false, - "groupName": "config", "defaultValue": "none", "options": { "canary": "Canary", @@ -87,7 +73,6 @@ "type": "string", "label": "ms-resource:loc.input.label.percentage", "required": true, - "groupName": "config", "helpMarkDown": "", "defaultValue": 0, "visibleRule": "strategy = Canary && action = deploy", @@ -102,7 +87,6 @@ "label": "ms-resource:loc.input.label.manifests", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.manifests", "visibleRule": "action = deploy || action = promote || action = reject" }, @@ -112,7 +96,6 @@ "label": "ms-resource:loc.input.label.containers", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.containers", "visibleRule": "action = deploy || action = promote" }, @@ -122,7 +105,6 @@ "label": "ms-resource:loc.input.label.imagePullSecrets", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.imagePullSecrets", "visibleRule": "action = deploy || action = promote" }, @@ -132,7 +114,6 @@ "label": "ms-resource:loc.input.label.renderType", "required": false, "defaultValue": "helm2", - "groupName": "config", "visibleRule": "action = bake", "options": { "helm2": "Helm 2" @@ -145,7 +126,6 @@ "label": "ms-resource:loc.input.label.helmChart", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.helmChart", "visibleRule": "action = bake && renderType = helm2" }, @@ -155,7 +135,6 @@ "label": "ms-resource:loc.input.label.overrideFiles", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.overrideFiles", "visibleRule": "action = bake && renderType = helm2" }, @@ -165,7 +144,6 @@ "label": "ms-resource:loc.input.label.overrides", "required": false, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.overrides", "visibleRule": "action = bake && renderType = helm2" }, @@ -179,7 +157,6 @@ "file": "file", "name": "name" }, - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.resourceToPatch", "visibleRule": "action = patch" }, @@ -189,7 +166,6 @@ "label": "ms-resource:loc.input.label.resourceFileToPatch", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.resourceFileToPatch", "visibleRule": "action = patch && resourceToPatch = file" }, @@ -199,7 +175,6 @@ "label": "ms-resource:loc.input.label.kind", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.kind", "visibleRule": "action = scale || resourceToPatch = name" }, @@ -209,7 +184,6 @@ "label": "ms-resource:loc.input.label.name", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.name", "visibleRule": "action = scale || resourceToPatch = name" }, @@ -219,7 +193,6 @@ "label": "ms-resource:loc.input.label.replicas", "required": true, "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.replicas", "visibleRule": "action = scale" }, @@ -234,7 +207,6 @@ "merge": "merge", "strategic": "strategic" }, - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.mergeStrategy", "visibleRule": "action = patch" }, @@ -243,16 +215,14 @@ "type": "string", "label": "ms-resource:loc.input.label.arguments", "defaultValue": "", - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.arguments", - "visibleRule": "action = delete || action = reject" + "visibleRule": "action = delete" }, { "name": "patch", "type": "string", "label": "ms-resource:loc.input.label.patch", "required": true, - "groupName": "config", "helpMarkDown": "ms-resource:loc.input.help.patch", "visibleRule": "action = patch" }, @@ -263,7 +233,6 @@ "defaultValue": "dockerRegistry", "required": true, "visibleRule": "action = createSecret", - "groupName": "config", "options": { "dockerRegistry": "dockerRegistry", "generic": "generic" @@ -275,7 +244,6 @@ "type": "string", "label": "ms-resource:loc.input.label.secretName", "required": false, - "groupName": "config", "visibleRule": "action = createSecret", "defaultValue": "", "helpMarkDown": "ms-resource:loc.input.help.secretName" @@ -283,7 +251,6 @@ { "name": "secretArguments", "type": "multiLine", - "groupName": "config", "properties": { "resizable": "true", "rows": "2", @@ -297,7 +264,6 @@ { "name": "dockerRegistryEndpoint", "type": "connectedService:dockerregistry", - "groupName": "config", "label": "ms-resource:loc.input.label.dockerRegistryEndpoint", "helpMarkDown": "ms-resource:loc.input.help.dockerRegistryEndpoint", "visibleRule": "action = createSecret && secretType = dockerRegistry"