added review comments

This commit is contained in:
Akshaya M
2020-03-24 15:40:30 +05:30
parent 97c66dece8
commit 6df92eb730
2 changed files with 16 additions and 7 deletions

View File

@@ -59,9 +59,9 @@ class ServicePrincipalLogin {
const script = new ScriptBuilder_1.default().getAzPSLoginScript(ServicePrincipalLogin.scheme, this.tenantId, args);
yield PowerShellToolRunner_1.default.init();
yield PowerShellToolRunner_1.default.executePowerShellScriptBlock(script, options);
const outputJson = JSON.parse(output.trim());
if (!(Constants_1.default.Success in outputJson)) {
throw new Error(`Azure PowerShell login failed with error: ${outputJson[Constants_1.default.Error]}`);
const result = JSON.parse(output.trim());
if (!(Constants_1.default.Success in result)) {
throw new Error(`Azure PowerShell login failed with error: ${result[Constants_1.default.Error]}`);
}
});
}

View File

@@ -24,6 +24,15 @@ const Constants_1 = __importDefault(require("../Constants"));
const ScriptBuilder_1 = __importDefault(require("./ScriptBuilder"));
const PowerShellToolRunner_1 = __importDefault(require("./PowerShellToolRunner"));
class Utils {
/**
* Add the folder path where Az modules are present to PSModulePath based on runner
*
* @param azPSVersion
*
* If azPSVersion is empty, folder path in which all Az modules are present are set
* If azPSVersion is not empty, folder path of exact Az module version is set
*
*/
static setPSModulePath(azPSVersion = "") {
let modulePath = "";
const runner = process.env.RUNNER_OS || os.type();
@@ -56,11 +65,11 @@ class Utils {
yield PowerShellToolRunner_1.default.init();
yield PowerShellToolRunner_1.default.executePowerShellScriptBlock(new ScriptBuilder_1.default()
.getLatestModuleScript(moduleName), options);
const outputJson = JSON.parse(output.trim());
if (!(Constants_1.default.Success in outputJson)) {
throw new Error(outputJson[Constants_1.default.Error]);
const result = JSON.parse(output.trim());
if (!(Constants_1.default.Success in result)) {
throw new Error(result[Constants_1.default.Error]);
}
const azLatestVersion = outputJson[Constants_1.default.AzVersion];
const azLatestVersion = result[Constants_1.default.AzVersion];
if (!Utils.isValidVersion(azLatestVersion)) {
throw new Error(`Invalid AzPSVersion: ${azLatestVersion}`);
}