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
Jump to file
Failed to load files.
Loading
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 validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(PublishProfileWebAppValidator);
let validator = await ValidatorFactory.getValidator(type);
expect(validator).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 validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(PublishProfileContainerWebAppValidator);
let validator = await ValidatorFactory.getValidator(type);
expect(validator).toBeInstanceOf(PublishProfileContainerWebAppValidator);
});

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

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

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

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

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

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

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

let validators = await ValidatorFactory.getValidator(type);
expect(validators[0]).toBeInstanceOf(SpnWindowsWebAppValidator);
let validator = await ValidatorFactory.getValidator(type);
expect(validator).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 providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppDeploymentProvider);
let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).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 providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(PublishProfileWebAppContainerDeploymentProvider);
let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).toBeInstanceOf(PublishProfileWebAppContainerDeploymentProvider);
});

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

let type: DEPLOYMENT_PROVIDER_TYPES = DEPLOYMENT_PROVIDER_TYPES.SPN;

let providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppDeploymentProvider);
let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).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 providers = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(providers[0]).toBeInstanceOf(WebAppContainerDeploymentProvider);
let provider = await DeploymentProviderFactory.getDeploymentProvider(type);
expect(provider).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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpnWebAppSiteContainersValidator = void 0;
const Validations_1 = require("../Validations");
class SpnWebAppSiteContainersValidator {
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) {
yield _super.validate.call(this);
}
(0, Validations_1.validateSiteContainersInputs)();
});
}
Expand Down
33 changes: 16 additions & 17 deletions lib/ActionInputValidator/ValidatorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class ValidatorFactory {
let actionParams = actionparameters_1.ActionParameters.getActionParams();
if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) {
if (!!actionParams.blessedAppSitecontainers || !!actionParams.siteContainers) {
return [new PublishProfileWebAppSiteContainersValidator_1.PublishProfileWebAppSiteContainersValidator()];
return new PublishProfileWebAppSiteContainersValidator_1.PublishProfileWebAppSiteContainersValidator();
}
else if (!!actionParams.images) {
yield this.setResourceDetails(actionParams);
return [new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator()];
return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator();
}
else {
try {
Expand All @@ -81,7 +81,7 @@ class ValidatorFactory {
catch (error) {
core.warning(`Failed to set resource details: ${error.message}`);
}
return [new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator()];
return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator();
}
}
else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) {
Expand All @@ -90,24 +90,22 @@ class ValidatorFactory {
yield this.getResourceDetails(actionParams);
if (!!actionParams.isLinux) {
if (!!actionParams.siteContainers) {
if (yield this.isBlessedSitecontainerApp(actionParams)) {
return [new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator(), new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator()];
}
return [new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator()];
yield this.setBlessedSitecontainerApp(actionParams);
return new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator();
}
else if (!!actionParams.images || !!actionParams.multiContainerConfigFile) {
return [new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator()];
return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator();
}
else {
return [new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator()];
return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator();
}
}
else {
if (!!actionParams.images) {
return [new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator()];
return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator();
}
else {
return [new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator()];
return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator();
}
}
}
Expand All @@ -133,16 +131,17 @@ class ValidatorFactory {
actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase());
});
}
static isBlessedSitecontainerApp(actionParams) {
static setBlessedSitecontainerApp(actionParams) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
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}`);
actionParams.blessedAppSitecontainers = (((_a = config.properties.linuxFxVersion) === null || _a === void 0 ? void 0 : _a.startsWith("DOCKER|")) !== true
&& ((_b = config.properties.linuxFxVersion) === null || _b === void 0 ? void 0 : _b.startsWith("COMPOSE|")) !== true
&& config.properties.linuxFxVersion !== "SITECONTAINERS");
return actionParams.blessedAppSitecontainers;
const linuxFxVersion = ((_a = config.properties.linuxFxVersion) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "";
actionParams.blessedAppSitecontainers = (!linuxFxVersion.startsWith("DOCKER|")
&& !linuxFxVersion.startsWith("COMPOSE|")
&& linuxFxVersion !== "SITECONTAINERS");
core.debug(`Is blessed app sitecontainers: ${actionParams.blessedAppSitecontainers}`);
});
}
}
Expand Down
15 changes: 6 additions & 9 deletions lib/DeploymentProvider/DeploymentProviderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,21 @@ 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)];
return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type);
}
else {
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type)];
return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type);
}
}
else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) {
if (!!actionparameters_1.ActionParameters.getActionParams().blessedAppSitecontainers) {
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type), new WebAppSiteContainersDeploymentProvider_1.WebAppSiteContainersDeploymentProvider(type)];
}
else if (!!actionparameters_1.ActionParameters.getActionParams().siteContainers) {
return [new WebAppSiteContainersDeploymentProvider_1.WebAppSiteContainersDeploymentProvider(type)];
if (!!actionparameters_1.ActionParameters.getActionParams().blessedAppSitecontainers || !!actionparameters_1.ActionParameters.getActionParams().siteContainers) {
return new WebAppSiteContainersDeploymentProvider_1.WebAppSiteContainersDeploymentProvider(type);
}
else if (!!actionparameters_1.ActionParameters.getActionParams().images || (!!actionparameters_1.ActionParameters.getActionParams().isLinux && !!actionparameters_1.ActionParameters.getActionParams().multiContainerConfigFile)) {
return [new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type)];
return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type);
}
else {
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type)];
return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type);
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebAppSiteContainersDeploymentProvider = void 0;
const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider");
const SiteContainerDeploymentUtility_1 = require("azure-actions-appservice-rest/Utilities/SiteContainerDeploymentUtility");
const core = __importStar(require("@actions/core"));
class WebAppSiteContainersDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider {
const WebAppDeploymentProvider_1 = require("./WebAppDeploymentProvider");
class WebAppSiteContainersDeploymentProvider extends WebAppDeploymentProvider_1.WebAppDeploymentProvider {
DeployWebAppStep() {
const _super = Object.create(null, {
DeployWebAppStep: { get: () => super.DeployWebAppStep }
});
return __awaiter(this, void 0, void 0, function* () {
if (!!this.actionParams.blessedAppSitecontainers) {
core.info("Blessed site containers detected, using WebAppDeploymentProvider for deployment.");
yield _super.DeployWebAppStep.call(this);
}
let siteContainerDeploymentUtility = new SiteContainerDeploymentUtility_1.SiteContainerDeploymentUtility(this.appService);
let siteContainers = this.actionParams.siteContainers;
core.info("Updating site containers");
for (let i = 0; i < siteContainers.length; i++) {
let siteContainer = siteContainers[i];
core.info("updating site container: " + siteContainer.getName);
core.info("updating site container: " + siteContainer.getName());
yield siteContainerDeploymentUtility.updateSiteContainer(siteContainer);
}
});
Expand Down
22 changes: 9 additions & 13 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,13 @@ function main() {
type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE;
}
// Validate action inputs
let validators = yield ValidatorFactory_1.ValidatorFactory.getValidator(type);
for (const validator of validators) {
yield validator.validate();
}
var deploymentProviders = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type);
for (const provider of deploymentProviders) {
core.info("Predeployment Step Started");
yield provider.PreDeploymentStep();
core.info("Deployment Step Started");
yield provider.DeployWebAppStep();
}
let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type);
yield validator.validate();
var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type);
core.info("Predeployment Step Started");
yield deploymentProvider.PreDeploymentStep();
core.info("Deployment Step Started");
yield deploymentProvider.DeployWebAppStep();
}
catch (error) {
isDeploymentSuccess = false;
Expand All @@ -95,8 +91,8 @@ function main() {
}
}
finally {
if (deploymentProviders != null) {
yield deploymentProviders[0].UpdateDeploymentStatus(isDeploymentSuccess);
if (deploymentProvider != null) {
yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess);
}
// Reset AZURE_HTTP_USER_AGENT
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
Expand Down
Loading
Loading