Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KubernetesManifest] Pick multiple manifests bug fix #10194

Merged
merged 2 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Tasks/KubernetesManifestV0/Tests/TestSetup.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tl = require('vsts-task-lib/task');
export const namespace: string = tl.getInput("namespace", false);
export const containers: string[] = tl.getDelimitedInput("containers", "\n");
export const imagePullSecrets: string[] = tl.getDelimitedInput("imagePullSecrets", "\n");
export const manifests = tl.getInput("manifests", false);
export const manifests = tl.getDelimitedInput("manifests", "\n");
export const canaryPercentage: string = tl.getInput("percentage");
export const deploymentStrategy: string = tl.getInput("strategy", false);
export const args: string = tl.getInput("arguments", false);
Expand Down
14 changes: 8 additions & 6 deletions Tasks/KubernetesManifestV0/src/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,29 @@ export const recognizedWorkloadTypes: string[] = ["deployment", "replicaset", "d
export const recognizedWorkloadTypesWithRolloutStatus: string[] = ["deployment", "daemonset", "statefulset"];

let isRelease = utils.isEqual(tl.getVariable("SYSTEM_HOSTTYPE"), "release", utils.StringComparer.OrdinalIgnoreCase);
const orgUrl = tl.getVariable("System.TeamFoundationCollectionUri");

export let pipelineAnnotations: string[] = [];

if (isRelease) {
pipelineAnnotations = [
`azure-pipelines/execution=${tl.getVariable("Release.ReleaseId")}`,
`azure-pipelines/run=${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")}/_releaseProgress?releaseId=${tl.getVariable("Release.ReleaseId")}`,
`azure-pipelines/runuri=${orgUrl}${tl.getVariable("System.TeamProject")}/_releaseProgress?releaseId=${tl.getVariable("Release.ReleaseId")}`,
`azure-pipelines/project=${tl.getVariable("System.TeamProject")}`,
`azure-pipelines/org=${tl.getVariable("System.CollectionId")}`
`azure-pipelines/org=${orgUrl}`
];
}
else {
pipelineAnnotations = [
`azure-pipelines/execution=${tl.getVariable("Build.BuildNumber")}`,
`azure-pipelines/run=${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")}/_build/results?buildId=${tl.getVariable("Build.BuildId")}`,
`azure-pipelines/runuri=${orgUrl}${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")}`
`azure-pipelines/org=${orgUrl}`
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const CANARY_SUFFIX = "-canary";
const CANARY_LABEL_VALUE = "canary";
const CANARY_VERSION_LABEL = "azure-pipelines/version";

export function deleteCanaryDeployment(kubectl: Kubectl, manifestFilesPath: string) {
export function deleteCanaryDeployment(kubectl: Kubectl, manifestFilesPath: string[]) {

// get manifest files
var inputManifestFiles: string[] = utils.getManifestFiles(manifestFilesPath);
Expand Down
4 changes: 2 additions & 2 deletions Tasks/KubernetesManifestV0/src/utils/DeploymentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IExecSyncResult } from 'vsts-task-lib/toolrunner';
import { Kubectl, Resource } from "kubernetes-common/kubectl-object-model";


export function deploy(kubectl: Kubectl, manifestFilesPath: string, deploymentStrategy: string) {
export function deploy(kubectl: Kubectl, manifestFilesPath: string[], deploymentStrategy: string) {

// get manifest files
var inputManifestFiles: string[] = getManifestFiles(manifestFilesPath);
Expand All @@ -37,7 +37,7 @@ export function deploy(kubectl: Kubectl, manifestFilesPath: string, deploymentSt
annotateResources(deployedManifestFiles, kubectl, resourceTypes);
}

function getManifestFiles(manifestFilesPath: string): string[] {
function getManifestFiles(manifestFilesPath: string[]): string[] {
var files: string[] = utils.getManifestFiles(manifestFilesPath);

if (files == null || files.length == 0) {
Expand Down
6 changes: 3 additions & 3 deletions Tasks/KubernetesManifestV0/src/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export enum StringComparer {
Ordinal, OrdinalIgnoreCase
}

export function getManifestFiles(manifestFilesPath: string): string[] {
if (!manifestFilesPath || manifestFilesPath.trim().length == 0) {
export function getManifestFiles(manifestFilesPath: string | string[]): string[] {
if (!manifestFilesPath) {
tl.debug("file input is not present");
return null;
}

var files = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory") || process.cwd(), manifestFilesPath.trim());
var files = tl.findMatch(tl.getVariable("System.DefaultWorkingDirectory") || process.cwd(), manifestFilesPath);
return files;
}

Expand Down
9 changes: 7 additions & 2 deletions Tasks/KubernetesManifestV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 151,
"Patch": 6
"Patch": 7
},
"demands": [],
"groups": [],
Expand Down Expand Up @@ -171,10 +171,15 @@
},
{
"name": "kind",
"type": "string",
"type": "pickList",
"label": "Kind",
"required": true,
"defaultValue": "",
"options": {
"deployment": "deployment",
"replicaset": "replicaset",
"statefulset": "statefulset"
},
"helpMarkDown": "Kind of K8s object; deployment, replicaSet etc.",
"visibleRule": "action = scale || resourceToPatch = name"
},
Expand Down
9 changes: 7 additions & 2 deletions Tasks/KubernetesManifestV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 151,
"Patch": 6
"Patch": 7
},
"demands": [],
"groups": [],
Expand Down Expand Up @@ -171,10 +171,15 @@
},
{
"name": "kind",
"type": "string",
"type": "pickList",
"label": "ms-resource:loc.input.label.kind",
"required": true,
"defaultValue": "",
"options": {
"deployment": "deployment",
"replicaset": "replicaset",
"statefulset": "statefulset"
},
"helpMarkDown": "ms-resource:loc.input.help.kind",
"visibleRule": "action = scale || resourceToPatch = name"
},
Expand Down