Skip to content

Commit

Permalink
add await to setazurestack
Browse files Browse the repository at this point in the history
  • Loading branch information
MoChilia committed Jun 19, 2024
1 parent 0df14e3 commit deb78be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions lib/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4003,7 +4003,7 @@ class AzureCliLogin {
};
yield this.executeAzCliCommand(["version"], true, execOptions);
core.debug(`Azure CLI version used:\n${output}`);
this.setAzurestackEnvIfNecessary();
yield this.registerAzurestackEnvIfNecessary();
yield this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
core.info(`Done setting cloud: "${this.loginConfig.environment}"`);
if (this.loginConfig.authType === LoginConfig_1.LoginConfig.AUTH_TYPE_SERVICE_PRINCIPAL) {
Expand All @@ -4029,22 +4029,22 @@ class AzureCliLogin {
}
});
}
setAzurestackEnvIfNecessary() {
registerAzurestackEnvIfNecessary() {
return __awaiter(this, void 0, void 0, function* () {
if (this.loginConfig.environment != "azurestack") {
return;
}
if (!this.loginConfig.resourceManagerEndpointUrl) {
throw new Error("resourceManagerEndpointUrl is a required parameter when environment is defined.");
}
// core.info(`Unregistering cloud: "${this.loginConfig.environment}" first if it exists`);
// try {
// await this.executeAzCliCommand(["cloud", "set", "-n", "AzureCloud"], true);
// await this.executeAzCliCommand(["cloud", "unregister", "-n", this.loginConfig.environment], false);
// }
// catch (error) {
// core.info(`Ignore cloud not registered error: "${error}"`);
// }
core.info(`Unregistering cloud: "${this.loginConfig.environment}" first if it exists`);
try {
yield this.executeAzCliCommand(["cloud", "set", "-n", "AzureCloud"], true);
yield this.executeAzCliCommand(["cloud", "unregister", "-n", this.loginConfig.environment], false);
}
catch (error) {
core.info(`Ignore cloud not registered error: "${error}"`);
}
core.info(`Registering cloud: "${this.loginConfig.environment}" with ARM endpoint: "${this.loginConfig.resourceManagerEndpointUrl}"`);
try {
let baseUri = this.loginConfig.resourceManagerEndpointUrl;
Expand Down
20 changes: 10 additions & 10 deletions src/Cli/AzureCliLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AzureCliLogin {
await this.executeAzCliCommand(["version"], true, execOptions);
core.debug(`Azure CLI version used:\n${output}`);

this.setAzurestackEnvIfNecessary();
await this.registerAzurestackEnvIfNecessary();

await this.executeAzCliCommand(["cloud", "set", "-n", this.loginConfig.environment], false);
core.info(`Done setting cloud: "${this.loginConfig.environment}"`);
Expand Down Expand Up @@ -59,22 +59,22 @@ export class AzureCliLogin {
}
}

async setAzurestackEnvIfNecessary() {
async registerAzurestackEnvIfNecessary() {
if (this.loginConfig.environment != "azurestack") {
return;
}
if (!this.loginConfig.resourceManagerEndpointUrl) {
throw new Error("resourceManagerEndpointUrl is a required parameter when environment is defined.");
}

// core.info(`Unregistering cloud: "${this.loginConfig.environment}" first if it exists`);
// try {
// await this.executeAzCliCommand(["cloud", "set", "-n", "AzureCloud"], true);
// await this.executeAzCliCommand(["cloud", "unregister", "-n", this.loginConfig.environment], false);
// }
// catch (error) {
// core.info(`Ignore cloud not registered error: "${error}"`);
// }
core.info(`Unregistering cloud: "${this.loginConfig.environment}" first if it exists`);
try {
await this.executeAzCliCommand(["cloud", "set", "-n", "AzureCloud"], true);
await this.executeAzCliCommand(["cloud", "unregister", "-n", this.loginConfig.environment], false);
}
catch (error) {
core.info(`Ignore cloud not registered error: "${error}"`);
}

core.info(`Registering cloud: "${this.loginConfig.environment}" with ARM endpoint: "${this.loginConfig.resourceManagerEndpointUrl}"`);
try {
Expand Down

0 comments on commit deb78be

Please sign in to comment.