mirror of
https://github.com/azure/login.git
synced 2026-03-13 18:17:09 -04:00
making login calls silent (#19)
Co-authored-by: Deepak Sattiraju <desattir@microsoft.com>
This commit is contained in:
@@ -49,8 +49,8 @@ function main() {
|
||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied.");
|
||||
}
|
||||
// Attempting Az cli login
|
||||
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`);
|
||||
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`);
|
||||
yield executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||
yield executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||
isAzCLISuccess = true;
|
||||
if (enableAzPSSession) {
|
||||
// Attempting Az PS login
|
||||
@@ -77,10 +77,10 @@ function main() {
|
||||
}
|
||||
});
|
||||
}
|
||||
function executeAzCliCommand(command) {
|
||||
function executeAzCliCommand(command, silent) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
yield exec.exec(`"${azPath}" ${command}`, [], {});
|
||||
yield exec.exec(`"${azPath}" ${command}`, [], { silent: !!silent });
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error(error);
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -35,8 +35,8 @@ async function main() {
|
||||
throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied.");
|
||||
}
|
||||
// Attempting Az cli login
|
||||
await executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`);
|
||||
await executeAzCliCommand(`account set --subscription "${subscriptionId}"`);
|
||||
await executeAzCliCommand(`login --service-principal -u "${servicePrincipalId}" -p "${servicePrincipalKey}" --tenant "${tenantId}"`, true);
|
||||
await executeAzCliCommand(`account set --subscription "${subscriptionId}"`, true);
|
||||
isAzCLISuccess = true;
|
||||
if (enableAzPSSession) {
|
||||
// Attempting Az PS login
|
||||
@@ -45,7 +45,7 @@ async function main() {
|
||||
await spnlogin.initialize();
|
||||
await spnlogin.login();
|
||||
}
|
||||
console.log("Login successful.");
|
||||
console.log("Login successful.");
|
||||
} catch (error) {
|
||||
if (!isAzCLISuccess) {
|
||||
core.error("Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows");
|
||||
@@ -60,9 +60,9 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
async function executeAzCliCommand(command: string) {
|
||||
async function executeAzCliCommand(command: string, silent?: boolean) {
|
||||
try {
|
||||
await exec.exec(`"${azPath}" ${command}`, [], {});
|
||||
await exec.exec(`"${azPath}" ${command}`, [], {silent: !!silent});
|
||||
}
|
||||
catch(error) {
|
||||
throw new Error(error);
|
||||
|
||||
Reference in New Issue
Block a user