diff --git a/lib/ActionInputValidator/ValidatorFactory.js b/lib/ActionInputValidator/ValidatorFactory.js index 93f570515..390a0b5bf 100644 --- a/lib/ActionInputValidator/ValidatorFactory.js +++ b/lib/ActionInputValidator/ValidatorFactory.js @@ -1,84 +1,84 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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 actionparameters_1 = require("../actionparameters"); -const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"); -const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); -const PublishProfileWebAppValidator_1 = require("./ActionValidators/PublishProfileWebAppValidator"); -const PublishProfileContainerWebAppValidator_1 = require("./ActionValidators/PublishProfileContainerWebAppValidator"); -const SpnLinuxContainerWebAppValidator_1 = require("./ActionValidators/SpnLinuxContainerWebAppValidator"); -const SpnLinuxWebAppValidator_1 = require("./ActionValidators/SpnLinuxWebAppValidator"); -const SpnWindowsContainerWebAppValidator_1 = require("./ActionValidators/SpnWindowsContainerWebAppValidator"); -const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebAppValidator"); -const Validations_1 = require("./Validations"); -const PublishProfile_1 = require("../Utilities/PublishProfile"); -const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); -class ValidatorFactory { - static getValidator(type) { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { - if (!!actionParams.images) { - yield this.setResourceDetails(actionParams); - return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator(); - } - else { - return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator(); - } - } - else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { - // app-name is required to get resource details - Validations_1.appNameIsRequired(actionParams.appName); - yield this.getResourceDetails(actionParams); - if (!!actionParams.isLinux) { - if (!!actionParams.images) { - return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator(); - } - else { - return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator(); - } - } - else { - if (!!actionParams.images) { - return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator(); - } - else { - return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator(); - } - } - } - else { - throw new Error("Valid credentails are not available. Add Azure Login action before this action or provide publish-profile input."); - } - }); - } - static getResourceDetails(params) { - return __awaiter(this, void 0, void 0, function* () { - let appDetails = yield AzureResourceFilterUtility_1.AzureResourceFilterUtility.getAppDetails(params.endpoint, params.appName); - params.resourceGroupName = appDetails["resourceGroupName"]; - params.realKind = appDetails["kind"]; - params.kind = actionparameters_1.appKindMap.get(params.realKind); - //app kind linux and kubeapp is supported only on linux environment currently - params.isLinux = params.realKind.indexOf("linux") > -1 || params.realKind.indexOf("kubeapp") > -1; - }); - } - static setResourceDetails(actionParams) { - return __awaiter(this, void 0, void 0, function* () { - const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); - const appOS = yield publishProfile.getAppOS(); - actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase()); - }); - } -} -exports.ValidatorFactory = ValidatorFactory; +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + 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 actionparameters_1 = require("../actionparameters"); +const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"); +const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); +const PublishProfileWebAppValidator_1 = require("./ActionValidators/PublishProfileWebAppValidator"); +const PublishProfileContainerWebAppValidator_1 = require("./ActionValidators/PublishProfileContainerWebAppValidator"); +const SpnLinuxContainerWebAppValidator_1 = require("./ActionValidators/SpnLinuxContainerWebAppValidator"); +const SpnLinuxWebAppValidator_1 = require("./ActionValidators/SpnLinuxWebAppValidator"); +const SpnWindowsContainerWebAppValidator_1 = require("./ActionValidators/SpnWindowsContainerWebAppValidator"); +const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebAppValidator"); +const Validations_1 = require("./Validations"); +const PublishProfile_1 = require("../Utilities/PublishProfile"); +const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); +class ValidatorFactory { + static getValidator(type) { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { + if (!!actionParams.images) { + yield this.setResourceDetails(actionParams); + return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator(); + } + else { + return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator(); + } + } + else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { + // app-name is required to get resource details + Validations_1.appNameIsRequired(actionParams.appName); + yield this.getResourceDetails(actionParams); + if (!!actionParams.isLinux) { + if (!!actionParams.images || !!actionParams.multiContainerConfigFile) { + return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator(); + } + else { + return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator(); + } + } + else { + if (!!actionParams.images) { + return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator(); + } + else { + return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator(); + } + } + } + else { + throw new Error("Valid credentials are not available. Add Azure Login action before this action or provide publish-profile input."); + } + }); + } + static getResourceDetails(params) { + return __awaiter(this, void 0, void 0, function* () { + let appDetails = yield AzureResourceFilterUtility_1.AzureResourceFilterUtility.getAppDetails(params.endpoint, params.appName); + params.resourceGroupName = appDetails["resourceGroupName"]; + params.realKind = appDetails["kind"]; + params.kind = actionparameters_1.appKindMap.get(params.realKind); + //app kind linux and kubeapp is supported only on linux environment currently + params.isLinux = params.realKind.indexOf("linux") > -1 || params.realKind.indexOf("kubeapp") > -1; + }); + } + static setResourceDetails(actionParams) { + return __awaiter(this, void 0, void 0, function* () { + const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); + const appOS = yield publishProfile.getAppOS(); + actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase()); + }); + } +} +exports.ValidatorFactory = ValidatorFactory; diff --git a/lib/DeploymentProvider/DeploymentProviderFactory.js b/lib/DeploymentProvider/DeploymentProviderFactory.js index 073066580..410441026 100644 --- a/lib/DeploymentProvider/DeploymentProviderFactory.js +++ b/lib/DeploymentProvider/DeploymentProviderFactory.js @@ -1,31 +1,31 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const actionparameters_1 = require("../actionparameters"); -const BaseWebAppDeploymentProvider_1 = require("./Providers/BaseWebAppDeploymentProvider"); -const WebAppContainerDeployment_1 = require("./Providers/WebAppContainerDeployment"); -const WebAppDeploymentProvider_1 = require("./Providers/WebAppDeploymentProvider"); -const PublishProfileWebAppContainerDeploymentProvider_1 = require("./Providers/PublishProfileWebAppContainerDeploymentProvider"); -class DeploymentProviderFactory { - static getDeploymentProvider(type) { - if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { - if (!!actionparameters_1.ActionParameters.getActionParams().images) { - return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type); - } - else { - return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); - } - } - else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { - if (!!actionparameters_1.ActionParameters.getActionParams().images) { - return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type); - } - else { - return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); - } - } - else { - throw new Error("Invalid deployment provider type."); - } - } -} -exports.DeploymentProviderFactory = DeploymentProviderFactory; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const actionparameters_1 = require("../actionparameters"); +const BaseWebAppDeploymentProvider_1 = require("./Providers/BaseWebAppDeploymentProvider"); +const WebAppContainerDeployment_1 = require("./Providers/WebAppContainerDeployment"); +const WebAppDeploymentProvider_1 = require("./Providers/WebAppDeploymentProvider"); +const PublishProfileWebAppContainerDeploymentProvider_1 = require("./Providers/PublishProfileWebAppContainerDeploymentProvider"); +class DeploymentProviderFactory { + static getDeploymentProvider(type) { + if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { + if (!!actionparameters_1.ActionParameters.getActionParams().images) { + return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type); + } + else { + return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); + } + } + else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { + if (!!actionparameters_1.ActionParameters.getActionParams().images || (!!actionparameters_1.ActionParameters.getActionParams().isLinux && !!actionparameters_1.ActionParameters.getActionParams().multiContainerConfigFile)) { + return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type); + } + else { + return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); + } + } + else { + throw new Error("Invalid deployment provider type."); + } + } +} +exports.DeploymentProviderFactory = DeploymentProviderFactory; diff --git a/src/ActionInputValidator/ValidatorFactory.ts b/src/ActionInputValidator/ValidatorFactory.ts index 5b6543be9..08b514ae5 100644 --- a/src/ActionInputValidator/ValidatorFactory.ts +++ b/src/ActionInputValidator/ValidatorFactory.ts @@ -30,7 +30,7 @@ export class ValidatorFactory { appNameIsRequired(actionParams.appName); await this.getResourceDetails(actionParams); if (!!actionParams.isLinux) { - if (!!actionParams.images) { + if (!!actionParams.images || !!actionParams.multiContainerConfigFile) { return new SpnLinuxContainerWebAppValidator(); } else { diff --git a/src/DeploymentProvider/DeploymentProviderFactory.ts b/src/DeploymentProvider/DeploymentProviderFactory.ts index e64e251a1..b225abc4b 100644 --- a/src/DeploymentProvider/DeploymentProviderFactory.ts +++ b/src/DeploymentProvider/DeploymentProviderFactory.ts @@ -18,7 +18,7 @@ export class DeploymentProviderFactory { } } else if(type == DEPLOYMENT_PROVIDER_TYPES.SPN) { - if (!!ActionParameters.getActionParams().images) { + if(!!ActionParameters.getActionParams().images || (!!ActionParameters.getActionParams().isLinux && !!ActionParameters.getActionParams().multiContainerConfigFile)) { return new WebAppContainerDeploymentProvider(type); } else {