Skip to content

Commit

Permalink
Patelchandni/lima+deployid (#108)
Browse files Browse the repository at this point in the history
* npm update to latest and single deployment id

* if RBAC, then appService is used, else kuduService for getting app settings

* Updating npm packages

* fix .gitignore

* Update lib files

Co-authored-by: Ahmed ElSayed <[email protected]>
  • Loading branch information
patelchandni and ahmelsayed authored Sep 22, 2021
1 parent 653e5ab commit 05f10fa
Show file tree
Hide file tree
Showing 69 changed files with 16,379 additions and 801 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# Github Actions master branch will not have node_modules (use v1 instead)
lib/
node_modules/
tests/temp/*.zip

# Tests
Expand Down
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 = utility_js_1.generateTemporaryFolderOrZipPath(process.env.RUNNER_TEMP, false);
const tempoaryFilePath = (0, 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 ziputility_js_1.archiveFolder(sourceLocation, "", tempoaryFilePath);
return yield (0, 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 = path_1.resolve(packagePath, 'pom.xml');
if (!fs_1.existsSync(pomXmlPath)) {
const pomXmlPath = (0, path_1.resolve)(packagePath, 'pom.xml');
if (!(0, 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 = fs_1.readFileSync(pomXmlPath, 'utf8');
pomXmlContent = (0, 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 xml2js_1.parseString(pomXmlContent, (error, xmlResult) => {
yield (0, 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 = path_1.resolve(packagePath, 'target', 'azure-functions', functionAppName);
const pomPackagePath = (0, 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
4 changes: 2 additions & 2 deletions lib/handlers/parameterValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ParameterValidator {
return creds;
}
let xmlProfile = undefined;
yield xml2js_1.parseString(publishProfile, (error, xmlResult) => {
yield (0, 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");
Expand Down Expand Up @@ -150,7 +150,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 (!packageUtility_1.exist(this._packagePath)) {
if (!(0, 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 AnnotationUtility_1.addAnnotation(context.endpoint, context.appService, true);
yield (0, 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
1 change: 1 addition & 0 deletions lib/publishers/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"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 {
storage_blob_2.uploadFileToBlockBlob(storage_blob_1.Aborter.timeout(configuration_1.ConfigurationConstant.BlobUploadTimeoutMs), filePath, blockBlobURL, {
(0, 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 storage_blob_2.generateBlobSASQueryParameters(blobSasValues, credential).toString();
return (0, storage_blob_2.generateBlobSASQueryParameters)(blobSasValues, credential).toString();
}
static publishToFunctionapp(state, appService, blobSasUrl) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down
25 changes: 16 additions & 9 deletions lib/publishers/zipDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class ZipDeploy {
const originalAppSettings = context.appSettings;
try {
yield this.patchTemporaryAppSettings(context, enableOryxBuild, scmDobuildDuringDeployment);
deploymentId = yield context.kuduServiceUtil.deployUsingZipDeploy(filePath);
deploymentId = yield context.kuduServiceUtil.deployUsingZipDeploy(filePath, {
'slotName': context.appService ? context.appService.getSlot() : 'production'
});
isDeploymentSucceeded = true;
}
catch (expt) {
Expand All @@ -36,10 +38,6 @@ class ZipDeploy {
if (isDeploymentSucceeded) {
yield context.kuduServiceUtil.postZipDeployOperation(deploymentId, deploymentId);
}
yield context.kuduServiceUtil.updateDeploymentStatus(isDeploymentSucceeded, null, {
'type': 'Deployment',
'slotName': context.appService ? context.appService.getSlot() : 'production'
});
}
yield this.restoreScmTemporarySettings(context, originalAppSettings);
yield this.deleteScmTemporarySettings(context, originalAppSettings);
Expand Down Expand Up @@ -147,10 +145,19 @@ class ZipDeploy {
while (retryCount > 0) {
yield utils_1.Sleeper.timeout(retryInterval);
try {
const settings = yield context.kuduService.getAppSettings();
if (settings && settings[key] && settings[key] === expectedValue) {
isSuccess = true;
break;
if (context.authenticationType === authentication_type_1.AuthenticationType.Rbac) {
const settings = yield context.appService.getApplicationSettings();
if (settings && settings.properties[key] && settings.properties[key] === expectedValue) {
isSuccess = true;
break;
}
}
else {
const settings = yield context.kuduService.getAppSettings();
if (settings && settings[key] && settings[key] === expectedValue) {
isSuccess = true;
break;
}
}
}
catch (expt) {
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 = path_1.resolve(working_dir, '.funcignore');
return fs_1.existsSync(funcignorePath);
const funcignorePath = (0, path_1.resolve)(working_dir, '.funcignore');
return (0, fs_1.existsSync)(funcignorePath);
}
static readFuncignore(working_dir) {
const funcignorePath = path_1.resolve(working_dir, '.funcignore');
const rules = fs_1.readFileSync(funcignorePath).toString().split('\n').filter(l => l.trim() !== '');
const funcignorePath = (0, path_1.resolve)(working_dir, '.funcignore');
const rules = (0, 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 path_1.normalize(path_1.resolve(working_dir)).replace(/\\/g, '/');
return (0, path_1.normalize)((0, path_1.resolve)(working_dir)).replace(/\\/g, '/');
}
}
exports.FuncIgnore = FuncIgnore;
1 change: 1 addition & 0 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"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

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

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

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

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

Loading

0 comments on commit 05f10fa

Please sign in to comment.