diff --git a/lib/main.js b/lib/main.js index 47200c70..4be73f59 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,9 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const crypto = __importStar(require("crypto")); @@ -37,7 +34,6 @@ const exec = __importStar(require("@actions/exec")); const io = __importStar(require("@actions/io")); const actions_secret_parser_1 = require("actions-secret-parser"); const ServicePrincipalLogin_1 = require("./PowerShell/ServicePrincipalLogin"); -const Constants_1 = __importDefault(require("./PowerShell/Constants")); var azPath; var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; var azPSHostEnv = !!process.env.AZUREPS_HOST_ENVIRONMENT ? `${process.env.AZUREPS_HOST_ENVIRONMENT}` : ""; @@ -54,6 +50,7 @@ function main() { core.exportVariable('AZUREPS_HOST_ENVIRONMENT', azurePSHostEnv); azPath = yield io.which("az", true); yield executeAzCliCommand("--version"); + let azureSupportedCloudName = ["azureusgovernment", "azurechinacloud", "azuregermancloud", "azurecloud", "azurestack"]; let creds = core.getInput('creds', { required: true }); let secrets = new actions_secret_parser_1.SecretParser(creds, actions_secret_parser_1.FormatType.JSON); let servicePrincipalId = secrets.getSecret("$.clientId", false); @@ -67,7 +64,7 @@ function main() { if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !subscriptionId) { throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied."); } - if (!Constants_1.default.AzureSupportedCloudName.includes(environment)) { + if (!azureSupportedCloudName.includes(environment)) { throw new Error("Unsupported value for environment is passed.The list of supported values for environment are ‘azureusgovernment', ‘azurechinacloud’, ‘azuregermancloud’, ‘azurecloud’ or ’azurestack’"); } // Attempting Az cli login diff --git a/src/PowerShell/Constants.ts b/src/PowerShell/Constants.ts index 572b7b70..9613db1d 100644 --- a/src/PowerShell/Constants.ts +++ b/src/PowerShell/Constants.ts @@ -10,5 +10,4 @@ export default class Constants { static readonly Success: string = "Success"; static readonly Error: string = "Error"; static readonly AzVersion: string = "AzVersion"; - static readonly AzureSupportedCloudName:string[] = ["azureusgovernment", "azurechinacloud", "azuregermancloud","azurecloud","azurestack"]; } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 8139be21..0fd469b9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,6 @@ import * as exec from '@actions/exec'; import * as io from '@actions/io'; import { FormatType, SecretParser } from 'actions-secret-parser'; import { ServicePrincipalLogin } from './PowerShell/ServicePrincipalLogin'; -import Constants from './PowerShell/Constants'; var azPath: string; var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; @@ -23,7 +22,8 @@ async function main() { azPath = await io.which("az", true); await executeAzCliCommand("--version"); - + + let azureSupportedCloudName:string[] = ["azureusgovernment", "azurechinacloud", "azuregermancloud","azurecloud","azurestack"]; let creds = core.getInput('creds', { required: true }); let secrets = new SecretParser(creds, FormatType.JSON); let servicePrincipalId = secrets.getSecret("$.clientId", false); @@ -34,11 +34,12 @@ async function main() { let environment = core.getInput("environment"); environment = environment.toLowerCase(); const enableAzPSSession = core.getInput('enable-AzPSSession').toLowerCase() === "true"; + if (!servicePrincipalId || !servicePrincipalKey || !tenantId || !subscriptionId) { throw new Error("Not all values are present in the creds object. Ensure clientId, clientSecret, tenantId and subscriptionId are supplied."); } - if(!Constants.AzureSupportedCloudName.includes(environment)){ + if(!azureSupportedCloudName.includes(environment)){ throw new Error("Unsupported value for environment is passed.The list of supported values for environment are ‘azureusgovernment', ‘azurechinacloud’, ‘azuregermancloud’, ‘azurecloud’ or ’azurestack’"); }