Skip to content

Commit

Permalink
2073393 ID 1.1.1 (AzDO) - Update PackerBuild@1 task to support Worklo… (
Browse files Browse the repository at this point in the history
#19835)

* 2073393 ID 1.1.1 (AzDO) - Update PackerBuild@1 task to support Workload Identity federation

* Test case Failure

* Test case Failure fixed
  • Loading branch information
PhilipsonJoseph authored May 3, 2024
1 parent 5278dc6 commit 8947d18
Show file tree
Hide file tree
Showing 54 changed files with 1,404 additions and 1,426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"client_jwt": "{{env `client_jwt`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
Expand All @@ -20,6 +21,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"resource_group_name": "{{user `resource_group`}}",
"storage_account": "{{user `storage_account`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"client_jwt": "{{env `client_jwt`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
Expand All @@ -21,6 +22,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"client_jwt": "{{env `client_jwt`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
Expand All @@ -20,6 +21,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "{{env `client_id`}}",
"client_secret": "{{env `client_secret`}}",
"client_jwt": "{{env `client_jwt`}}",
"subscription_id": "{{env `subscription_id`}}",
"tenant_id": "{{env `tenant_id`}}",
"object_id": "{{env `object_id`}}",
Expand All @@ -19,6 +20,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"resource_group_name": "{{user `resource_group`}}",
"storage_account": "{{user `storage_account`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "",
"client_secret": "",
"client_jwt": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
Expand All @@ -22,6 +23,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"resource_group_name": "{{user `resource_group`}}",
"storage_account": "{{user `storage_account`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "",
"client_secret": "",
"client_jwt": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
Expand All @@ -23,6 +24,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "",
"client_secret": "",
"client_jwt": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
Expand All @@ -22,6 +23,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"managed_image_resource_group_name": "{{user `resource_group`}}",
"managed_image_name": "{{user `managed_image_name`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
"client_id": "",
"client_secret": "",
"client_jwt": "",
"subscription_id": "",
"tenant_id": "",
"object_id": "",
Expand All @@ -21,6 +22,7 @@
"type": "azure-arm",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"client_jwt": "{{user `client_jwt`}}",
"resource_group_name": "{{user `resource_group`}}",
"storage_account": "{{user `storage_account`}}",
"subscription_id": "{{user `subscription_id`}}",
Expand Down
8 changes: 4 additions & 4 deletions Tasks/PackerBuildV1/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe('PackerBuild Suite V1', function() {
process.env["__ostype__"] = "windows";

assert(tr.failed, 'task should have failed');
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_OSTypeNotSupported") != -1, "error message should be right");
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_OSTypeNotSupported") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]loc_mock_OSTypeNotSupported") != -1, "error message should be right");
done();
});

Expand Down Expand Up @@ -365,7 +365,7 @@ describe('PackerBuild Suite V1', function() {
assert(tr.failed, 'task should fail if output is not parsed properly');
assert(tr.invokedToolCount == 4, 'all 4 commands should have been invoked. actual: ' + tr.invokedToolCount);
assert(tr.stdout.indexOf("##vso[task.setvariable variable=imageUri;isOutput=false;issecret=false;]") == -1, "should not try to set output variable");
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_ImageURIOutputVariableNotFound") != -1, "should show proper console message");
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_ImageURIOutputVariableNotFound") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]loc_mock_ImageURIOutputVariableNotFound") != -1, "should show proper console message");
done();
});

Expand Down Expand Up @@ -496,7 +496,7 @@ describe('PackerBuild Suite V1', function() {

assert(tr.invokedToolCount == 1, 'should have invoked tool only once. actual: ' + tr.invokedToolCount);
assert(tr.failed, 'task should fail if download fails');
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer download failed!!") != -1, "error message should be right");
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer download failed!!") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]packer download failed!!") != -1, "error message should be right");
done();
});

Expand All @@ -510,7 +510,7 @@ describe('PackerBuild Suite V1', function() {

assert(tr.invokedToolCount == 0, 'should have invoked tool not even once. actual: ' + tr.invokedToolCount);
assert(tr.failed, 'task should fail if extraction fails');
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer zip extraction failed!!") != -1, "error message should be right");
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer zip extraction failed!!") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]packer zip extraction failed!!") != -1, "error message should be right");
done();
});

Expand Down
6 changes: 3 additions & 3 deletions Tasks/PackerBuildV1/Tests/L0Utilities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import path = require('path');
var mockery = require('mockery');
import * as libMocker from 'azure-pipelines-task-lib/lib-mocker';

// provide answers for task mock
let a: any = <any>{
Expand All @@ -18,10 +18,10 @@ let a: any = <any>{
}
};

mockery.enable({warnOnUnregistered: false});
libMocker.enable({warnOnUnregistered: false});
var tlm = require('azure-pipelines-task-lib/mock-task');
tlm.setAnswers(a);
mockery.registerMock('azure-pipelines-task-lib/task', tlm);
libMocker.registerMock('azure-pipelines-task-lib/task', tlm);
var ut = require('../src/utilities.js');

ut.copyFile(".\\DefaultTemplates\\default.windows.template.json", "F:\\somedir\\tempdir\\100");
Expand Down
Loading

0 comments on commit 8947d18

Please sign in to comment.