Skip to content

Commit 72a0ca5

Browse files
author
Hanzhang Zeng (Roger)
committed
Release v1.2.1
1 parent d6d2dee commit 72a0ca5

File tree

7,947 files changed

+1674995
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,947 files changed

+1674995
-338
lines changed

.gitignore

+336-338
Large diffs are not rendered by default.

lib/constants/authentication_type.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.AuthenticationType = void 0;
4+
var AuthenticationType;
5+
(function (AuthenticationType) {
6+
AuthenticationType[AuthenticationType["Rbac"] = 1] = "Rbac";
7+
AuthenticationType[AuthenticationType["Scm"] = 2] = "Scm";
8+
})(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));

lib/constants/configuration.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.ConfigurationConstant = void 0;
4+
class ConfigurationConstant {
5+
}
6+
exports.ConfigurationConstant = ConfigurationConstant;
7+
ConfigurationConstant.ParamInAppName = 'app-name';
8+
ConfigurationConstant.ParamInPackagePath = 'package';
9+
ConfigurationConstant.ParamInSlot = 'slot-name';
10+
ConfigurationConstant.ParamInPublishProfile = 'publish-profile';
11+
ConfigurationConstant.ParamInRespectPomXml = 'respect-pom-xml';
12+
ConfigurationConstant.ParamInRespectFuncignore = 'respect-funcignore';
13+
ConfigurationConstant.ParamOutResultName = 'app-url';
14+
ConfigurationConstant.ActionName = 'DeployFunctionAppToAzure';
15+
ConfigurationConstant.BlobContainerName = 'github-actions-deploy';
16+
ConfigurationConstant.BlobNamePrefix = 'Functionapp';
17+
ConfigurationConstant.BlobServiceTimeoutMs = 3 * 1000;
18+
ConfigurationConstant.BlobUploadTimeoutMs = 30 * 60 * 1000;
19+
ConfigurationConstant.BlobUploadBlockSizeByte = 4 * 1024 * 1024;
20+
ConfigurationConstant.BlobUplaodBlockParallel = 4;
21+
ConfigurationConstant.BlobPermission = 'r';
22+
ConfigurationConstant.ProductionSlotName = 'production';

lib/constants/function_runtime.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.FunctionRuntimeUtil = exports.FunctionRuntimeConstant = void 0;
4+
const exceptions_1 = require("../exceptions");
5+
var FunctionRuntimeConstant;
6+
(function (FunctionRuntimeConstant) {
7+
FunctionRuntimeConstant[FunctionRuntimeConstant["None"] = 1] = "None";
8+
FunctionRuntimeConstant[FunctionRuntimeConstant["Dotnet"] = 2] = "Dotnet";
9+
FunctionRuntimeConstant[FunctionRuntimeConstant["Node"] = 3] = "Node";
10+
FunctionRuntimeConstant[FunctionRuntimeConstant["Powershell"] = 4] = "Powershell";
11+
FunctionRuntimeConstant[FunctionRuntimeConstant["Java"] = 5] = "Java";
12+
FunctionRuntimeConstant[FunctionRuntimeConstant["Python"] = 6] = "Python";
13+
FunctionRuntimeConstant[FunctionRuntimeConstant["Custom"] = 7] = "Custom";
14+
})(FunctionRuntimeConstant = exports.FunctionRuntimeConstant || (exports.FunctionRuntimeConstant = {}));
15+
class FunctionRuntimeUtil {
16+
static FromString(language) {
17+
if (language === undefined) {
18+
return FunctionRuntimeConstant.None;
19+
}
20+
const key = language.charAt(0).toUpperCase() + language.toLowerCase().slice(1);
21+
const result = FunctionRuntimeConstant[key];
22+
if (result === undefined) {
23+
throw new exceptions_1.UnexpectedConversion('FunctionRuntimeConstant', language);
24+
}
25+
return result;
26+
}
27+
}
28+
exports.FunctionRuntimeUtil = FunctionRuntimeUtil;

lib/constants/function_sku.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.FunctionSkuUtil = exports.FunctionSkuConstant = void 0;
4+
var FunctionSkuConstant;
5+
(function (FunctionSkuConstant) {
6+
FunctionSkuConstant[FunctionSkuConstant["Consumption"] = 1] = "Consumption";
7+
FunctionSkuConstant[FunctionSkuConstant["Dedicated"] = 2] = "Dedicated";
8+
FunctionSkuConstant[FunctionSkuConstant["ElasticPremium"] = 3] = "ElasticPremium";
9+
})(FunctionSkuConstant = exports.FunctionSkuConstant || (exports.FunctionSkuConstant = {}));
10+
class FunctionSkuUtil {
11+
static FromString(sku) {
12+
const skuLowercasedString = sku.trim().toLowerCase();
13+
if (skuLowercasedString.startsWith('dynamic')) {
14+
return FunctionSkuConstant.Consumption;
15+
}
16+
if (skuLowercasedString.startsWith('elasticpremium')) {
17+
return FunctionSkuConstant.ElasticPremium;
18+
}
19+
return FunctionSkuConstant.Dedicated;
20+
}
21+
}
22+
exports.FunctionSkuUtil = FunctionSkuUtil;

lib/constants/log_level.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.LogLevelConstant = void 0;
4+
var LogLevelConstant;
5+
(function (LogLevelConstant) {
6+
LogLevelConstant[LogLevelConstant["Debug"] = 1] = "Debug";
7+
LogLevelConstant[LogLevelConstant["Info"] = 2] = "Info";
8+
LogLevelConstant[LogLevelConstant["Warning"] = 3] = "Warning";
9+
LogLevelConstant[LogLevelConstant["Error"] = 4] = "Error";
10+
LogLevelConstant[LogLevelConstant["Off"] = 5] = "Off";
11+
})(LogLevelConstant = exports.LogLevelConstant || (exports.LogLevelConstant = {}));

lib/constants/publish_method.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.PublishMethodConstant = void 0;
4+
var PublishMethodConstant;
5+
(function (PublishMethodConstant) {
6+
// Using api/zipdeploy endpoint in scm site
7+
PublishMethodConstant[PublishMethodConstant["ZipDeploy"] = 1] = "ZipDeploy";
8+
// Setting WEBSITE_RUN_FROM_PACKAGE app setting
9+
PublishMethodConstant[PublishMethodConstant["WebsiteRunFromPackageDeploy"] = 2] = "WebsiteRunFromPackageDeploy";
10+
})(PublishMethodConstant = exports.PublishMethodConstant || (exports.PublishMethodConstant = {}));

lib/constants/runtime_stack.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.RuntimeStackUtil = exports.RuntimeStackConstant = void 0;
4+
const exceptions_1 = require("../exceptions");
5+
var RuntimeStackConstant;
6+
(function (RuntimeStackConstant) {
7+
RuntimeStackConstant[RuntimeStackConstant["Unknown"] = 0] = "Unknown";
8+
RuntimeStackConstant[RuntimeStackConstant["Windows"] = 1] = "Windows";
9+
RuntimeStackConstant[RuntimeStackConstant["Linux"] = 2] = "Linux";
10+
})(RuntimeStackConstant = exports.RuntimeStackConstant || (exports.RuntimeStackConstant = {}));
11+
class RuntimeStackUtil {
12+
static FromString(osType) {
13+
if (!osType) {
14+
return RuntimeStackConstant.Unknown;
15+
}
16+
const key = osType.charAt(0).toUpperCase() + osType.toLowerCase().slice(1);
17+
const result = RuntimeStackConstant[key];
18+
if (result === undefined) {
19+
throw new exceptions_1.UnexpectedConversion("RuntimeStackConstant", osType);
20+
}
21+
return result;
22+
}
23+
}
24+
exports.RuntimeStackUtil = RuntimeStackUtil;

lib/constants/state.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.StateConstant = void 0;
4+
var StateConstant;
5+
(function (StateConstant) {
6+
// State when initialize Github Action
7+
StateConstant[StateConstant["Initialize"] = 1] = "Initialize";
8+
// Get & Check the parameter from action.yml
9+
StateConstant[StateConstant["ValidateParameter"] = 2] = "ValidateParameter";
10+
// Get & Check if the resources does exist
11+
StateConstant[StateConstant["ValidateAzureResource"] = 3] = "ValidateAzureResource";
12+
// Zip content and choose the proper deployment method
13+
StateConstant[StateConstant["PreparePublishContent"] = 4] = "PreparePublishContent";
14+
// Publish content to Azure Functionapps
15+
StateConstant[StateConstant["PublishContent"] = 5] = "PublishContent";
16+
// Validate if the content has been published successfully
17+
StateConstant[StateConstant["ValidatePublishedContent"] = 6] = "ValidatePublishedContent";
18+
// End state with success
19+
StateConstant[StateConstant["Succeeded"] = 7] = "Succeeded";
20+
// End state with failure
21+
StateConstant[StateConstant["Failed"] = 8] = "Failed";
22+
})(StateConstant = exports.StateConstant || (exports.StateConstant = {}));

lib/exceptions.js

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.AzureResourceError = exports.WebRequestError = exports.FileIOError = exports.ValidationError = exports.ChangeContextException = exports.ChangeParamsException = exports.InvocationException = exports.ExecutionException = exports.UnexpectedConversion = exports.UnexpectedExitException = exports.NotImplementedException = exports.BaseException = void 0;
4+
const state_1 = require("./constants/state");
5+
class BaseException extends Error {
6+
constructor(message = undefined, innerException = undefined) {
7+
super();
8+
this._innerException = innerException ? innerException : undefined;
9+
this.message = message ? message : "";
10+
}
11+
GetInnerException() {
12+
return this._innerException;
13+
}
14+
GetTraceback() {
15+
let errorMessages = [this.message];
16+
let innerException = this._innerException;
17+
while (innerException !== undefined && innerException instanceof BaseException) {
18+
errorMessages.push(innerException.message);
19+
innerException = innerException._innerException;
20+
}
21+
if (innerException !== undefined && innerException instanceof Error) {
22+
errorMessages.push(innerException.message);
23+
errorMessages.push(innerException.stack);
24+
}
25+
else if (innerException !== undefined) {
26+
errorMessages.push(String(innerException));
27+
}
28+
return errorMessages;
29+
}
30+
PrintTraceback(printer) {
31+
const traceback = this.GetTraceback();
32+
for (let i = 0; i < traceback.length; i++) {
33+
const prefix = " ".repeat(i * 2);
34+
printer(`${prefix}${traceback[i]}`);
35+
}
36+
}
37+
}
38+
exports.BaseException = BaseException;
39+
class NotImplementedException extends BaseException {
40+
}
41+
exports.NotImplementedException = NotImplementedException;
42+
class UnexpectedExitException extends BaseException {
43+
constructor(state = state_1.StateConstant.Failed) {
44+
super(state_1.StateConstant[state]);
45+
}
46+
}
47+
exports.UnexpectedExitException = UnexpectedExitException;
48+
class UnexpectedConversion extends BaseException {
49+
constructor(constantField, value) {
50+
super(`Failed to convert ${value} to ${constantField}`);
51+
}
52+
}
53+
exports.UnexpectedConversion = UnexpectedConversion;
54+
class ExecutionException extends BaseException {
55+
constructor(state, executionStage, innerException) {
56+
let errorMessage = `Execution Exception (state: ${state_1.StateConstant[state]})`;
57+
if (executionStage !== undefined) {
58+
errorMessage += ` (step: ${executionStage})`;
59+
}
60+
super(errorMessage, innerException);
61+
}
62+
}
63+
exports.ExecutionException = ExecutionException;
64+
class InvocationException extends ExecutionException {
65+
constructor(state, innerException) {
66+
super(state, "Invocation", innerException);
67+
}
68+
}
69+
exports.InvocationException = InvocationException;
70+
class ChangeParamsException extends ExecutionException {
71+
constructor(state, innerException) {
72+
super(state, "ChangeParams", innerException);
73+
}
74+
}
75+
exports.ChangeParamsException = ChangeParamsException;
76+
class ChangeContextException extends ExecutionException {
77+
constructor(state, innerException) {
78+
super(state, "ChangeContext", innerException);
79+
}
80+
}
81+
exports.ChangeContextException = ChangeContextException;
82+
class ValidationError extends BaseException {
83+
constructor(state, field, expectation, innerException) {
84+
super(`At ${state_1.StateConstant[state]}, ${field} : ${expectation}.`, innerException);
85+
}
86+
}
87+
exports.ValidationError = ValidationError;
88+
class FileIOError extends BaseException {
89+
constructor(state, action, message, innerException) {
90+
super(`When performing file operation at ${state_1.StateConstant[state]}, ${action} : ${message}`, innerException);
91+
}
92+
}
93+
exports.FileIOError = FileIOError;
94+
class WebRequestError extends BaseException {
95+
constructor(url, verb, message, innerException) {
96+
super(`When [${verb}] ${url}, error: ${message}`, innerException);
97+
}
98+
}
99+
exports.WebRequestError = WebRequestError;
100+
class AzureResourceError extends BaseException {
101+
constructor(state, action, message, innerException) {
102+
super(`When request Azure resource at ${state_1.StateConstant[state]}, ${action} : ${message}`, innerException);
103+
}
104+
}
105+
exports.AzureResourceError = AzureResourceError;

0 commit comments

Comments
 (0)