Skip to content

Commit b4fcf5d

Browse files
committed
adding az cli version debug logs (Azure#76)
1 parent e2ec7a0 commit b4fcf5d

2 files changed

Lines changed: 31 additions & 8 deletions

File tree

lib/main.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ function main() {
3636
core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString);
3737
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
3838
azPath = yield io.which("az", true);
39-
yield executeAzCliCommand("--version");
39+
let output = "";
40+
const options = {
41+
listeners: {
42+
stdout: (data) => {
43+
output += data.toString();
44+
}
45+
}
46+
};
47+
yield executeAzCliCommand("--version", true, options);
48+
core.debug(`az cli version used:\n${output}`);
49+
4050
let creds = core.getInput('creds', { required: true });
4151
let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON);
4252
let servicePrincipalId = secrets.getSecret("$.clientId", false);
@@ -45,6 +55,7 @@ function main() {
4555
let subscriptionId = secrets.getSecret("$.subscriptionId", false);
4656
const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true";
4757
const allowNoSubscriptionsLogin = core.getInput('allow-no-subscriptions').toLowerCase() === "true";
58+
4859
if (!servicePrincipalId || !servicePrincipalKey || !tenantId) {
4960
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret and tenantId are supplied.");
5061
}
@@ -85,10 +96,12 @@ function main() {
8596
}
8697
});
8798
}
88-
function executeAzCliCommand(command, silent) {
99+
100+
function executeAzCliCommand(command, silent, options = {}) {
89101
return __awaiter(this, void 0, void 0, function* () {
102+
options.silent = !!silent;
90103
try {
91-
yield exec.exec(`"${azPath}" ${command}`, [], { silent: !!silent });
104+
yield exec.exec(`"${azPath}" ${command}`, [], options);
92105
}
93106
catch (error) {
94107
throw new Error(error);

src/main.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ async function main() {
2121
core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv);
2222

2323
azPath = await io.which("az", true);
24-
await executeAzCliCommand("--version");
25-
24+
let output: string = "";
25+
const options: any = {
26+
listeners: {
27+
stdout: (data: Buffer) => {
28+
output += data.toString();
29+
}
30+
}
31+
};
32+
await executeAzCliCommand("--version", true, options);
33+
core.debug(`az cli version used:\n${output}`);
34+
2635
let creds = core.getInput('creds', { required: true });
2736
let secrets = new SecretParser(creds, FormatType.JSON);
2837
let servicePrincipalId = secrets.getSecret("$.clientId", false);
@@ -70,13 +79,14 @@ async function main() {
7079
}
7180
}
7281

73-
async function executeAzCliCommand(command: string, silent?: boolean) {
82+
async function executeAzCliCommand(command: string, silent?: boolean, options: any = {}) {
83+
options.silent = !!silent;
7484
try {
75-
await exec.exec(`"${azPath}" ${command}`, [], {silent: !!silent});
85+
await exec.exec(`"${azPath}" ${command}`, [], options);
7686
}
7787
catch(error) {
7888
throw new Error(error);
7989
}
8090
}
8191

82-
main();
92+
main();

0 commit comments

Comments
 (0)