Skip to content

Commit

Permalink
build releases/v1 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
patelchandni committed Apr 19, 2022
1 parent b52215f commit 45adfe5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 27 deletions.
14 changes: 7 additions & 7 deletions lib/handlers/contentPreparer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ContentPreparer {
}
return packagePath;
case packageUtility_1.PackageType.folder:
const tempoaryFilePath = (0, utility_js_1.generateTemporaryFolderOrZipPath)(process.env.RUNNER_TEMP, false);
const tempoaryFilePath = utility_js_1.generateTemporaryFolderOrZipPath(process.env.RUNNER_TEMP, false);
// Parse .funcignore and remove unwantted files
if (respectFuncignore) {
yield this.removeFilesDefinedInFuncignore(packagePath);
Expand All @@ -93,7 +93,7 @@ class ContentPreparer {
}
utils_1.Logger.Info(`Will archive ${sourceLocation} into ${tempoaryFilePath} as function app content`);
try {
return yield (0, ziputility_js_1.archiveFolder)(sourceLocation, "", tempoaryFilePath);
return yield ziputility_js_1.archiveFolder(sourceLocation, "", tempoaryFilePath);
}
catch (expt) {
throw new exceptions_1.FileIOError(state, "Generate Publish Content", `Failed to archive ${sourceLocation}`, expt);
Expand All @@ -105,16 +105,16 @@ class ContentPreparer {
}
getPomXmlSourceLocation(packagePath) {
return __awaiter(this, void 0, void 0, function* () {
const pomXmlPath = (0, path_1.resolve)(packagePath, 'pom.xml');
if (!(0, fs_1.existsSync)(pomXmlPath)) {
const pomXmlPath = path_1.resolve(packagePath, 'pom.xml');
if (!fs_1.existsSync(pomXmlPath)) {
utils_1.Logger.Warn(`The file ${pomXmlPath} does not exist. ` +
"Please ensure your publish-profile setting points to a folder containing host.json.");
utils_1.Logger.Warn(`Fall back on ${packagePath} as packaging source.`);
return packagePath;
}
let pomXmlContent = undefined;
try {
pomXmlContent = (0, fs_1.readFileSync)(pomXmlPath, 'utf8');
pomXmlContent = fs_1.readFileSync(pomXmlPath, 'utf8');
}
catch (expt) {
utils_1.Logger.Warn(`The file ${pomXmlPath} does not have valid content. Please check if the pom.xml file is ` +
Expand All @@ -123,7 +123,7 @@ class ContentPreparer {
return packagePath;
}
let pomXmlResult = undefined;
yield (0, xml2js_1.parseString)(pomXmlContent, (error, xmlResult) => {
yield xml2js_1.parseString(pomXmlContent, (error, xmlResult) => {
if (!error) {
pomXmlResult = xmlResult;
}
Expand All @@ -144,7 +144,7 @@ class ContentPreparer {
utils_1.Logger.Warn(`Fall back on ${packagePath} as packaging source.`);
return packagePath;
}
const pomPackagePath = (0, path_1.resolve)(packagePath, 'target', 'azure-functions', functionAppName);
const pomPackagePath = path_1.resolve(packagePath, 'target', 'azure-functions', functionAppName);
utils_1.Logger.Info(`Successfully parsed pom.xml. Using ${pomPackagePath} as source folder for packaging`);
return pomPackagePath;
});
Expand Down
31 changes: 27 additions & 4 deletions lib/handlers/parameterValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,24 @@ class ParameterValidator {
return creds;
}
let xmlProfile = undefined;
yield (0, xml2js_1.parseString)(publishProfile, (error, xmlResult) => {
yield xml2js_1.parseString(publishProfile, (error, xmlResult) => {
if (error) {
throw new exceptions_1.ValidationError(state, configuration_1.ConfigurationConstant.ParamInPublishProfile, "should be a valid XML. Please ensure your publish-profile secret is set in your " +
"GitHub repository by heading to GitHub repo -> Settings -> Secrets -> Repository secrets");
}
xmlProfile = xmlResult;
});
if (this.tryParseOldPublishProfile(xmlProfile, creds)) {
if (this.tryParsePublishProfileZipDeploy(xmlProfile, creds)) {
logger_1.Logger.Info('Successfully parsed SCM credential from publish-profile format.');
}
else if (this.tryParseOldPublishProfile(xmlProfile, creds)) {
logger_1.Logger.Info('Successfully parsed SCM credential from old publish-profile format.');
}
else if (this.tryParseNewPublishProfile(xmlProfile, creds)) {
logger_1.Logger.Info('Successfully passed SCM crednetial from new publish-profile format.');
}
else {
throw new exceptions_1.ValidationError(state, configuration_1.ConfigurationConstant.ParamInPublishProfile, "should contain valid SCM credentials. Please ensure your publish-profile contains 'MSDeploy' publish " +
throw new exceptions_1.ValidationError(state, configuration_1.ConfigurationConstant.ParamInPublishProfile, "should contain valid SCM credentials. Please ensure your publish-profile contains 'ZipDeploy' publish or 'MSDeploy' publish " +
"method. Ensure 'userName', 'userPWD', and 'publishUrl' exist in the section. You can always acquire " +
"the latest publish-profile from portal -> function app resource -> overview -> get publish profile");
}
Expand All @@ -99,6 +102,26 @@ class ParameterValidator {
return creds;
});
}
tryParsePublishProfileZipDeploy(xmlResult, out) {
// uri: cp-win-dotnet.scm.azurewebsites.net
const options = xmlResult.publishData.publishProfile.filter((p) => {
return p.$.publishMethod === "ZipDeploy";
});
if ((options || []).length == 0) {
logger_1.Logger.Error('The publish profile does not contain ZipDeploy publish method.');
return false;
}
const zipDeploy = options[0].$;
const publishUrl = zipDeploy.publishUrl.split(":")[0];
if (publishUrl.indexOf(".scm.") >= 0) {
out.uri = `https://${zipDeploy.userName}:${zipDeploy.userPWD}@${publishUrl}`;
out.username = zipDeploy.userName;
out.password = zipDeploy.userPWD;
out.appUrl = zipDeploy.destinationAppUrl;
return true;
}
return false;
}
tryParseOldPublishProfile(xmlResult, out) {
// uri: hazeng-fa-python38-azurecli.scm.azurewebsites.net
const options = xmlResult.publishData.publishProfile.filter((p) => {
Expand Down Expand Up @@ -150,7 +173,7 @@ class ParameterValidator {
if (this._packagePath === undefined || this._packagePath.trim() === "") {
throw new exceptions_1.ValidationError(state, configuration_1.ConfigurationConstant.ParamInPackagePath, "should not be empty");
}
if (!(0, packageUtility_1.exist)(this._packagePath)) {
if (!packageUtility_1.exist(this._packagePath)) {
throw new exceptions_1.ValidationError(state, configuration_1.ConfigurationConstant.ParamInPackagePath, `cannot find '${this._packagePath}'`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/publishValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PublishValidator {
invoke(_0, _1, context) {
return __awaiter(this, void 0, void 0, function* () {
if (context.endpoint && context.appService) {
yield (0, AnnotationUtility_1.addAnnotation)(context.endpoint, context.appService, true);
yield AnnotationUtility_1.addAnnotation(context.endpoint, context.appService, true);
}
// Set app-url output to function app url
core.setOutput(configuration_1.ConfigurationConstant.ParamOutResultName, context.appUrl);
Expand Down
6 changes: 0 additions & 6 deletions lib/handlers/resourceValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ class ResourceValidator {
throw new exceptions_1.ValidationError(state, 'Function Runtime', "Python Function App on Windows is not yet supported");
}
}
// Linux Java and Linux Powershell is not supported
if (context.os === runtime_stack_1.RuntimeStackConstant.Linux) {
if (context.language === function_runtime_1.FunctionRuntimeConstant.Powershell) {
throw new exceptions_1.ValidationError(state, 'Function Runtime', "PowerShell Function App on Windows is not yet supported");
}
}
}
}
exports.ResourceValidator = ResourceValidator;
1 change: 0 additions & 1 deletion lib/publishers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebsiteRunFromPackageDeploy = exports.ZipDeploy = void 0;
var zipDeploy_1 = require("./zipDeploy");
Object.defineProperty(exports, "ZipDeploy", { enumerable: true, get: function () { return zipDeploy_1.ZipDeploy; } });
var websiteRunFromPackageDeploy_1 = require("./websiteRunFromPackageDeploy");
Expand Down
4 changes: 2 additions & 2 deletions lib/publishers/websiteRunFromPackageDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class WebsiteRunFromPackageDeploy {
const blobURL = storage_blob_2.BlobURL.fromContainerURL(containerUrl, blobName);
const blockBlobURL = storage_blob_2.BlockBlobURL.fromBlobURL(blobURL);
try {
(0, storage_blob_2.uploadFileToBlockBlob)(storage_blob_1.Aborter.timeout(configuration_1.ConfigurationConstant.BlobUploadTimeoutMs), filePath, blockBlobURL, {
storage_blob_2.uploadFileToBlockBlob(storage_blob_1.Aborter.timeout(configuration_1.ConfigurationConstant.BlobUploadTimeoutMs), filePath, blockBlobURL, {
blockSize: configuration_1.ConfigurationConstant.BlobUploadBlockSizeByte,
parallelism: configuration_1.ConfigurationConstant.BlobUplaodBlockParallel,
});
Expand All @@ -104,7 +104,7 @@ class WebsiteRunFromPackageDeploy {
expiryTime: expiryTime,
permissions: configuration_1.ConfigurationConstant.BlobPermission
};
return (0, storage_blob_2.generateBlobSASQueryParameters)(blobSasValues, credential).toString();
return storage_blob_2.generateBlobSASQueryParameters(blobSasValues, credential).toString();
}
static publishToFunctionapp(state, appService, blobSasUrl) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/funcignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const ignore = require("ignore");
const logger_1 = require("./logger");
class FuncIgnore {
static doesFuncignoreExist(working_dir) {
const funcignorePath = (0, path_1.resolve)(working_dir, '.funcignore');
return (0, fs_1.existsSync)(funcignorePath);
const funcignorePath = path_1.resolve(working_dir, '.funcignore');
return fs_1.existsSync(funcignorePath);
}
static readFuncignore(working_dir) {
const funcignorePath = (0, path_1.resolve)(working_dir, '.funcignore');
const rules = (0, fs_1.readFileSync)(funcignorePath).toString().split('\n').filter(l => l.trim() !== '');
const funcignorePath = path_1.resolve(working_dir, '.funcignore');
const rules = fs_1.readFileSync(funcignorePath).toString().split('\n').filter(l => l.trim() !== '');
try {
// @ts-ignore
return ignore().add(rules);
Expand Down Expand Up @@ -43,7 +43,7 @@ class FuncIgnore {
});
}
static sanitizeWorkingDir(working_dir) {
return (0, path_1.normalize)((0, path_1.resolve)(working_dir)).replace(/\\/g, '/');
return path_1.normalize(path_1.resolve(working_dir)).replace(/\\/g, '/');
}
}
exports.FuncIgnore = FuncIgnore;
1 change: 0 additions & 1 deletion lib/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FuncIgnore = exports.Client = exports.Sleeper = exports.Parser = exports.Logger = void 0;
var logger_1 = require("./logger");
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
var parser_1 = require("./parser");
Expand Down

0 comments on commit 45adfe5

Please sign in to comment.