@coalescesoftware/coa 1.0.113 → 1.0.116
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/CLIProfile.js +22 -10
- package/bin/CommonCLI.js +26 -6
- package/bin/Deploy.js +1 -1
- package/bin/Package.js +758 -0
- package/bin/Plan.js +2 -2
- package/bin/index.js +256 -27
- package/package.json +3 -2
- package/bin/CommonCLI/CommonCLI.js +0 -126
- 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
package/bin/CLIProfile.js
CHANGED
|
@@ -55,6 +55,7 @@ exports.GetDefaultLocationForCoaConfigFile = GetDefaultLocationForCoaConfigFile;
|
|
|
55
55
|
exports.ICLIProfileExample = {
|
|
56
56
|
profile: "Profile To Use",
|
|
57
57
|
environmentID: "Environment ID",
|
|
58
|
+
parameters: "Parameters",
|
|
58
59
|
snowflakeAccount: "Snowflake Account To Use",
|
|
59
60
|
snowflakeAuthType: "Snowflake Auth Type (Basic, KeyPair)",
|
|
60
61
|
snowflakeKeyPairPath: "Snowflake Key Pair Path",
|
|
@@ -68,21 +69,29 @@ exports.ICLIProfileExample = {
|
|
|
68
69
|
exclude: "Coalesce Node Selector"
|
|
69
70
|
};
|
|
70
71
|
const ReadCLIProfiles = (filePath) => {
|
|
71
|
-
|
|
72
|
+
let filePathToUse;
|
|
73
|
+
if (!filePath) {
|
|
74
|
+
filePathToUse = (0, exports.GetDefaultLocationForCoaConfigFile)();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
filePathToUse = filePath;
|
|
78
|
+
}
|
|
79
|
+
return fs.promises.readFile(filePathToUse, 'utf-8')
|
|
80
|
+
.then((file) => {
|
|
72
81
|
return ini.parse(file);
|
|
73
|
-
})
|
|
82
|
+
})
|
|
83
|
+
.catch((err) => {
|
|
74
84
|
CLILogger.error("unable to read cli profile file filePath:", filePath, err);
|
|
75
|
-
|
|
85
|
+
if (!filePath) //if no filepath was specified, silently proceed
|
|
86
|
+
return {};
|
|
87
|
+
else //unable to proceed couldnt read file
|
|
88
|
+
throw new Error(`unable to read cli profile:${filePathToUse}`);
|
|
76
89
|
});
|
|
77
90
|
};
|
|
78
91
|
const GetFinalCLIProfile = (commandLineOverrides, configFileLocation) => {
|
|
79
92
|
let profileToUseOverride = commandLineOverrides.profile ? commandLineOverrides.profile : null;
|
|
80
|
-
return ReadCLIProfiles(configFileLocation)
|
|
81
|
-
|
|
82
|
-
}).catch((err) => {
|
|
83
|
-
//unable to read cli profiles
|
|
84
|
-
return {};
|
|
85
|
-
}).then((cliProfiles) => {
|
|
93
|
+
return ReadCLIProfiles(configFileLocation)
|
|
94
|
+
.then((cliProfiles) => {
|
|
86
95
|
const defaultCLIProfile = cliProfiles.default;
|
|
87
96
|
let finalCLIProfile = {};
|
|
88
97
|
//if theres a default cli profile, start with that
|
|
@@ -105,6 +114,8 @@ const GetFinalCLIProfile = (commandLineOverrides, configFileLocation) => {
|
|
|
105
114
|
return finalCLIProfile;
|
|
106
115
|
});
|
|
107
116
|
};
|
|
117
|
+
//Get CLI Config given command line overrides and a config file
|
|
118
|
+
//config file location can be null - which means to use default location
|
|
108
119
|
const GetCLIConfig = (commandLineOverrides, configFileLocation) => {
|
|
109
120
|
return GetFinalCLIProfile(commandLineOverrides, configFileLocation).then((cliProfile) => {
|
|
110
121
|
CLILogger.info("got final cli profile configFileLocation:", configFileLocation, JSON.stringify(RemoveCredentialsFromCLIProfile(cliProfile)));
|
|
@@ -124,7 +135,8 @@ const GetCLIConfig = (commandLineOverrides, configFileLocation) => {
|
|
|
124
135
|
snowflakeRole: cliProfile.snowflakeRole,
|
|
125
136
|
snowflakeUsername: cliProfile.snowflakeUsername,
|
|
126
137
|
snowflakeWarehouse: cliProfile.snowflakeWarehouse
|
|
127
|
-
}
|
|
138
|
+
},
|
|
139
|
+
runtimeParameters: cliProfile.parameters
|
|
128
140
|
};
|
|
129
141
|
Shared.Common.CleanupUndefinedValuesFromObject(cliConfig);
|
|
130
142
|
return cliConfig;
|
package/bin/CommonCLI.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.FinishWithOutputFile = exports.GetUserConnectionForCLI = exports.CleanupCLIJob = void 0;
|
|
22
|
+
exports.FinishWithOutputFile = exports.ValidateRuntimeParameters = exports.GetRuntimeParametersFromFirestore = exports.GetUserConnectionForCLI = exports.CleanupCLIJob = void 0;
|
|
23
23
|
const Shared = __importStar(require("@coalescesoftware/shared"));
|
|
24
24
|
const fs = __importStar(require("fs"));
|
|
25
25
|
const crypto = __importStar(require("crypto"));
|
|
@@ -76,21 +76,20 @@ const GetKeyPairKey = (keyPairPath) => {
|
|
|
76
76
|
};
|
|
77
77
|
const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
78
78
|
return new Promise((resolve, reject) => {
|
|
79
|
-
var _a, _b, _c, _d, _e, _f
|
|
79
|
+
var _a, _b, _c, _d, _e, _f;
|
|
80
80
|
const output = {
|
|
81
81
|
connectionDetails: {
|
|
82
82
|
userID,
|
|
83
83
|
user: (_a = runInfo.userCredentials) === null || _a === void 0 ? void 0 : _a.snowflakeUsername,
|
|
84
84
|
role: (_b = runInfo.userCredentials) === null || _b === void 0 ? void 0 : _b.snowflakeRole,
|
|
85
85
|
warehouse: (_c = runInfo.userCredentials) === null || _c === void 0 ? void 0 : _c.snowflakeWarehouse,
|
|
86
|
-
authenticator: (_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType
|
|
87
86
|
},
|
|
88
|
-
connectionType: (
|
|
87
|
+
connectionType: (_d = runInfo.userCredentials) === null || _d === void 0 ? void 0 : _d.snowflakeAuthType
|
|
89
88
|
};
|
|
90
|
-
if (!((
|
|
89
|
+
if (!((_e = runInfo.userCredentials) === null || _e === void 0 ? void 0 : _e.snowflakeAuthType)) {
|
|
91
90
|
reject(new Error("ERROR (GetUserConnectionForCLI): no auth type provided"));
|
|
92
91
|
}
|
|
93
|
-
else if (((
|
|
92
|
+
else if (((_f = runInfo.userCredentials) === null || _f === void 0 ? void 0 : _f.snowflakeAuthType) === Shared.ConnectionOperations.EUserConnectionTypes.keyPair) {
|
|
94
93
|
GetKeyPairKey(Shared.Common.getValueSafe(runInfo, ["userCredentials", "snowflakeKeyPairPath"], ""))
|
|
95
94
|
.then((keyPair) => {
|
|
96
95
|
output.connectionDetails.keyPair = keyPair;
|
|
@@ -106,6 +105,27 @@ const GetUserConnectionForCLI = (userID, runInfo) => {
|
|
|
106
105
|
});
|
|
107
106
|
};
|
|
108
107
|
exports.GetUserConnectionForCLI = GetUserConnectionForCLI;
|
|
108
|
+
////////
|
|
109
|
+
// Runtime Parameters
|
|
110
|
+
///////
|
|
111
|
+
const GetRuntimeParametersFromFirestore = (firestore, teamID, environmentID) => {
|
|
112
|
+
return Shared.CommonOperations.getWorkspaceDocumentRefAdmin(firestore, teamID, environmentID).get().then((workspace) => {
|
|
113
|
+
return workspace.get("runTimeParameters");
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
exports.GetRuntimeParametersFromFirestore = GetRuntimeParametersFromFirestore;
|
|
117
|
+
const ValidateRuntimeParameters = (runtimeParameters) => {
|
|
118
|
+
try {
|
|
119
|
+
JSON.parse(runtimeParameters);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
throw new Error(`Failed to parse runtime parameters: ${error.message}`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.ValidateRuntimeParameters = ValidateRuntimeParameters;
|
|
126
|
+
////////
|
|
127
|
+
// Output File
|
|
128
|
+
///////
|
|
109
129
|
const FinishWithOutputFile = (logContextToUse, outputFilePath, runCounter, token) => {
|
|
110
130
|
if (!outputFilePath) {
|
|
111
131
|
return Promise.resolve();
|
package/bin/Deploy.js
CHANGED
|
@@ -50,7 +50,7 @@ const DeployWithCLI = (plan, config, token) => {
|
|
|
50
50
|
logContext = Shared.Logging.CreateLogContext(teamID, environmentID, userID);
|
|
51
51
|
const connectionCache = new Shared.Snowflake.ConnectionStorageClass();
|
|
52
52
|
RunSQL = Shared.SQLExecutorCreators.CreateRunSQLWithoutScheduler(teamDetails, connectionCache);
|
|
53
|
-
runInfo = Shared.DeployOperations.CreateDeployRequestObject(plan.plan, plan.environmentState, teamInfo, plan.gitInfo, plan.targetEnvironment,
|
|
53
|
+
runInfo = Shared.DeployOperations.CreateDeployRequestObject(plan.plan, plan.environmentState, teamInfo, plan.gitInfo, plan.targetEnvironment, plan.runtimeParameters);
|
|
54
54
|
runInfo.userCredentials = config.userCredentials;
|
|
55
55
|
return CommonCLI.GetUserConnectionForCLI(userID, runInfo);
|
|
56
56
|
})
|