@coalescesoftware/coa 1.0.100 → 1.0.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/CLIOperations.js +135 -0
- package/bin/CLIProfile.js +37 -13
- package/bin/{CommonCLI/CommonCLI.js → Common.js} +9 -28
- package/bin/Profile.js +53 -0
- package/bin/index.js +25 -20
- package/package.json +2 -2
- package/bin/CommonCLI/CommonCLI.test.js +0 -28
- package/bin/Deploy/Deploy.js +0 -70
- package/bin/Plan/Plan.js +0 -41
- package/bin/Refresh/Refresh.js +0 -65
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.DisableNonCLIConsoleLogs = exports.ExitCLISafe = exports.VerifyAllRefreshItems = exports.VerifyAllPlanItems = exports.VerifyAllDeployItems = void 0;
|
|
23
|
+
const Templates = __importStar(require("@coalescesoftware/shared/src/Templates"));
|
|
24
|
+
const R = __importStar(require("runtypes"));
|
|
25
|
+
const Logging = __importStar(require("@coalescesoftware/shared/src/Logging"));
|
|
26
|
+
const Firebase = __importStar(require("@coalescesoftware/shared/src/Firebase"));
|
|
27
|
+
const LogCLI = Logging.GetLogger(Logging.LoggingArea.CLI);
|
|
28
|
+
const UserCredentialsDeployType = R.Record({
|
|
29
|
+
snowflakeUsername: R.String,
|
|
30
|
+
snowflakePassword: R.String.optional(),
|
|
31
|
+
snowflakeRole: R.String.optional(),
|
|
32
|
+
snowflakeWarehouse: R.String.optional(),
|
|
33
|
+
});
|
|
34
|
+
const UserCredentialsRefreshType = R.Record({
|
|
35
|
+
snowflakePassword: R.String.optional(),
|
|
36
|
+
});
|
|
37
|
+
const BaseEnvironmentType = R.Record({
|
|
38
|
+
environmentID: R.Union(R.String, R.Number),
|
|
39
|
+
});
|
|
40
|
+
const EnvironmentRefreshType = BaseEnvironmentType.extend({
|
|
41
|
+
jobID: R.String.optional(),
|
|
42
|
+
});
|
|
43
|
+
const DeployConfig = R.Record({
|
|
44
|
+
token: userCredentials, UserCredentialsDeployType,
|
|
45
|
+
});
|
|
46
|
+
const RefreshConfig = R.Record({
|
|
47
|
+
userCredentials: UserCredentialsRefreshType,
|
|
48
|
+
runDetails: EnvironmentRefreshType,
|
|
49
|
+
});
|
|
50
|
+
const Plan = R.Record({
|
|
51
|
+
version: R.Number,
|
|
52
|
+
targetEnvironment: R.Number,
|
|
53
|
+
plan: R.Unknown,
|
|
54
|
+
environmentState: R.Unknown,
|
|
55
|
+
gitInfo: R.Unknown,
|
|
56
|
+
});
|
|
57
|
+
const PlanConfig = R.Record({
|
|
58
|
+
runDetails: BaseEnvironmentType,
|
|
59
|
+
});
|
|
60
|
+
const Token = R.String;
|
|
61
|
+
const VerifyAllDeployItems = (plan,
|
|
62
|
+
// TODO-AI: move coalesceToken out of usercredentials to one level higher
|
|
63
|
+
config, token) => {
|
|
64
|
+
const runTypesAndObjectsToVerify = [
|
|
65
|
+
{ runType: Plan, object: plan },
|
|
66
|
+
{ runType: DeployConfig, object: config },
|
|
67
|
+
{ runType: Token, object: token },
|
|
68
|
+
];
|
|
69
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
70
|
+
};
|
|
71
|
+
exports.VerifyAllDeployItems = VerifyAllDeployItems;
|
|
72
|
+
const VerifyAllPlanItems = (config) => {
|
|
73
|
+
const { coalescetoken: token } = config;
|
|
74
|
+
const runTypesAndObjectsToVerify = [
|
|
75
|
+
{ runType: PlanConfig, object: config },
|
|
76
|
+
{ runType: Token, object: token },
|
|
77
|
+
];
|
|
78
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
79
|
+
};
|
|
80
|
+
exports.VerifyAllPlanItems = VerifyAllPlanItems;
|
|
81
|
+
const VerifyAllRefreshItems = (config, token) => {
|
|
82
|
+
const runTypesAndObjectsToVerify = [
|
|
83
|
+
{ runType: RefreshConfig, object: config },
|
|
84
|
+
{ runType: Token, object: token },
|
|
85
|
+
];
|
|
86
|
+
return Templates.ValidateMultipleRunTypesAndReturnSuccessOrErrorMessages(runTypesAndObjectsToVerify);
|
|
87
|
+
};
|
|
88
|
+
exports.VerifyAllRefreshItems = VerifyAllRefreshItems;
|
|
89
|
+
/**
|
|
90
|
+
* Should be used in place of all process.exit() or process.exitCode = x instances. process.exit() kills all processes immediately and we lose logs and can
|
|
91
|
+
* cause other issues, process.exitCode = x will hang indefinitely if firebase apps aren't deleted first
|
|
92
|
+
* @param exitCode normal nodeJS exit code that would be passed to process.exit or process.exitCode
|
|
93
|
+
*/
|
|
94
|
+
const ExitCLISafe = (exitCode) => {
|
|
95
|
+
// force exit if FB fails to exit (or less likely, logs fail to send) in 5 seconds
|
|
96
|
+
const forceExitTimeout = setTimeout(() => {
|
|
97
|
+
LogCLI.alert("CLI exit timeout");
|
|
98
|
+
// inner timeout is so the above log can be sent to Datadog; proper methods for waiting on winston transports don't work on our datadog transport
|
|
99
|
+
setTimeout(() => process.exit(exitCode), 1000);
|
|
100
|
+
}, 5000);
|
|
101
|
+
try {
|
|
102
|
+
const firebase = Firebase.justFirebase;
|
|
103
|
+
// Firebase Apps is an App[]
|
|
104
|
+
if (firebase.apps.length) {
|
|
105
|
+
firebase.apps.forEach((app) => {
|
|
106
|
+
firebase.app(app.name).delete();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
clearTimeout(forceExitTimeout);
|
|
110
|
+
process.exitCode = exitCode;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
LogCLI.error("Error while attempting to close Firebase apps in CLI");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
exports.ExitCLISafe = ExitCLISafe;
|
|
117
|
+
const DisableNonCLIConsoleLogs = () => {
|
|
118
|
+
const allLoggersConfigs = {};
|
|
119
|
+
Object.values(Logging.LoggingArea).forEach(logArea => {
|
|
120
|
+
if (logArea !== Logging.LoggingArea.CLI) {
|
|
121
|
+
allLoggersConfigs[logArea] = {
|
|
122
|
+
level: Logging.LoggingAreas[logArea].level,
|
|
123
|
+
transports: [Logging.GetHttpTransport(), Logging.GetOurTransport()]
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
const CLIAreaInfo = Logging.LoggingAreas[Logging.LoggingArea.CLI];
|
|
128
|
+
allLoggersConfigs[Logging.LoggingArea.CLI] = {
|
|
129
|
+
level: CLIAreaInfo.level,
|
|
130
|
+
transports: Logging.GetDefaultTransports(CLIAreaInfo)
|
|
131
|
+
};
|
|
132
|
+
Logging.ReconfigureLoggers(allLoggersConfigs);
|
|
133
|
+
};
|
|
134
|
+
exports.DisableNonCLIConsoleLogs = DisableNonCLIConsoleLogs;
|
|
135
|
+
//# sourceMappingURL=CLIOperations.js.map
|
package/bin/CLIProfile.js
CHANGED
|
@@ -19,20 +19,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.GetCLIConfig = exports.ICLIProfileExample = void 0;
|
|
22
|
+
exports.GetCLIConfig = exports.ICLIProfileExample = exports.GetDefaultLocationForCoaConfigFile = void 0;
|
|
23
23
|
/* eslint-disable multiline-comment-style */
|
|
24
24
|
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
25
|
+
const immer = __importStar(require("immer"));
|
|
25
26
|
const os = require('os');
|
|
26
27
|
const path = require('path');
|
|
27
28
|
const ini = require('ini');
|
|
28
29
|
const fs = require('fs');
|
|
30
|
+
const RemoveCredentialsFromCLIProfile = (cliProfile) => {
|
|
31
|
+
return immer.produce(cliProfile, (draft) => {
|
|
32
|
+
if (draft.snowflakePassword)
|
|
33
|
+
draft.snowflakePassword = '<REDACTED>';
|
|
34
|
+
if (draft.snowflakeAccount)
|
|
35
|
+
draft.snowflakeAccount = '<REDACTED>';
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const RemoveCredentialsFromCLIProfiles = (cliProfiles) => {
|
|
39
|
+
return immer.produce(cliProfiles, (draftState) => {
|
|
40
|
+
Object.keys(draftState).forEach((cliProfileName) => {
|
|
41
|
+
draftState[cliProfileName] = RemoveCredentialsFromCLIProfile(cliProfiles[cliProfileName]);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
29
45
|
const CLILogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI_INTERNAL);
|
|
30
|
-
const
|
|
46
|
+
const GetDefaultLocationForCoaConfigFile = () => {
|
|
31
47
|
const homedir = os.homedir();
|
|
32
48
|
const coaConfigLocation = path.join(homedir, ".coa/config");
|
|
33
49
|
CLILogger.info("using default location", coaConfigLocation);
|
|
34
50
|
return coaConfigLocation;
|
|
35
51
|
};
|
|
52
|
+
exports.GetDefaultLocationForCoaConfigFile = GetDefaultLocationForCoaConfigFile;
|
|
36
53
|
//voodoo typescript magic in order to get runtime and compiletime ICLIProfile code
|
|
37
54
|
//https://stackoverflow.com/questions/45670705/iterate-over-interface-properties-in-typescript
|
|
38
55
|
exports.ICLIProfileExample = {
|
|
@@ -45,9 +62,12 @@ exports.ICLIProfileExample = {
|
|
|
45
62
|
snowflakeRole: "Snowflake Role",
|
|
46
63
|
snowflakeUsername: "Snowflake Username",
|
|
47
64
|
snowflakeWarehouse: "Snowflake Warehouse",
|
|
48
|
-
token: "Coalesce Token"
|
|
65
|
+
token: "Coalesce Token",
|
|
66
|
+
jobID: "Coalesce JobID",
|
|
67
|
+
include: "Coalesce Node Selector",
|
|
68
|
+
exclude: "Coalesce Node Selector"
|
|
49
69
|
};
|
|
50
|
-
const
|
|
70
|
+
const ReadCLIProfiles = (filePath) => {
|
|
51
71
|
return fs.promises.readFile(filePath, 'utf-8').then((file) => {
|
|
52
72
|
return ini.parse(file);
|
|
53
73
|
}).catch((err) => {
|
|
@@ -55,10 +75,9 @@ const readCLIProfiles = (filePath) => {
|
|
|
55
75
|
throw new Error("unable to read cli profile");
|
|
56
76
|
});
|
|
57
77
|
};
|
|
58
|
-
const
|
|
78
|
+
const GetFinalCLIProfile = (commandLineOverrides, configFileLocation) => {
|
|
59
79
|
let profileToUseOverride = commandLineOverrides.profile ? commandLineOverrides.profile : null;
|
|
60
|
-
|
|
61
|
-
return readCLIProfiles(defaultPath).then((cliProfiles) => {
|
|
80
|
+
return ReadCLIProfiles(configFileLocation).then((cliProfiles) => {
|
|
62
81
|
return cliProfiles;
|
|
63
82
|
}).catch((err) => {
|
|
64
83
|
//unable to read cli profiles
|
|
@@ -74,7 +93,7 @@ const getFinalCLIProfile = (commandLineOverrides) => {
|
|
|
74
93
|
const profileToUse = profileToUseOverride || //cli override
|
|
75
94
|
(!!defaultCLIProfile && defaultCLIProfile.profile) //default profile exists
|
|
76
95
|
|| "";
|
|
77
|
-
CLILogger.info("using profile", profileToUse, "cliProfiles", JSON.stringify(cliProfiles));
|
|
96
|
+
CLILogger.info("using profile", profileToUse, "cliProfiles", JSON.stringify(RemoveCredentialsFromCLIProfiles(cliProfiles)));
|
|
78
97
|
if (profileToUse) {
|
|
79
98
|
if (!(profileToUse in cliProfiles)) {
|
|
80
99
|
throw new Error(`unable to find profile ${profileToUse}`);
|
|
@@ -86,13 +105,16 @@ const getFinalCLIProfile = (commandLineOverrides) => {
|
|
|
86
105
|
return finalCLIProfile;
|
|
87
106
|
});
|
|
88
107
|
};
|
|
89
|
-
const GetCLIConfig = (commandLineOverrides) => {
|
|
90
|
-
return
|
|
91
|
-
CLILogger.info("got final cli profile", JSON.stringify(cliProfile));
|
|
92
|
-
|
|
108
|
+
const GetCLIConfig = (commandLineOverrides, configFileLocation) => {
|
|
109
|
+
return GetFinalCLIProfile(commandLineOverrides, configFileLocation).then((cliProfile) => {
|
|
110
|
+
CLILogger.info("got final cli profile configFileLocation:", configFileLocation, JSON.stringify(RemoveCredentialsFromCLIProfile(cliProfile)));
|
|
111
|
+
const cliConfig = {
|
|
93
112
|
token: cliProfile.token,
|
|
94
113
|
runDetails: {
|
|
95
|
-
environmentID: cliProfile.environmentID
|
|
114
|
+
environmentID: cliProfile.environmentID,
|
|
115
|
+
jobID: cliProfile.jobID,
|
|
116
|
+
includeNodesSelector: cliProfile.include,
|
|
117
|
+
excludeNodesSelector: cliProfile.exclude
|
|
96
118
|
},
|
|
97
119
|
userCredentials: {
|
|
98
120
|
snowflakeAccount: cliProfile.snowflakeAccount,
|
|
@@ -104,6 +126,8 @@ const GetCLIConfig = (commandLineOverrides) => {
|
|
|
104
126
|
snowflakeWarehouse: cliProfile.snowflakeWarehouse
|
|
105
127
|
}
|
|
106
128
|
};
|
|
129
|
+
Shared.Common.CleanupUndefinedValuesFromObject(cliConfig);
|
|
130
|
+
return cliConfig;
|
|
107
131
|
});
|
|
108
132
|
};
|
|
109
133
|
exports.GetCLIConfig = GetCLIConfig;
|
|
@@ -19,32 +19,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.GetUserConnectionForCLI = exports.CleanupCLIJob =
|
|
22
|
+
exports.GetUserConnectionForCLI = exports.CleanupCLIJob = void 0;
|
|
23
23
|
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
-
const crypto = __importStar(require("crypto"));
|
|
25
24
|
const fs = __importStar(require("fs"));
|
|
25
|
+
const crypto = __importStar(require("crypto"));
|
|
26
26
|
const RunnerBackendLogger = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.RunnerBackend);
|
|
27
|
-
exports.ConsoleLog = console.log;
|
|
28
|
-
const GetConfig = (path) => {
|
|
29
|
-
try {
|
|
30
|
-
return JSON.parse(fs.readFileSync(path, { encoding: "utf8" }));
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
(0, exports.ConsoleLog)(`Unable to read or parse config file: ${error}`);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.GetConfig = GetConfig;
|
|
38
|
-
const GetToken = (path) => {
|
|
39
|
-
try {
|
|
40
|
-
return fs.readFileSync(path, { encoding: "utf8" }).trim();
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
(0, exports.ConsoleLog)(`Unable to read token file: ${error}`);
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.GetToken = GetToken;
|
|
48
27
|
const CleanupCLIJob = (runCompletion, firebase, logContext, action) => {
|
|
49
28
|
const cleanupPromise = new Promise((resolve, reject) => {
|
|
50
29
|
let promiseError = null;
|
|
@@ -96,18 +75,20 @@ const GetKeyPairKey = (keyPairPath) => {
|
|
|
96
75
|
const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
97
76
|
return new Promise((resolve, reject) => {
|
|
98
77
|
var _a, _b, _c, _d;
|
|
99
|
-
Shared.Common.assert(Shared.Logging.LoggingArea.RunnerBackend, !!((_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeAuthType), "ERROR (GetUserConnectionForCLI): no auth type provided");
|
|
100
78
|
const output = {
|
|
101
79
|
connectionDetails: {
|
|
102
80
|
userID,
|
|
103
81
|
user: "mx2323",
|
|
104
82
|
role: "SYSADMIN",
|
|
105
83
|
warehouse: "COMPUTE_WH",
|
|
106
|
-
authenticator: (
|
|
84
|
+
authenticator: (_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeAuthType
|
|
107
85
|
},
|
|
108
|
-
connectionType: (
|
|
86
|
+
connectionType: (_b = runInfo.userCredentials) === null || _b === void 0 ? void 0 : _b.snowflakeAuthType
|
|
109
87
|
};
|
|
110
|
-
if (((
|
|
88
|
+
if (!((_c = runInfo.userCredentials) === null || _c === void 0 ? void 0 : _c.snowflakeAuthType)) {
|
|
89
|
+
reject(new Error("ERROR (GetUserConnectionForCLI): no auth type provided"));
|
|
90
|
+
}
|
|
91
|
+
else if (((_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType) === Shared.ConnectionOperations.EUserConnectionTypes.keyPair) {
|
|
111
92
|
GetKeyPairKey(Shared.Common.getValueSafe(runInfo, ["userCredentials", "snowflakeKeyPairPath"], ""))
|
|
112
93
|
.then((keyPair) => {
|
|
113
94
|
output.connectionDetails.keyPair = keyPair;
|
|
@@ -123,4 +104,4 @@ const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
|
123
104
|
});
|
|
124
105
|
};
|
|
125
106
|
exports.GetUserConnectionForCLI = GetUserConnectionForCLI;
|
|
126
|
-
//# sourceMappingURL=
|
|
107
|
+
//# sourceMappingURL=Common.js.map
|
package/bin/Profile.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable multiline-comment-style */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
6
|
+
}) : (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
o[k2] = m[k];
|
|
9
|
+
}));
|
|
10
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
11
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
12
|
+
}) : function(o, v) {
|
|
13
|
+
o["default"] = v;
|
|
14
|
+
});
|
|
15
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
|
+
if (mod && mod.__esModule) return mod;
|
|
17
|
+
var result = {};
|
|
18
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
19
|
+
__setModuleDefault(result, mod);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
+
const GetCLIConfigFromCLIProfile = (CLIProfile) => {
|
|
25
|
+
return {
|
|
26
|
+
token: "AIwUaOn1n7RzQXkyx6mwVO7x17s-agEgNHtIROspfSBx-QjsII6O9Kp7Qxpl_7TtjG3a59dq32VBeItGG5X6sN2kKmn54u-RMFxoJnZg0VXh3p1qM-0Palu7hVDiMIFuNdX2dyOQy2DK7WLjwbH6kXFrDQy8zLlDCKFGxzcMMNU3wp2TPtb2uxbZYtVcCqZg3be7Lr3esaKYhJLcKuW5lixc_JCAEhMjQw",
|
|
27
|
+
runDetails: {
|
|
28
|
+
environmentID: 2
|
|
29
|
+
},
|
|
30
|
+
userCredentials: {
|
|
31
|
+
snowflakeAccount: "ww56326.us-central1.gcp",
|
|
32
|
+
snowflakeAuthType: Shared.ConnectionOperations.EUserConnectionTypes.basic,
|
|
33
|
+
snowflakePassword: "ThisIsAPassword1!",
|
|
34
|
+
snowflakeRole: "SYSADMIN",
|
|
35
|
+
snowflakeUsername: "mx2323",
|
|
36
|
+
snowflakeWarehouse: "COMPUTE_WH"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
// TODO: create a profile class that takes the cmd object in the constructor
|
|
41
|
+
// store contents of configuration file
|
|
42
|
+
// if no config file path option
|
|
43
|
+
// check if there's a valid configuration file in the current working directory or home directory
|
|
44
|
+
// if none exists
|
|
45
|
+
// create a configuration file with empty default profile
|
|
46
|
+
// prompt user to either rerun the command with valid config file, per-command flags for all profile values, or run `coa init` to go through prompts for creating a profile
|
|
47
|
+
// if a configuration file exists, but any required property holds a falsy value
|
|
48
|
+
// inform user which fields are missing and prompt to run `coa init` to fill out invalid fields
|
|
49
|
+
// method: validate configuration file
|
|
50
|
+
// method: get final profile for current command
|
|
51
|
+
// create a function getCLIProfile that returns a CLI profile, this should return a promise that resolve in CLI profile
|
|
52
|
+
// hardcode a profile
|
|
53
|
+
//# sourceMappingURL=Profile.js.map
|
package/bin/index.js
CHANGED
|
@@ -39,7 +39,8 @@ const LogCLIInternal = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI_I
|
|
|
39
39
|
const program = new commander_1.Command();
|
|
40
40
|
program.version(require("../package.json").version, "-v, --version");
|
|
41
41
|
program.option("-b, --debug", "Output extra debugging", false);
|
|
42
|
-
|
|
42
|
+
program.option("--config <coa-config-location>", "coa config file location", CLIProfile.GetDefaultLocationForCoaConfigFile());
|
|
43
|
+
const AddOverridesToCommand = (command) => {
|
|
43
44
|
Object.keys(CLIProfile.ICLIProfileExample).forEach((key) => {
|
|
44
45
|
command.option(`--${key} <value>`, CLIProfile.ICLIProfileExample[key], "");
|
|
45
46
|
});
|
|
@@ -47,14 +48,13 @@ const addOverridesToCommand = (command) => {
|
|
|
47
48
|
};
|
|
48
49
|
//computeCLIOverrides returns an object that has a value if any of them have been specified at the command line
|
|
49
50
|
//this is used as the final override when getting a CLIConfig
|
|
50
|
-
const
|
|
51
|
+
const ComputeCLIOverrides = (command) => {
|
|
51
52
|
let overrides = {};
|
|
52
53
|
Object.keys(CLIProfile.ICLIProfileExample).forEach((key) => {
|
|
53
54
|
const source = command.getOptionValueSource(key);
|
|
54
|
-
if (source ==
|
|
55
|
+
if (source == "cli") {
|
|
55
56
|
overrides[key] = command.getOptionValue(key);
|
|
56
57
|
}
|
|
57
|
-
return overrides;
|
|
58
58
|
});
|
|
59
59
|
return overrides;
|
|
60
60
|
};
|
|
@@ -68,12 +68,12 @@ program.command("none", { hidden: true, isDefault: true })
|
|
|
68
68
|
/**
|
|
69
69
|
* Plan command is responsible for reading files and creating a Coalesce Deployment Plan
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
AddOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Plan))
|
|
72
72
|
.option("-d, --dir <dir>", "Coalesce pipeline Yaml file path", ".")
|
|
73
73
|
.option("--out <plan-location>", "Coalesce plan location", "./coa-plan.json")
|
|
74
74
|
.description("plan a Coalesce deployment")
|
|
75
75
|
.action((options, cmd) => {
|
|
76
|
-
const cliOverrides =
|
|
76
|
+
const cliOverrides = ComputeCLIOverrides(cmd);
|
|
77
77
|
const optsWithGlobals = cmd.optsWithGlobals();
|
|
78
78
|
const directoryPath = optsWithGlobals.dir;
|
|
79
79
|
let logContextToUse;
|
|
@@ -89,7 +89,7 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Plan))
|
|
|
89
89
|
Shared.CLIOperations.DisableNonCLIConsoleLogs();
|
|
90
90
|
}
|
|
91
91
|
let config;
|
|
92
|
-
return CLIProfile.GetCLIConfig(cliOverrides)
|
|
92
|
+
return CLIProfile.GetCLIConfig(cliOverrides, optsWithGlobals.config)
|
|
93
93
|
.then((configResult) => {
|
|
94
94
|
config = configResult;
|
|
95
95
|
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(config.token, undefined);
|
|
@@ -118,11 +118,11 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Plan))
|
|
|
118
118
|
/**
|
|
119
119
|
* Deploy command is responsible for taking an already generated plan, and executing it
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
AddOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Deploy))
|
|
122
122
|
.option("-p, --plan <plan-location>", "Coalesce plan location", "./coa-plan.json")
|
|
123
123
|
.description("run a coalesce deployment plan")
|
|
124
124
|
.action((options, cmd) => {
|
|
125
|
-
const cliOverrides =
|
|
125
|
+
const cliOverrides = ComputeCLIOverrides(cmd);
|
|
126
126
|
const optsWithGlobals = cmd.optsWithGlobals();
|
|
127
127
|
const plan = JSON.parse(fs_1.default.readFileSync(optsWithGlobals.plan, { encoding: "utf-8" }));
|
|
128
128
|
// const config = JSON.parse(fs.readFileSync(cmd.config, { encoding: "utf-8" }))
|
|
@@ -140,7 +140,7 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Deploy))
|
|
|
140
140
|
let logContextToUse;
|
|
141
141
|
let runInfo;
|
|
142
142
|
let config;
|
|
143
|
-
return CLIProfile.GetCLIConfig(cliOverrides)
|
|
143
|
+
return CLIProfile.GetCLIConfig(cliOverrides, optsWithGlobals.config)
|
|
144
144
|
.then((configResult) => {
|
|
145
145
|
config = configResult;
|
|
146
146
|
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(config.token, undefined);
|
|
@@ -168,7 +168,7 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Deploy))
|
|
|
168
168
|
Shared.CLIOperations.ExitCLISafe(0);
|
|
169
169
|
})
|
|
170
170
|
.catch(error => {
|
|
171
|
-
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright(`An error occurred during deployment ${error}`));
|
|
171
|
+
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright(`An error occurred during deployment ${error.toString()}`));
|
|
172
172
|
Shared.CLIOperations.ExitCLISafe(1);
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -176,10 +176,10 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Deploy))
|
|
|
176
176
|
/**
|
|
177
177
|
* Refresh command begins a locally executed Coalesce Environment Run
|
|
178
178
|
*/
|
|
179
|
-
|
|
179
|
+
AddOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Refresh))
|
|
180
180
|
.description("runs a Coalesce pipeline")
|
|
181
181
|
.action((options, command) => {
|
|
182
|
-
const cliOverrides =
|
|
182
|
+
const cliOverrides = ComputeCLIOverrides(command);
|
|
183
183
|
const optsWithGlobals = command.optsWithGlobals();
|
|
184
184
|
//const token = fs.readFileSync(cmd.token, { encoding: "utf8" })
|
|
185
185
|
//const config = JSON.parse(fs.readFileSync(cmd.config, { encoding: "utf8" }))
|
|
@@ -201,21 +201,26 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Refresh)
|
|
|
201
201
|
//WHY DO WE HAVE THIS CONFIG?
|
|
202
202
|
let runInfo;
|
|
203
203
|
let config;
|
|
204
|
-
return CLIProfile.GetCLIConfig(cliOverrides)
|
|
204
|
+
return CLIProfile.GetCLIConfig(cliOverrides, optsWithGlobals.config)
|
|
205
205
|
.then((configResult) => {
|
|
206
206
|
config = configResult;
|
|
207
207
|
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(config.token, undefined);
|
|
208
|
-
})
|
|
208
|
+
})
|
|
209
|
+
.then(({ teamInfo }) => {
|
|
209
210
|
Shared.Logging.SetBackendGlobalContext({ userID: teamInfo.fbUserID, orgID: teamInfo.fbTeamID });
|
|
210
211
|
runInfo = {
|
|
211
212
|
runType: Shared.Runner.ERunType.refresh,
|
|
212
213
|
runStatus: Shared.Runner.ERunStatus.running,
|
|
213
214
|
runDetails: {
|
|
214
|
-
environmentID: config.runDetails.environmentID
|
|
215
|
+
environmentID: config.runDetails.environmentID,
|
|
216
|
+
jobID: config.runDetails.jobID,
|
|
217
|
+
includeNodesSelector: config.runDetails.includeNodesSelector,
|
|
218
|
+
excludeNodesSelector: config.runDetails.excludeNodesSelector
|
|
215
219
|
},
|
|
216
220
|
userCredentials: config.userCredentials,
|
|
217
221
|
runTimeParameters: {}
|
|
218
222
|
};
|
|
223
|
+
Shared.Common.CleanupUndefinedValuesFromObject(runInfo);
|
|
219
224
|
LogCLIInternal.infoContext(logContextToUse, "cliOverrides", cliOverrides);
|
|
220
225
|
LogCLIInternal.infoContext(logContextToUse, "got the cli config", config);
|
|
221
226
|
LogCLIInternal.infoContext(logContextToUse, "got the run info", config);
|
|
@@ -230,11 +235,11 @@ addOverridesToCommand(program.command(Shared.CLIOperations.ECLICommands.Refresh)
|
|
|
230
235
|
.then(() => {
|
|
231
236
|
LogCLI.infoContext(logContextToUse, "Refresh successful!");
|
|
232
237
|
Shared.CLIOperations.ExitCLISafe(0);
|
|
233
|
-
})
|
|
234
|
-
.catch(error => {
|
|
235
|
-
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright(`Error during refresh!: ${error.toString()}`));
|
|
236
|
-
Shared.CLIOperations.ExitCLISafe(1);
|
|
237
238
|
});
|
|
239
|
+
})
|
|
240
|
+
.catch(error => {
|
|
241
|
+
LogCLI.errorContext(logContextToUse, chalk_1.default.redBright(`Error during refresh!: ${error.toString()}`));
|
|
242
|
+
Shared.CLIOperations.ExitCLISafe(1);
|
|
238
243
|
});
|
|
239
244
|
});
|
|
240
245
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coalescesoftware/coa",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Coalesce Automation, Inc.",
|
|
6
6
|
"main": "index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"start-cli-debug": "yarn run start --debug"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@coalescesoftware/shared": "^1.0.
|
|
15
|
+
"@coalescesoftware/shared": "^1.0.112",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
17
|
"commander": "^9.2.0",
|
|
18
18
|
"firebase": "8.2.0",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const CommonCLI = __importStar(require("./CommonCLI"));
|
|
23
|
-
test("should fail to read and parse invalid JSON", () => {
|
|
24
|
-
expect(() => {
|
|
25
|
-
CommonCLI.GetConfig("cli/src/__mocks__/invalid.json");
|
|
26
|
-
}).toThrow("Unexpected token I in JSON at position 0");
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=CommonCLI.test.js.map
|
package/bin/Deploy/Deploy.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.DeployWithCLI = void 0;
|
|
23
|
-
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
-
const CommonCLI = __importStar(require("../CommonCLI/CommonCLI"));
|
|
25
|
-
const CryptoJS = require("crypto-js");
|
|
26
|
-
const v8 = require("v8");
|
|
27
|
-
Shared.Snowflake.CryptoJS = CryptoJS;
|
|
28
|
-
Shared.Snowflake.salt = CryptoJS.lib.WordArray.random(128 / 8);
|
|
29
|
-
Shared.Snowflake.v8 = v8;
|
|
30
|
-
const LogCLI = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI);
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param plan
|
|
34
|
-
* @param config
|
|
35
|
-
* @param token
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
const DeployWithCLI = (plan, config, token) => {
|
|
39
|
-
let firebase;
|
|
40
|
-
let logContext;
|
|
41
|
-
let teamDetailsStored, runInfo, RunSQL;
|
|
42
|
-
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token, undefined)
|
|
43
|
-
.then((teamDetails) => {
|
|
44
|
-
var _a;
|
|
45
|
-
teamDetailsStored = teamDetails;
|
|
46
|
-
const { teamInfo, teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamDetails;
|
|
47
|
-
firebase = teamDetails.firebase;
|
|
48
|
-
const environmentID = (_a = config.runDetails) === null || _a === void 0 ? void 0 : _a.environmentID;
|
|
49
|
-
logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
|
|
50
|
-
const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
|
|
51
|
-
RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamDetails, connectionCache);
|
|
52
|
-
runInfo = Shared.DeployOperations.CreateDeployRequestObject(plan.plan, plan.environmentState, teamInfo, plan.gitInfo, plan.targetEnvironment, "");
|
|
53
|
-
runInfo.userCredentials = config.userCredentials;
|
|
54
|
-
return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
|
|
55
|
-
})
|
|
56
|
-
.then((connection) => {
|
|
57
|
-
LogCLI.infoContext(logContext, "Deploy starting (CLI)");
|
|
58
|
-
return Shared.SchedulerOperations.HandleDeploy(runInfo, teamDetailsStored, RunSQL, connection);
|
|
59
|
-
})
|
|
60
|
-
.then(({ runCounter, runCompletion }) => {
|
|
61
|
-
const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Deploy");
|
|
62
|
-
return {
|
|
63
|
-
runCounter,
|
|
64
|
-
runCompletion: cleanupPromise,
|
|
65
|
-
logContext,
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
exports.DeployWithCLI = DeployWithCLI;
|
|
70
|
-
//# sourceMappingURL=Deploy.js.map
|
package/bin/Plan/Plan.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.CreatePlan = void 0;
|
|
26
|
-
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
27
|
-
const fs_1 = __importDefault(require("fs"));
|
|
28
|
-
const CreatePlan = (path, environmentID, token, message) => {
|
|
29
|
-
const fsSettings = {
|
|
30
|
-
fs: fs_1.default,
|
|
31
|
-
dir: path,
|
|
32
|
-
};
|
|
33
|
-
return Shared.DeployOperations.CreatePlanCLI(environmentID, fsSettings, token, Shared.Templates.PlatformType.snowflake)
|
|
34
|
-
.then(result => {
|
|
35
|
-
const { plan } = result;
|
|
36
|
-
plan.gitInfo = { commit: { message: message }, oid: "" };
|
|
37
|
-
return result;
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.CreatePlan = CreatePlan;
|
|
41
|
-
//# sourceMappingURL=Plan.js.map
|
package/bin/Refresh/Refresh.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.RefreshWithCLI = void 0;
|
|
23
|
-
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
|
-
const CommonCLI = __importStar(require("../CommonCLI/CommonCLI"));
|
|
25
|
-
const CryptoJS = require("crypto-js");
|
|
26
|
-
const v8 = require("v8");
|
|
27
|
-
Shared.Snowflake.CryptoJS = CryptoJS;
|
|
28
|
-
Shared.Snowflake.salt = CryptoJS.lib.WordArray.random(128 / 8);
|
|
29
|
-
Shared.Snowflake.v8 = v8;
|
|
30
|
-
const LogCLI = Shared.Logging.GetLogger(Shared.Logging.LoggingArea.CLI);
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param token
|
|
34
|
-
* @param runInfo
|
|
35
|
-
* @returns
|
|
36
|
-
*/
|
|
37
|
-
const RefreshWithCLI = (token, runInfo) => {
|
|
38
|
-
let firebase;
|
|
39
|
-
let logContext;
|
|
40
|
-
let RunSQL, teamDetails;
|
|
41
|
-
return Shared.SchedulerOperations.AuthenticateFirebaseTokenAndRetrieveTeamInfoForCLI(token, undefined)
|
|
42
|
-
.then((teamInfoAndFirebase) => {
|
|
43
|
-
const { teamInfo: { fbUserID: userID, fbTeamID: teamID } } = teamInfoAndFirebase;
|
|
44
|
-
firebase = teamInfoAndFirebase.firebase;
|
|
45
|
-
const environmentID = runInfo.runDetails.environmentID;
|
|
46
|
-
logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
|
|
47
|
-
const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
|
|
48
|
-
RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamInfoAndFirebase, connectionCache);
|
|
49
|
-
LogCLI.infoContext(logContext, "Starting refresh (CLI)");
|
|
50
|
-
return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
|
|
51
|
-
})
|
|
52
|
-
.then((connection) => {
|
|
53
|
-
return Shared.SchedulerOperations.HandleRefresh(runInfo, teamDetails, RunSQL, connection);
|
|
54
|
-
})
|
|
55
|
-
.then(({ runCounter, runCompletion }) => {
|
|
56
|
-
const cleanupPromise = CommonCLI.CleanupCLIJob(runCompletion, firebase, logContext, "Refresh");
|
|
57
|
-
return {
|
|
58
|
-
runCounter,
|
|
59
|
-
runCompletion: cleanupPromise,
|
|
60
|
-
logContext,
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
exports.RefreshWithCLI = RefreshWithCLI;
|
|
65
|
-
//# sourceMappingURL=Refresh.js.map
|