Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubeapp (master) #141

Closed
Closed
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
158 changes: 79 additions & 79 deletions lib/ActionInputValidator/ValidatorFactory.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
"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);
switch (actionParams.kind) {
case actionparameters_1.WebAppKind.Linux:
return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator();
case actionparameters_1.WebAppKind.Windows:
return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator();
case actionparameters_1.WebAppKind.LinuxContainer:
return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator();
case actionparameters_1.WebAppKind.WindowsContainer:
return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator();
default:
throw new Error(`Action does not support app service with kind ${actionParams.realKind}.`);
}
}
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);
params.isLinux = params.realKind.indexOf("linux") > -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);
switch (actionParams.kind) {
case actionparameters_1.WebAppKind.Linux:
return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator();
case actionparameters_1.WebAppKind.Windows:
return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator();
case actionparameters_1.WebAppKind.LinuxContainer:
return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator();
case actionparameters_1.WebAppKind.WindowsContainer:
return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator();
default:
throw new Error(`Action does not support app service with kind ${actionParams.realKind}.`);
}
}
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);
params.isLinux = params.realKind.indexOf("linux") > -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;
16 changes: 13 additions & 3 deletions lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const utility = __importStar(require("azure-actions-utility/utility.js"));
const zipUtility = __importStar(require("azure-actions-utility/ziputility.js"));
const packageUtility_1 = require("azure-actions-utility/packageUtility");
const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider");
const AnnotationUtility_1 = require("azure-actions-appservice-rest/Utilities/AnnotationUtility");
class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider {
DeployWebAppStep() {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -40,18 +41,18 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
let folderPath = yield utility.generateTemporaryFolderForDeployment(false, webPackage, packageUtility_1.PackageType.jar);
let output = yield utility.archiveFolderForDeployment(false, folderPath);
webPackage = output.webDeployPkg;
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage);
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
case packageUtility_1.PackageType.folder:
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
webPackage = (yield zipUtility.archiveFolder(webPackage, "", tempPackagePath));
core.debug("Compressed folder into zip " + webPackage);
core.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage);
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
case packageUtility_1.PackageType.zip:
core.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage);
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
default:
throw new Error('Invalid App Service package or folder path provided: ' + webPackage);
Expand All @@ -75,5 +76,14 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
}
});
}
UpdateDeploymentStatus(isDeploymentSuccess) {
return __awaiter(this, void 0, void 0, function* () {
if (!!this.appService) {
yield AnnotationUtility_1.addAnnotation(this.actionParams.endpoint, this.appService, isDeploymentSuccess);
}
console.log('App Service Application URL: ' + this.applicationURL);
core.setOutput('webapp-url', this.applicationURL);
});
}
}
exports.WebAppDeploymentProvider = WebAppDeploymentProvider;
71 changes: 30 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@actions/core": "^1.2.6",
"actions-secret-parser": "^1.0.3",
"azure-actions-appservice-rest": "^1.3.1",
"azure-actions-appservice-rest": "^1.3.2",
"azure-actions-utility": "^1.0.3",
"azure-actions-webclient": "^1.1.0"
}
Expand Down
1 change: 0 additions & 1 deletion src/actionparameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class ActionParameters {
if (!this.actionparams) {
this.actionparams = new ActionParameters(!!endpoint ? endpoint : null);
}

return this.actionparams;
}

Expand Down