Skip to content

Commit f796b86

Browse files
committed
test update to node 24
1 parent bbcc074 commit f796b86

19 files changed

+10401
-191
lines changed

.github/workflows/azure-login-negative.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
- name: 'Checking out repo code'
2222
uses: actions/checkout@v4
2323

24-
- name: Set Node.js 20.x for GitHub Action
24+
- name: Set Node.js 24.x for GitHub Action
2525
uses: actions/setup-node@v4
2626
with:
27-
node-version: 20.x
27+
node-version: 24.x
2828

2929
- name: 'Validate build'
3030
run: |
@@ -84,10 +84,10 @@ jobs:
8484
- name: 'Checking out repo code'
8585
uses: actions/checkout@v4
8686

87-
- name: Set Node.js 20.x for GitHub Action
87+
- name: Set Node.js 24.x for GitHub Action
8888
uses: actions/setup-node@v4
8989
with:
90-
node-version: 20.x
90+
node-version: 24.x
9191

9292
- name: 'Validate build'
9393
run: |

.github/workflows/azure-login-positive.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ jobs:
2020
- name: 'Checking out repo code'
2121
uses: actions/checkout@v4
2222

23-
- name: Set Node.js 20.x for GitHub Action
23+
- name: Set Node.js 24.x for GitHub Action
2424
uses: actions/setup-node@v4
2525
with:
26-
node-version: 20.x
27-
28-
- name: 'Validate build'
29-
run: |
26+
node-version: 24.x
3027
npm install
3128
npm run build
3229

@@ -112,10 +109,10 @@ jobs:
112109
- name: 'Checking out repo code'
113110
uses: actions/checkout@v4
114111

115-
- name: Set Node.js 20.x for GitHub Action
112+
- name: Set Node.js 24.x for GitHub Action
116113
uses: actions/setup-node@v4
117114
with:
118-
node-version: 20.x
115+
node-version: 24.x
119116

120117
- name: 'Validate build'
121118
run: |
@@ -247,10 +244,10 @@ jobs:
247244
- name: 'Checking out repo code'
248245
uses: actions/checkout@v4
249246

250-
- name: Set Node.js 20.x for GitHub Action
247+
- name: Set Node.js 24.x for GitHub Action
251248
uses: actions/setup-node@v4
252249
with:
253-
node-version: 20.x
250+
node-version: 24.x
254251

255252
- name: Install Azure CLI
256253
run: |

.github/workflows/azure-login-pr-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
repository: ${{ github.event.pull_request.head.repo.full_name }}
1616
ref: ${{ github.event.pull_request.head.ref }}
1717

18-
# Using 20.x version as an example
19-
- name: Set Node.js 20.x for GitHub Action
18+
# Using 24.x version as an example
19+
- name: Set Node.js 24.x for GitHub Action
2020
uses: actions/setup-node@v4
2121
with:
22-
node-version: 20.x
22+
node-version: 24.x
2323

2424
- name: installing node_modules
2525
run: npm install

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
- name: 'Checking out repo code'
2121
uses: actions/checkout@v4
2222

23-
- name: Set Node.js 20.x for GitHub Action
23+
- name: Set Node.js 24.x for GitHub Action
2424
uses: actions/setup-node@v4
2525
with:
26-
node-version: 20.x
26+
node-version: 24.x
2727

2828
- name: 'Validate build'
2929
run: |

.github/workflows/markdownlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Use Node.js
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 20.x
14+
node-version: 24.x
1515
- name: Run Markdownlint
1616
run: |
1717
npm i -g markdownlint-cli2

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ branding:
3838
icon: 'login.svg'
3939
color: 'blue'
4040
runs:
41-
using: 'node20'
41+
using: 'node24'
4242
main: 'lib/main/index.js'
4343
post-if: (!env.AZURE_LOGIN_POST_CLEANUP || env.AZURE_LOGIN_POST_CLEANUP != 'false')
4444
post: 'lib/cleanup/index.js'

lib/Cli/AzureCliLogin.js

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27+
return new (P || (P = Promise))(function (resolve, reject) {
28+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31+
step((generator = generator.apply(thisArg, _arguments || [])).next());
32+
});
33+
};
34+
Object.defineProperty(exports, "__esModule", { value: true });
35+
exports.AzureCliLogin = void 0;
36+
const exec = __importStar(require("@actions/exec"));
37+
const core = __importStar(require("@actions/core"));
38+
const io = __importStar(require("@actions/io"));
39+
class AzureCliLogin {
40+
constructor(loginConfig) {
41+
this.loginConfig = loginConfig;
42+
}
43+
login() {
44+
return __awaiter(this, void 0, void 0, function* () {
45+
this.azPath = yield io.which("az", true);
46+
core.debug(`az cli path: ${this.azPath}`);
47+
let output = "";
48+
const execOptions = {
49+
listeners: {
50+
stdout: (data) => {
51+
output += data.toString();
52+
}
53+
}
54+
};
55+
yield this.executeAzCliCommand("--version", true, execOptions);
56+
core.debug(`az cli version used:\n${output}`);
57+
this.setAzurestackEnvIfNecessary();
58+
yield this.executeAzCliCommand(`cloud set -n "${this.loginConfig.environment}"`, false);
59+
console.log(`Done setting cloud: "${this.loginConfig.environment}"`);
60+
// Attempting Az cli login
61+
var commonArgs = ["--service-principal",
62+
"-u", this.loginConfig.servicePrincipalId,
63+
"--tenant", this.loginConfig.tenantId
64+
];
65+
if (this.loginConfig.allowNoSubscriptionsLogin) {
66+
commonArgs = commonArgs.concat("--allow-no-subscriptions");
67+
}
68+
if (this.loginConfig.enableOIDC) {
69+
commonArgs = commonArgs.concat("--federated-token", this.loginConfig.federatedToken);
70+
}
71+
else {
72+
console.log("Note: Azure/login action also supports OIDC login mechanism. Refer https://github.com/azure/login#configure-a-service-principal-with-a-federated-credential-to-use-oidc-based-authentication for more details.");
73+
commonArgs = commonArgs.concat(`--password=${this.loginConfig.servicePrincipalKey}`);
74+
}
75+
const loginOptions = defaultExecOptions();
76+
yield this.executeAzCliCommand(`login`, true, loginOptions, commonArgs);
77+
if (!this.loginConfig.allowNoSubscriptionsLogin) {
78+
var args = [
79+
"--subscription",
80+
this.loginConfig.subscriptionId
81+
];
82+
yield this.executeAzCliCommand(`account set`, true, loginOptions, args);
83+
}
84+
});
85+
}
86+
setAzurestackEnvIfNecessary() {
87+
return __awaiter(this, void 0, void 0, function* () {
88+
if (this.loginConfig.environment != "azurestack") {
89+
return;
90+
}
91+
if (!this.loginConfig.resourceManagerEndpointUrl) {
92+
throw new Error("resourceManagerEndpointUrl is a required parameter when environment is defined.");
93+
}
94+
console.log(`Unregistering cloud: "${this.loginConfig.environment}" first if it exists`);
95+
try {
96+
yield this.executeAzCliCommand(`cloud set -n AzureCloud`, true);
97+
yield this.executeAzCliCommand(`cloud unregister -n "${this.loginConfig.environment}"`, false);
98+
}
99+
catch (error) {
100+
console.log(`Ignore cloud not registered error: "${error}"`);
101+
}
102+
console.log(`Registering cloud: "${this.loginConfig.environment}" with ARM endpoint: "${this.loginConfig.resourceManagerEndpointUrl}"`);
103+
try {
104+
let baseUri = this.loginConfig.resourceManagerEndpointUrl;
105+
if (baseUri.endsWith('/')) {
106+
baseUri = baseUri.substring(0, baseUri.length - 1); // need to remove trailing / from resourceManagerEndpointUrl to correctly derive suffixes below
107+
}
108+
let suffixKeyvault = ".vault" + baseUri.substring(baseUri.indexOf('.')); // keyvault suffix starts with .
109+
let suffixStorage = baseUri.substring(baseUri.indexOf('.') + 1); // storage suffix starts without .
110+
let profileVersion = "2019-03-01-hybrid";
111+
yield this.executeAzCliCommand(`cloud register -n "${this.loginConfig.environment}" --endpoint-resource-manager "${this.loginConfig.resourceManagerEndpointUrl}" --suffix-keyvault-dns "${suffixKeyvault}" --suffix-storage-endpoint "${suffixStorage}" --profile "${profileVersion}"`, false);
112+
}
113+
catch (error) {
114+
core.error(`Error while trying to register cloud "${this.loginConfig.environment}": "${error}"`);
115+
}
116+
console.log(`Done registering cloud: "${this.loginConfig.environment}"`);
117+
});
118+
}
119+
executeAzCliCommand(command, silent, execOptions = {}, args = []) {
120+
return __awaiter(this, void 0, void 0, function* () {
121+
execOptions.silent = !!silent;
122+
yield exec.exec(`"${this.azPath}" ${command}`, args, execOptions);
123+
});
124+
}
125+
}
126+
exports.AzureCliLogin = AzureCliLogin;
127+
function defaultExecOptions() {
128+
return {
129+
silent: true,
130+
listeners: {
131+
stderr: (data) => {
132+
let error = data.toString();
133+
let startsWithWarning = error.toLowerCase().startsWith('warning');
134+
let startsWithError = error.toLowerCase().startsWith('error');
135+
// printing ERROR
136+
if (error && error.trim().length !== 0 && !startsWithWarning) {
137+
if (startsWithError) {
138+
//removing the keyword 'ERROR' to avoid duplicates while throwing error
139+
error = error.slice(5);
140+
}
141+
core.setFailed(error);
142+
}
143+
}
144+
}
145+
};
146+
}

lib/PowerShell/Constants.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
class Constants {
4+
}
5+
exports.default = Constants;
6+
Constants.prefix = "az_";
7+
Constants.moduleName = "Az.Accounts";
8+
Constants.versionPattern = /[0-9]+\.[0-9]+\.[0-9]+/;
9+
Constants.AzureCloud = "AzureCloud";
10+
Constants.Subscription = "Subscription";
11+
Constants.ServicePrincipal = "ServicePrincipal";
12+
Constants.Success = "Success";
13+
Constants.Error = "Error";
14+
Constants.AzVersion = "AzVersion";

lib/PowerShell/IAzurePowerShellSession.js

Whitespace-only changes.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27+
return new (P || (P = Promise))(function (resolve, reject) {
28+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31+
step((generator = generator.apply(thisArg, _arguments || [])).next());
32+
});
33+
};
34+
var __importDefault = (this && this.__importDefault) || function (mod) {
35+
return (mod && mod.__esModule) ? mod : { "default": mod };
36+
};
37+
Object.defineProperty(exports, "__esModule", { value: true });
38+
exports.ServicePrincipalLogin = void 0;
39+
const core = __importStar(require("@actions/core"));
40+
const Utils_1 = __importDefault(require("./Utilities/Utils"));
41+
const PowerShellToolRunner_1 = __importDefault(require("./Utilities/PowerShellToolRunner"));
42+
const ScriptBuilder_1 = __importDefault(require("./Utilities/ScriptBuilder"));
43+
const Constants_1 = __importDefault(require("./Constants"));
44+
class ServicePrincipalLogin {
45+
constructor(loginConfig) {
46+
this.loginConfig = loginConfig;
47+
}
48+
initialize() {
49+
return __awaiter(this, void 0, void 0, function* () {
50+
Utils_1.default.setPSModulePath();
51+
const azLatestVersion = yield Utils_1.default.getLatestModule(Constants_1.default.moduleName);
52+
core.debug(`Az Module version used: ${azLatestVersion}`);
53+
Utils_1.default.setPSModulePath(`${Constants_1.default.prefix}${azLatestVersion}`);
54+
});
55+
}
56+
login() {
57+
return __awaiter(this, void 0, void 0, function* () {
58+
let output = "";
59+
let commandStdErr = false;
60+
const options = {
61+
listeners: {
62+
stdout: (data) => {
63+
output += data.toString();
64+
},
65+
stderr: (data) => {
66+
let error = data.toString();
67+
if (error && error.trim().length !== 0) {
68+
commandStdErr = true;
69+
core.error(error);
70+
}
71+
}
72+
}
73+
};
74+
const args = {
75+
servicePrincipalId: this.loginConfig.servicePrincipalId,
76+
servicePrincipalKey: this.loginConfig.servicePrincipalKey,
77+
federatedToken: this.loginConfig.federatedToken,
78+
subscriptionId: this.loginConfig.subscriptionId,
79+
environment: this.loginConfig.environment,
80+
scopeLevel: ServicePrincipalLogin.scopeLevel,
81+
allowNoSubscriptionsLogin: this.loginConfig.allowNoSubscriptionsLogin,
82+
resourceManagerEndpointUrl: this.loginConfig.resourceManagerEndpointUrl
83+
};
84+
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.loginConfig.tenantId, args);
85+
yield PowerShellToolRunner_1.default.init();
86+
yield PowerShellToolRunner_1.default.executePowerShellScriptBlock(script, options);
87+
const result = JSON.parse(output.trim());
88+
if (!(Constants_1.default.Success in result)) {
89+
throw new Error(`Azure PowerShell login failed with error: ${result[Constants_1.default.Error]}`);
90+
}
91+
console.log(`Azure PowerShell session successfully initialized`);
92+
});
93+
}
94+
}
95+
exports.ServicePrincipalLogin = ServicePrincipalLogin;
96+
ServicePrincipalLogin.scopeLevel = Constants_1.default.Subscription;
97+
ServicePrincipalLogin.scheme = Constants_1.default.ServicePrincipal;

0 commit comments

Comments
 (0)