Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 12 additions & 12 deletions __tests__/ActionInputValidator/ValidatorFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('Test Validator Factory', () => {
jest.spyOn(PublishProfile, 'getPublishProfile').mockImplementation(() => PublishProfile.prototype);
jest.spyOn(PublishProfile.prototype, 'getAppOS').mockImplementation(async() => 'unix');

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(PublishProfileWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(PublishProfileWebAppValidator);
});

it("Get Container Validator for Publish Profile auth flow", async() => {
Expand All @@ -42,8 +42,8 @@ describe('Test Validator Factory', () => {
jest.spyOn(PublishProfile, 'getPublishProfile').mockImplementation(() => PublishProfile.prototype);
jest.spyOn(PublishProfile.prototype, 'getAppOS').mockImplementation(async() => 'unix');

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(PublishProfileContainerWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(PublishProfileContainerWebAppValidator);
});

});
Expand All @@ -70,8 +70,8 @@ describe('Test Validator Factory', () => {
};
});

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(SpnLinuxContainerWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(SpnLinuxContainerWebAppValidator);
});

it("Get Linux/Kube Code Validator for SPN auth flow", async() => {
Expand All @@ -90,8 +90,8 @@ describe('Test Validator Factory', () => {
};
});

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(SpnLinuxWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(SpnLinuxWebAppValidator);
});

it("Get Windows Container Validator for SPN auth flow", async() => {
Expand All @@ -111,8 +111,8 @@ describe('Test Validator Factory', () => {
};
});

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(SpnWindowsContainerWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(SpnWindowsContainerWebAppValidator);
});

it("Get Windows Code Validator for SPN auth flow", async() => {
Expand All @@ -131,8 +131,8 @@ describe('Test Validator Factory', () => {
};
});

let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(SpnWindowsWebAppValidator);
let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(SpnWindowsWebAppValidator);
});

});
Expand Down
16 changes: 8 additions & 8 deletions __tests__/DeploymentProvider/DeploymentProviderFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('Test Deployment Provider Factory', () => {
it("Get Code Deployment Provider for Publish Profile auth flow", async() => {
let type: DEPLOYMENT_PROVIDER_TYPES = DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE;

let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).toBeInstanceOf(WebAppDeploymentProvider);
let providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppDeploymentProvider);
});

it("Get Container Deployment Provider for Publish Profile auth flow", async() => {
Expand All @@ -32,8 +32,8 @@ describe('Test Deployment Provider Factory', () => {

let type: DEPLOYMENT_PROVIDER_TYPES = DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE;

let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).toBeInstanceOf(PublishProfileWebAppContainerDeploymentProvider);
let providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(PublishProfileWebAppContainerDeploymentProvider);
});

});
Expand All @@ -48,8 +48,8 @@ describe('Test Deployment Provider Factory', () => {

let type: DEPLOYMENT_PROVIDER_TYPES = DEPLOYMENT_PROVIDER_TYPES.SPN;

let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).toBeInstanceOf(WebAppDeploymentProvider);
let providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppDeploymentProvider);
});

it("Get Container Deployment Provider for SPN auth flow", async() => {
Expand All @@ -61,8 +61,8 @@ describe('Test Deployment Provider Factory', () => {

let type: DEPLOYMENT_PROVIDER_TYPES = DEPLOYMENT_PROVIDER_TYPES.SPN;

let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).toBeInstanceOf(WebAppContainerDeploymentProvider);
let providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppContainerDeploymentProvider);
});

});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ describe('Test azure-webapps-deploy', () => {
}
return '';
});
let getValidatorFactorySpy = jest.spyOn(ValidatorFactory, 'getValidator').mockImplementation(async _type => new PublishProfileWebAppValidator());
let getValidatorFactorySpy = jest.spyOn(ValidatorFactory, 'getValidator').mockImplementation(async _type => [new PublishProfileWebAppValidator()]);
let ValidatorFactoryValidateSpy = jest.spyOn(PublishProfileWebAppValidator.prototype, 'validate');
let getDeploymentProviderSpy = jest.spyOn(DeploymentProviderFactory, 'getDeploymentProvider').mockImplementation(type => new WebAppDeploymentProvider(type));
let getDeploymentProviderSpy = jest.spyOn(DeploymentProviderFactory, 'getDeploymentProvider').mockImplementation(type => [new WebAppDeploymentProvider(type)]);
let deployWebAppStepSpy = jest.spyOn(WebAppDeploymentProvider.prototype, 'DeployWebAppStep');
let updateDeploymentStatusSpy = jest.spyOn(WebAppDeploymentProvider.prototype, 'UpdateDeploymentStatus');

Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ inputs:
restart:
description: 'Restart the app service after deployment'
required: false

sitecontainers-config:
description: 'Applies to Sitecontainers, containes a list of siteContainer specs'
required: false

outputs:
webapp-url:
description: 'URL to work with your webapp'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PublishProfileContainerWebAppValidator {
(0, Validations_1.packageNotAllowed)(actionParams.packageInput);
(0, Validations_1.multiContainerNotAllowed)(actionParams.multiContainerConfigFile);
(0, Validations_1.startupCommandNotAllowed)(actionParams.startupCommand);
(0, Validations_1.siteContainersConfigNotAllowed)(actionParams.siteContainers);
(0, Validations_1.validateAppDetails)();
(0, Validations_1.validateSingleContainerInputs)();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublishProfileWebAppSiteContainersValidator = void 0;
class PublishProfileWebAppSiteContainersValidator {
validate() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("publish-profile is not supported for Site Containers scenario");
});
}
}
exports.PublishProfileWebAppSiteContainersValidator = PublishProfileWebAppSiteContainersValidator;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PublishProfileWebAppValidator {
(0, Validations_1.containerInputsNotAllowed)(actionParams.images, actionParams.multiContainerConfigFile, true);
(0, Validations_1.validateAppDetails)();
(0, Validations_1.startupCommandNotAllowed)(actionParams.startupCommand);
(0, Validations_1.siteContainersConfigNotAllowed)(actionParams.siteContainers);
yield (0, Validations_1.validatePackageInput)();
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
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) {
Expand All @@ -10,11 +43,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpnLinuxWebAppValidator = void 0;
const core = __importStar(require("@actions/core"));
const Validations_1 = require("../Validations");
const actionparameters_1 = require("../../actionparameters");
class SpnLinuxWebAppValidator {
validate() {
return __awaiter(this, void 0, void 0, function* () {
core.info("Validating SPN Linux Web App inputs...");
let actionParams = actionparameters_1.ActionParameters.getActionParams();
(0, Validations_1.containerInputsNotAllowed)(actionParams.images, actionParams.multiContainerConfigFile);
yield (0, Validations_1.validatePackageInput)();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpnWebAppSiteContainersValidator = void 0;
const core = __importStar(require("@actions/core"));
const Validations_1 = require("../Validations");
const SpnLinuxWebAppValidator_1 = require("./SpnLinuxWebAppValidator");
const actionparameters_1 = require("../../actionparameters");
class SpnWebAppSiteContainersValidator extends SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator {
validate() {
const _super = Object.create(null, {
validate: { get: () => super.validate }
});
return __awaiter(this, void 0, void 0, function* () {
let actionParams = actionparameters_1.ActionParameters.getActionParams();
if (!!actionParams.blessedAppSitecontainers) {
core.info("Blessed site containers detected, using SpnLinuxWebAppValidator for validation.");
yield _super.validate.call(this);
}
core.info("Validating SPN Web App Site Containers inputs...");
(0, Validations_1.validateSiteContainersInputs)();
});
}
}
exports.SpnWebAppSiteContainersValidator = SpnWebAppSiteContainersValidator;
15 changes: 15 additions & 0 deletions lib/ActionInputValidator/Validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ exports.multiContainerNotAllowed = multiContainerNotAllowed;
exports.validateSingleContainerInputs = validateSingleContainerInputs;
exports.validateContainerInputs = validateContainerInputs;
exports.validatePackageInput = validatePackageInput;
exports.siteContainersConfigNotAllowed = siteContainersConfigNotAllowed;
exports.validateSiteContainersInputs = validateSiteContainersInputs;
const core = __importStar(require("@actions/core"));
const packageUtility_1 = require("azure-actions-utility/packageUtility");
const PublishProfile_1 = require("../Utilities/PublishProfile");
Expand Down Expand Up @@ -146,3 +148,16 @@ function validatePackageInput() {
}
});
}
// Error if Sitecontainers configuration is provided
function siteContainersConfigNotAllowed(siteContainers) {
if (!!siteContainers) {
throw new Error("SiteContainers not valid input for this web app.");
}
}
// validate Sitecontainers inputs
function validateSiteContainersInputs() {
const actionParams = actionparameters_1.ActionParameters.getActionParams();
if (!actionParams.siteContainers || actionParams.siteContainers.length === 0) {
throw new Error("Site containers not provided.");
}
}
28 changes: 26 additions & 2 deletions lib/ActionInputValidator/ValidatorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebApp
const Validations_1 = require("./Validations");
const PublishProfile_1 = require("../Utilities/PublishProfile");
const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants"));
const SpnWebAppSiteContainersValidator_1 = require("./ActionValidators/SpnWebAppSiteContainersValidator");
const PublishProfileWebAppSiteContainersValidator_1 = require("./ActionValidators/PublishProfileWebAppSiteContainersValidator");
const azure_app_service_1 = require("azure-actions-appservice-rest/Arm/azure-app-service");
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) {
if (!!actionParams.blessedAppSitecontainers || !!actionParams.siteContainers) {
return new PublishProfileWebAppSiteContainersValidator_1.PublishProfileWebAppSiteContainersValidator();
}
else if (!!actionParams.images) {
yield this.setResourceDetails(actionParams);
return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator();
}
Expand All @@ -83,7 +89,12 @@ class ValidatorFactory {
(0, Validations_1.appNameIsRequired)(actionParams.appName);
yield this.getResourceDetails(actionParams);
if (!!actionParams.isLinux) {
if (!!actionParams.images || !!actionParams.multiContainerConfigFile) {
if (!!actionParams.siteContainers) {
yield this.setIfBlessedSitecontainerApp(actionParams);
core.debug(`Blessed site containers: ${actionParams.blessedAppSitecontainers}`);
return new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator();
}
else if (!!actionParams.images || !!actionParams.multiContainerConfigFile) {
return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator();
}
else {
Expand Down Expand Up @@ -121,5 +132,18 @@ class ValidatorFactory {
actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase());
});
}
static setIfBlessedSitecontainerApp(actionParams) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const appService = new azure_app_service_1.AzureAppService(actionParams.endpoint, actionParams.resourceGroupName, actionParams.appName, actionParams.slotName);
let config = yield appService.getConfiguration();
core.debug(`LinuxFxVersion of app is: ${config.properties.linuxFxVersion}`);
const linuxFxVersion = ((_a = config.properties.linuxFxVersion) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "";
actionParams.blessedAppSitecontainers = (!linuxFxVersion.startsWith("DOCKER|")
&& !linuxFxVersion.startsWith("COMPOSE|")
&& linuxFxVersion !== "SITECONTAINERS");
return actionParams.blessedAppSitecontainers;
});
}
}
exports.ValidatorFactory = ValidatorFactory;
Loading
Loading