@catladder/cli 0.0.0-next-78f04d3f → 0.0.0-next-89bce6d0
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/dist/bundles/catenv/index.js +68 -40
- package/dist/bundles/cli/index.js +68 -40
- package/dist/bundles/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.d.ts +6 -0
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.js +8 -0
- package/dist/packages/bash/src/variables/VariableValueContainingReferences.js.map +1 -1
- package/dist/packages/bash/src/variables/resolveAllReferences.d.ts +1 -2
- package/dist/packages/bash/src/variables/resolveAllReferences.js +4 -2
- package/dist/packages/bash/src/variables/resolveAllReferences.js.map +1 -1
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.d.ts +1 -4
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.js +4 -2
- package/dist/packages/bash/src/variables/resolveAllReferencesOnce.js.map +1 -1
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js +17 -9
- package/dist/packages/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js +2 -2
- package/dist/packages/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.d.ts +7 -9
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.js +32 -24
- package/dist/packages/pipeline/src/deploy/cloudRun/utils/database.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/index.d.ts +2 -2
- package/dist/skills/catladder-deploys/references/deploy-types.md +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1902,6 +1902,14 @@ class VariableValueContainingReferences {
|
|
|
1902
1902
|
? []
|
|
1903
1903
|
: [part]);
|
|
1904
1904
|
}
|
|
1905
|
+
/**
|
|
1906
|
+
* concats values to this one and returns a new VariableValueContainingReferences.
|
|
1907
|
+
* mirrors String.prototype.concat / BashExpression.concat so a VariableValue
|
|
1908
|
+
* can be extended regardless of its concrete type
|
|
1909
|
+
*/
|
|
1910
|
+
concat(...values) {
|
|
1911
|
+
return new VariableValueContainingReferences([...this.parts, ...values]);
|
|
1912
|
+
}
|
|
1905
1913
|
toString(options = {
|
|
1906
1914
|
quotes: false,
|
|
1907
1915
|
}) {
|
|
@@ -1951,16 +1959,18 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1951
1959
|
exports.resolveAllReferences = void 0;
|
|
1952
1960
|
const VariableValueContainingReferences_1 = __nccwpck_require__(70795);
|
|
1953
1961
|
const resolveAllReferencesOnce_1 = __nccwpck_require__(98690);
|
|
1962
|
+
const hasUnresolvedReferences = (value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences &&
|
|
1963
|
+
value.parts.some((part) => part instanceof VariableValueContainingReferences_1.VariableReference);
|
|
1954
1964
|
const resolveAllReferences = async (values, getEnvVars) => {
|
|
1955
1965
|
// replace until there aren't any references left
|
|
1956
1966
|
let result = values;
|
|
1957
1967
|
let i = 0;
|
|
1958
|
-
while (Object.values(result).some(
|
|
1968
|
+
while (Object.values(result).some(hasUnresolvedReferences)) {
|
|
1959
1969
|
const replaced = await (0, resolveAllReferencesOnce_1.resolveAllReferencesOnce)(result, getEnvVars);
|
|
1960
1970
|
result = replaced;
|
|
1961
1971
|
i++;
|
|
1962
1972
|
if (i > 1000) {
|
|
1963
|
-
const unresolved = Object.entries(result).filter(([key, value]) => value
|
|
1973
|
+
const unresolved = Object.entries(result).filter(([key, value]) => hasUnresolvedReferences(value));
|
|
1964
1974
|
throw new Error("Infinite loop detected in these variables: " +
|
|
1965
1975
|
unresolved
|
|
1966
1976
|
.map(([key, value]) => `${key} (last reference: ${value.parts.find((part) => part instanceof VariableValueContainingReferences_1.VariableReference)})`)
|
|
@@ -1984,7 +1994,9 @@ exports.resolveAllReferencesOnce = void 0;
|
|
|
1984
1994
|
const VariableValueContainingReferences_1 = __nccwpck_require__(70795);
|
|
1985
1995
|
const resolveReferencesOnce_1 = __nccwpck_require__(29767);
|
|
1986
1996
|
const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
1987
|
-
const allReferences = Object.values(values).flatMap((value) => value
|
|
1997
|
+
const allReferences = Object.values(values).flatMap((value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
1998
|
+
? value.parts.filter((part) => part instanceof VariableValueContainingReferences_1.VariableReference)
|
|
1999
|
+
: []);
|
|
1988
2000
|
const allComponentsUnique = Array.from(new Set(allReferences.map((reference) => reference.componentName)));
|
|
1989
2001
|
const allEnvVarsInComponents = Object.fromEntries(await Promise.all(allComponentsUnique.map(async (componentName) => [
|
|
1990
2002
|
componentName,
|
|
@@ -1992,7 +2004,7 @@ const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
|
1992
2004
|
])));
|
|
1993
2005
|
return Object.fromEntries(Object.entries(values).map(([key, value]) => [
|
|
1994
2006
|
key,
|
|
1995
|
-
value
|
|
2007
|
+
value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
1996
2008
|
? (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, ({ componentName, variableName }) => {
|
|
1997
2009
|
return allEnvVarsInComponents[componentName][variableName];
|
|
1998
2010
|
})
|
|
@@ -6929,7 +6941,9 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
6929
6941
|
const additionalEnvVars = deployConfigRaw
|
|
6930
6942
|
? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext)
|
|
6931
6943
|
: {};
|
|
6932
|
-
|
|
6944
|
+
// deploy types provide HOSTNAME_INTERNAL as a plain string or bash
|
|
6945
|
+
// expression (never containing references)
|
|
6946
|
+
const HOSTNAME_INTERNAL = ((_b = additionalEnvVars.HOSTNAME_INTERNAL) !== null && _b !== void 0 ? _b : "unknown-host.example.com");
|
|
6933
6947
|
host = (_c = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _c !== void 0 ? _c : HOSTNAME_INTERNAL;
|
|
6934
6948
|
url = (0, bash_1.joinBashExpressions)(["https://", host]);
|
|
6935
6949
|
predefinedVariables = {
|
|
@@ -6957,8 +6971,18 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
6957
6971
|
componentName: ctx.componentName,
|
|
6958
6972
|
}),
|
|
6959
6973
|
]));
|
|
6960
|
-
|
|
6961
|
-
|
|
6974
|
+
// predefined variables may contain references too (e.g. the embedded
|
|
6975
|
+
// database connection string references the component's own DB_* vars), so
|
|
6976
|
+
// we resolve references over the merged map. This way public var overrides
|
|
6977
|
+
// (like DB_PASSWORD: "${otherComponent:DB_PASSWORD}") are picked up by the
|
|
6978
|
+
// predefined variables that reference them
|
|
6979
|
+
const mergedEnvVars = {
|
|
6980
|
+
...predefinedVariables,
|
|
6981
|
+
...secretEnvVars,
|
|
6982
|
+
...publicEnvVarsUnresolved,
|
|
6983
|
+
};
|
|
6984
|
+
const resolvedEnvVars = ((_g = options.shouldResolveReferences) !== null && _g !== void 0 ? _g : true)
|
|
6985
|
+
? await (0, bash_3.resolveAllReferences)(mergedEnvVars, async (otherComponentName) => {
|
|
6962
6986
|
const { envVars: otherEnvVars } = await (0, exports.getEnvironmentVariables)({
|
|
6963
6987
|
...ctx,
|
|
6964
6988
|
componentName: otherComponentName,
|
|
@@ -6967,12 +6991,8 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
6967
6991
|
});
|
|
6968
6992
|
return otherEnvVars;
|
|
6969
6993
|
})
|
|
6970
|
-
:
|
|
6971
|
-
const envVars = addIndexVar(
|
|
6972
|
-
...predefinedVariables,
|
|
6973
|
-
...secretEnvVars,
|
|
6974
|
-
...publicEnvVars,
|
|
6975
|
-
});
|
|
6994
|
+
: mergedEnvVars;
|
|
6995
|
+
const envVars = addIndexVar(resolvedEnvVars);
|
|
6976
6996
|
return {
|
|
6977
6997
|
envVars,
|
|
6978
6998
|
secretEnvVarKeys,
|
|
@@ -8963,8 +8983,8 @@ const getCloudSqlVariables = ({ deployConfigRaw, environmentSlugPrefix, env, com
|
|
|
8963
8983
|
};
|
|
8964
8984
|
return {
|
|
8965
8985
|
...dbVars,
|
|
8966
|
-
DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars).concat(additionalQueryParamsString),
|
|
8967
|
-
DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE),
|
|
8986
|
+
DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars, componentName).concat(additionalQueryParamsString),
|
|
8987
|
+
DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE, componentName),
|
|
8968
8988
|
};
|
|
8969
8989
|
}
|
|
8970
8990
|
return {};
|
|
@@ -9156,64 +9176,72 @@ const getDatabaseCreateScript = (context, deployConfig) => {
|
|
|
9156
9176
|
]);
|
|
9157
9177
|
};
|
|
9158
9178
|
exports.getDatabaseCreateScript = getDatabaseCreateScript;
|
|
9159
|
-
exports.DEFAULT_DB_VARIABLES_MODE = "
|
|
9160
|
-
const getVariableOrValue = (key,
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9179
|
+
exports.DEFAULT_DB_VARIABLES_MODE = "embedded";
|
|
9180
|
+
const getVariableOrValue = (key, mode, componentName) => {
|
|
9181
|
+
// in embedded mode we reference the component's own env var, which gets
|
|
9182
|
+
// resolved to its final value (including vars.public overrides) after all
|
|
9183
|
+
// env vars have been merged
|
|
9184
|
+
return mode === "legacy"
|
|
9185
|
+
? `$${key}`
|
|
9186
|
+
: new bash_1.VariableReference(componentName, key);
|
|
9187
|
+
};
|
|
9188
|
+
const joinDbUrlParts = (parts, mode) => mode === "legacy"
|
|
9189
|
+
? (0, bash_1.joinBashExpressions)(parts)
|
|
9190
|
+
: new bash_1.VariableValueContainingReferences(parts);
|
|
9191
|
+
const getDatabaseJdbcUrl = (variables, mode, componentName) => {
|
|
9164
9192
|
const parts = [
|
|
9165
9193
|
"jdbc:postgresql:///",
|
|
9166
|
-
getVariableOrValue("DB_NAME",
|
|
9194
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
9167
9195
|
"?cloudSqlInstance=",
|
|
9168
|
-
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME",
|
|
9196
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", mode, componentName),
|
|
9169
9197
|
"&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=",
|
|
9170
|
-
getVariableOrValue("DB_USER",
|
|
9198
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
9171
9199
|
"&password=",
|
|
9172
|
-
getVariableOrValue("DB_PASSWORD",
|
|
9200
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
9173
9201
|
];
|
|
9174
|
-
return (
|
|
9202
|
+
return joinDbUrlParts(parts, mode);
|
|
9175
9203
|
};
|
|
9176
9204
|
exports.getDatabaseJdbcUrl = getDatabaseJdbcUrl;
|
|
9177
|
-
const getRailsDatabaseConnectionString = (variables, mode) => {
|
|
9205
|
+
const getRailsDatabaseConnectionString = (variables, mode, componentName) => {
|
|
9178
9206
|
const parts = [
|
|
9179
9207
|
"postgresql://",
|
|
9180
|
-
getVariableOrValue("DB_USER",
|
|
9208
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
9181
9209
|
":",
|
|
9182
|
-
getVariableOrValue("DB_PASSWORD",
|
|
9210
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
9183
9211
|
"@",
|
|
9184
9212
|
encodeURIComponent(`/cloudsql/${variables.CLOUD_SQL_INSTANCE_CONNECTION_NAME}`),
|
|
9185
9213
|
"/",
|
|
9186
|
-
getVariableOrValue("DB_NAME",
|
|
9214
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
9187
9215
|
"?",
|
|
9188
9216
|
];
|
|
9189
|
-
return (
|
|
9217
|
+
return joinDbUrlParts(parts, mode);
|
|
9190
9218
|
};
|
|
9191
9219
|
exports.getRailsDatabaseConnectionString = getRailsDatabaseConnectionString;
|
|
9192
|
-
const getPrismaDatabaseConnectionString = (variables, mode) => {
|
|
9220
|
+
const getPrismaDatabaseConnectionString = (variables, mode, componentName) => {
|
|
9193
9221
|
const parts = [
|
|
9194
9222
|
"postgresql://",
|
|
9195
|
-
getVariableOrValue("DB_USER",
|
|
9223
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
9196
9224
|
":",
|
|
9197
|
-
getVariableOrValue("DB_PASSWORD",
|
|
9225
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
9198
9226
|
"@localhost/",
|
|
9199
|
-
getVariableOrValue("DB_NAME",
|
|
9227
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
9200
9228
|
"?host=/cloudsql/",
|
|
9201
|
-
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME",
|
|
9229
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", mode, componentName),
|
|
9202
9230
|
];
|
|
9203
|
-
return (
|
|
9231
|
+
return joinDbUrlParts(parts, mode);
|
|
9204
9232
|
};
|
|
9205
9233
|
exports.getPrismaDatabaseConnectionString = getPrismaDatabaseConnectionString;
|
|
9206
|
-
const getDatabaseConnectionString = (config, variables) => {
|
|
9234
|
+
const getDatabaseConnectionString = (config, variables, componentName) => {
|
|
9207
9235
|
var _a;
|
|
9208
9236
|
const mode = (_a = config.dbConnectionStringVariablesMode) !== null && _a !== void 0 ? _a : exports.DEFAULT_DB_VARIABLES_MODE;
|
|
9209
9237
|
switch (config.dbConnectionStringFormat) {
|
|
9210
9238
|
case "jdbc":
|
|
9211
|
-
return (0, exports.getDatabaseJdbcUrl)(variables, mode);
|
|
9239
|
+
return (0, exports.getDatabaseJdbcUrl)(variables, mode, componentName);
|
|
9212
9240
|
case "rails":
|
|
9213
|
-
return (0, exports.getRailsDatabaseConnectionString)(variables, mode);
|
|
9241
|
+
return (0, exports.getRailsDatabaseConnectionString)(variables, mode, componentName);
|
|
9214
9242
|
default:
|
|
9215
9243
|
// prisma
|
|
9216
|
-
return (0, exports.getPrismaDatabaseConnectionString)(variables, mode);
|
|
9244
|
+
return (0, exports.getPrismaDatabaseConnectionString)(variables, mode, componentName);
|
|
9217
9245
|
}
|
|
9218
9246
|
};
|
|
9219
9247
|
exports.getDatabaseConnectionString = getDatabaseConnectionString;
|
|
@@ -7895,6 +7895,14 @@ class VariableValueContainingReferences {
|
|
|
7895
7895
|
? []
|
|
7896
7896
|
: [part]);
|
|
7897
7897
|
}
|
|
7898
|
+
/**
|
|
7899
|
+
* concats values to this one and returns a new VariableValueContainingReferences.
|
|
7900
|
+
* mirrors String.prototype.concat / BashExpression.concat so a VariableValue
|
|
7901
|
+
* can be extended regardless of its concrete type
|
|
7902
|
+
*/
|
|
7903
|
+
concat(...values) {
|
|
7904
|
+
return new VariableValueContainingReferences([...this.parts, ...values]);
|
|
7905
|
+
}
|
|
7898
7906
|
toString(options = {
|
|
7899
7907
|
quotes: false,
|
|
7900
7908
|
}) {
|
|
@@ -7944,16 +7952,18 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
7944
7952
|
exports.resolveAllReferences = void 0;
|
|
7945
7953
|
const VariableValueContainingReferences_1 = __nccwpck_require__(70795);
|
|
7946
7954
|
const resolveAllReferencesOnce_1 = __nccwpck_require__(98690);
|
|
7955
|
+
const hasUnresolvedReferences = (value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences &&
|
|
7956
|
+
value.parts.some((part) => part instanceof VariableValueContainingReferences_1.VariableReference);
|
|
7947
7957
|
const resolveAllReferences = async (values, getEnvVars) => {
|
|
7948
7958
|
// replace until there aren't any references left
|
|
7949
7959
|
let result = values;
|
|
7950
7960
|
let i = 0;
|
|
7951
|
-
while (Object.values(result).some(
|
|
7961
|
+
while (Object.values(result).some(hasUnresolvedReferences)) {
|
|
7952
7962
|
const replaced = await (0, resolveAllReferencesOnce_1.resolveAllReferencesOnce)(result, getEnvVars);
|
|
7953
7963
|
result = replaced;
|
|
7954
7964
|
i++;
|
|
7955
7965
|
if (i > 1000) {
|
|
7956
|
-
const unresolved = Object.entries(result).filter(([key, value]) => value
|
|
7966
|
+
const unresolved = Object.entries(result).filter(([key, value]) => hasUnresolvedReferences(value));
|
|
7957
7967
|
throw new Error("Infinite loop detected in these variables: " +
|
|
7958
7968
|
unresolved
|
|
7959
7969
|
.map(([key, value]) => `${key} (last reference: ${value.parts.find((part) => part instanceof VariableValueContainingReferences_1.VariableReference)})`)
|
|
@@ -7977,7 +7987,9 @@ exports.resolveAllReferencesOnce = void 0;
|
|
|
7977
7987
|
const VariableValueContainingReferences_1 = __nccwpck_require__(70795);
|
|
7978
7988
|
const resolveReferencesOnce_1 = __nccwpck_require__(29767);
|
|
7979
7989
|
const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
7980
|
-
const allReferences = Object.values(values).flatMap((value) => value
|
|
7990
|
+
const allReferences = Object.values(values).flatMap((value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
7991
|
+
? value.parts.filter((part) => part instanceof VariableValueContainingReferences_1.VariableReference)
|
|
7992
|
+
: []);
|
|
7981
7993
|
const allComponentsUnique = Array.from(new Set(allReferences.map((reference) => reference.componentName)));
|
|
7982
7994
|
const allEnvVarsInComponents = Object.fromEntries(await Promise.all(allComponentsUnique.map(async (componentName) => [
|
|
7983
7995
|
componentName,
|
|
@@ -7985,7 +7997,7 @@ const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
|
7985
7997
|
])));
|
|
7986
7998
|
return Object.fromEntries(Object.entries(values).map(([key, value]) => [
|
|
7987
7999
|
key,
|
|
7988
|
-
value
|
|
8000
|
+
value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
7989
8001
|
? (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, ({ componentName, variableName }) => {
|
|
7990
8002
|
return allEnvVarsInComponents[componentName][variableName];
|
|
7991
8003
|
})
|
|
@@ -12922,7 +12934,9 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
12922
12934
|
const additionalEnvVars = deployConfigRaw
|
|
12923
12935
|
? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext)
|
|
12924
12936
|
: {};
|
|
12925
|
-
|
|
12937
|
+
// deploy types provide HOSTNAME_INTERNAL as a plain string or bash
|
|
12938
|
+
// expression (never containing references)
|
|
12939
|
+
const HOSTNAME_INTERNAL = ((_b = additionalEnvVars.HOSTNAME_INTERNAL) !== null && _b !== void 0 ? _b : "unknown-host.example.com");
|
|
12926
12940
|
host = (_c = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _c !== void 0 ? _c : HOSTNAME_INTERNAL;
|
|
12927
12941
|
url = (0, bash_1.joinBashExpressions)(["https://", host]);
|
|
12928
12942
|
predefinedVariables = {
|
|
@@ -12950,8 +12964,18 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
12950
12964
|
componentName: ctx.componentName,
|
|
12951
12965
|
}),
|
|
12952
12966
|
]));
|
|
12953
|
-
|
|
12954
|
-
|
|
12967
|
+
// predefined variables may contain references too (e.g. the embedded
|
|
12968
|
+
// database connection string references the component's own DB_* vars), so
|
|
12969
|
+
// we resolve references over the merged map. This way public var overrides
|
|
12970
|
+
// (like DB_PASSWORD: "${otherComponent:DB_PASSWORD}") are picked up by the
|
|
12971
|
+
// predefined variables that reference them
|
|
12972
|
+
const mergedEnvVars = {
|
|
12973
|
+
...predefinedVariables,
|
|
12974
|
+
...secretEnvVars,
|
|
12975
|
+
...publicEnvVarsUnresolved,
|
|
12976
|
+
};
|
|
12977
|
+
const resolvedEnvVars = ((_g = options.shouldResolveReferences) !== null && _g !== void 0 ? _g : true)
|
|
12978
|
+
? await (0, bash_3.resolveAllReferences)(mergedEnvVars, async (otherComponentName) => {
|
|
12955
12979
|
const { envVars: otherEnvVars } = await (0, exports.getEnvironmentVariables)({
|
|
12956
12980
|
...ctx,
|
|
12957
12981
|
componentName: otherComponentName,
|
|
@@ -12960,12 +12984,8 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
12960
12984
|
});
|
|
12961
12985
|
return otherEnvVars;
|
|
12962
12986
|
})
|
|
12963
|
-
:
|
|
12964
|
-
const envVars = addIndexVar(
|
|
12965
|
-
...predefinedVariables,
|
|
12966
|
-
...secretEnvVars,
|
|
12967
|
-
...publicEnvVars,
|
|
12968
|
-
});
|
|
12987
|
+
: mergedEnvVars;
|
|
12988
|
+
const envVars = addIndexVar(resolvedEnvVars);
|
|
12969
12989
|
return {
|
|
12970
12990
|
envVars,
|
|
12971
12991
|
secretEnvVarKeys,
|
|
@@ -14956,8 +14976,8 @@ const getCloudSqlVariables = ({ deployConfigRaw, environmentSlugPrefix, env, com
|
|
|
14956
14976
|
};
|
|
14957
14977
|
return {
|
|
14958
14978
|
...dbVars,
|
|
14959
|
-
DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars).concat(additionalQueryParamsString),
|
|
14960
|
-
DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE),
|
|
14979
|
+
DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars, componentName).concat(additionalQueryParamsString),
|
|
14980
|
+
DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE, componentName),
|
|
14961
14981
|
};
|
|
14962
14982
|
}
|
|
14963
14983
|
return {};
|
|
@@ -15149,64 +15169,72 @@ const getDatabaseCreateScript = (context, deployConfig) => {
|
|
|
15149
15169
|
]);
|
|
15150
15170
|
};
|
|
15151
15171
|
exports.getDatabaseCreateScript = getDatabaseCreateScript;
|
|
15152
|
-
exports.DEFAULT_DB_VARIABLES_MODE = "
|
|
15153
|
-
const getVariableOrValue = (key,
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15172
|
+
exports.DEFAULT_DB_VARIABLES_MODE = "embedded";
|
|
15173
|
+
const getVariableOrValue = (key, mode, componentName) => {
|
|
15174
|
+
// in embedded mode we reference the component's own env var, which gets
|
|
15175
|
+
// resolved to its final value (including vars.public overrides) after all
|
|
15176
|
+
// env vars have been merged
|
|
15177
|
+
return mode === "legacy"
|
|
15178
|
+
? `$${key}`
|
|
15179
|
+
: new bash_1.VariableReference(componentName, key);
|
|
15180
|
+
};
|
|
15181
|
+
const joinDbUrlParts = (parts, mode) => mode === "legacy"
|
|
15182
|
+
? (0, bash_1.joinBashExpressions)(parts)
|
|
15183
|
+
: new bash_1.VariableValueContainingReferences(parts);
|
|
15184
|
+
const getDatabaseJdbcUrl = (variables, mode, componentName) => {
|
|
15157
15185
|
const parts = [
|
|
15158
15186
|
"jdbc:postgresql:///",
|
|
15159
|
-
getVariableOrValue("DB_NAME",
|
|
15187
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
15160
15188
|
"?cloudSqlInstance=",
|
|
15161
|
-
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME",
|
|
15189
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", mode, componentName),
|
|
15162
15190
|
"&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=",
|
|
15163
|
-
getVariableOrValue("DB_USER",
|
|
15191
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
15164
15192
|
"&password=",
|
|
15165
|
-
getVariableOrValue("DB_PASSWORD",
|
|
15193
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
15166
15194
|
];
|
|
15167
|
-
return (
|
|
15195
|
+
return joinDbUrlParts(parts, mode);
|
|
15168
15196
|
};
|
|
15169
15197
|
exports.getDatabaseJdbcUrl = getDatabaseJdbcUrl;
|
|
15170
|
-
const getRailsDatabaseConnectionString = (variables, mode) => {
|
|
15198
|
+
const getRailsDatabaseConnectionString = (variables, mode, componentName) => {
|
|
15171
15199
|
const parts = [
|
|
15172
15200
|
"postgresql://",
|
|
15173
|
-
getVariableOrValue("DB_USER",
|
|
15201
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
15174
15202
|
":",
|
|
15175
|
-
getVariableOrValue("DB_PASSWORD",
|
|
15203
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
15176
15204
|
"@",
|
|
15177
15205
|
encodeURIComponent(`/cloudsql/${variables.CLOUD_SQL_INSTANCE_CONNECTION_NAME}`),
|
|
15178
15206
|
"/",
|
|
15179
|
-
getVariableOrValue("DB_NAME",
|
|
15207
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
15180
15208
|
"?",
|
|
15181
15209
|
];
|
|
15182
|
-
return (
|
|
15210
|
+
return joinDbUrlParts(parts, mode);
|
|
15183
15211
|
};
|
|
15184
15212
|
exports.getRailsDatabaseConnectionString = getRailsDatabaseConnectionString;
|
|
15185
|
-
const getPrismaDatabaseConnectionString = (variables, mode) => {
|
|
15213
|
+
const getPrismaDatabaseConnectionString = (variables, mode, componentName) => {
|
|
15186
15214
|
const parts = [
|
|
15187
15215
|
"postgresql://",
|
|
15188
|
-
getVariableOrValue("DB_USER",
|
|
15216
|
+
getVariableOrValue("DB_USER", mode, componentName),
|
|
15189
15217
|
":",
|
|
15190
|
-
getVariableOrValue("DB_PASSWORD",
|
|
15218
|
+
getVariableOrValue("DB_PASSWORD", mode, componentName),
|
|
15191
15219
|
"@localhost/",
|
|
15192
|
-
getVariableOrValue("DB_NAME",
|
|
15220
|
+
getVariableOrValue("DB_NAME", mode, componentName),
|
|
15193
15221
|
"?host=/cloudsql/",
|
|
15194
|
-
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME",
|
|
15222
|
+
getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", mode, componentName),
|
|
15195
15223
|
];
|
|
15196
|
-
return (
|
|
15224
|
+
return joinDbUrlParts(parts, mode);
|
|
15197
15225
|
};
|
|
15198
15226
|
exports.getPrismaDatabaseConnectionString = getPrismaDatabaseConnectionString;
|
|
15199
|
-
const getDatabaseConnectionString = (config, variables) => {
|
|
15227
|
+
const getDatabaseConnectionString = (config, variables, componentName) => {
|
|
15200
15228
|
var _a;
|
|
15201
15229
|
const mode = (_a = config.dbConnectionStringVariablesMode) !== null && _a !== void 0 ? _a : exports.DEFAULT_DB_VARIABLES_MODE;
|
|
15202
15230
|
switch (config.dbConnectionStringFormat) {
|
|
15203
15231
|
case "jdbc":
|
|
15204
|
-
return (0, exports.getDatabaseJdbcUrl)(variables, mode);
|
|
15232
|
+
return (0, exports.getDatabaseJdbcUrl)(variables, mode, componentName);
|
|
15205
15233
|
case "rails":
|
|
15206
|
-
return (0, exports.getRailsDatabaseConnectionString)(variables, mode);
|
|
15234
|
+
return (0, exports.getRailsDatabaseConnectionString)(variables, mode, componentName);
|
|
15207
15235
|
default:
|
|
15208
15236
|
// prisma
|
|
15209
|
-
return (0, exports.getPrismaDatabaseConnectionString)(variables, mode);
|
|
15237
|
+
return (0, exports.getPrismaDatabaseConnectionString)(variables, mode, componentName);
|
|
15210
15238
|
}
|
|
15211
15239
|
};
|
|
15212
15240
|
exports.getDatabaseConnectionString = getDatabaseConnectionString;
|
|
@@ -43,7 +43,7 @@ resources with `yarn catladder project setup`; detect drift with
|
|
|
43
43
|
- `additionalServices?: Record<string, service | false | null>`.
|
|
44
44
|
- `jobs?: Record<string, DeployConfigCloudRunJob | false | null>` — `{ command, args?, image?, cpu?, memory? (512Mi), timeout? (10min), parallelism? (1), maxRetries? (0) }`. The per-job `when`/`schedule`/`waitForCompletion` fields are **deprecated** — use `execute`.
|
|
45
45
|
- `workerPools?: Record<string, DeployConfigCloudRunWorkerPool | false | null>` — always-on background work, no endpoint, no autoscaling: `{ command, instances? (1), cpu?, memory?, image?, args?, gpu?/gpuType? }`.
|
|
46
|
-
- `cloudSql?: DeployConfigCloudRunCloudSql | false` — `{ type: "unmanaged", instanceConnectionName, dbUser?, dbNamePrefix?, dbBaseName?, deleteDatabaseOnStop?, dbConnectionStringFormat? ("prisma" default | "rails" | "jdbc"), dbConnectionStringVariablesMode? ("
|
|
46
|
+
- `cloudSql?: DeployConfigCloudRunCloudSql | false` — `{ type: "unmanaged", instanceConnectionName, dbUser?, dbNamePrefix?, dbBaseName?, deleteDatabaseOnStop?, dbConnectionStringFormat? ("prisma" default | "rails" | "jdbc"), dbConnectionStringVariablesMode? ("embedded" default | "legacy"), dbAdditionalQueryParams? }`. Injects `DB_*` vars plus `DATABASE_URL`/`DATABASE_JDBC_URL`; in the default `"embedded"` mode the connection strings contain the component's final values (referenceable from other components, `vars.public` overrides of `DB_*` flow in). To share another component's database: `dbBaseName: "<owner>"` + `DB_PASSWORD: "${<owner>:DB_PASSWORD}"` in `vars.public`.
|
|
47
47
|
- `execute?: Record<string, DeployConfigCloudRunExecute | null>` — run a script / job / HTTP call at a lifecycle point (`when`: `preDeploy` | `postDeploy` | `preStop` | `postStop`) or on a `schedule`.
|
|
48
48
|
- `debug?: boolean`.
|
|
49
49
|
|
|
@@ -16,6 +16,12 @@ type MaybeArray<T> = T | T[];
|
|
|
16
16
|
export declare class VariableValueContainingReferences {
|
|
17
17
|
parts: VariableValuePart[];
|
|
18
18
|
constructor(parts: MaybeArray<VariableValuePart | VariableValueContainingReferences>);
|
|
19
|
+
/**
|
|
20
|
+
* concats values to this one and returns a new VariableValueContainingReferences.
|
|
21
|
+
* mirrors String.prototype.concat / BashExpression.concat so a VariableValue
|
|
22
|
+
* can be extended regardless of its concrete type
|
|
23
|
+
*/
|
|
24
|
+
concat(...values: Array<VariableValuePart | VariableValueContainingReferences>): VariableValueContainingReferences;
|
|
19
25
|
toString(options?: EscapeOptions): string;
|
|
20
26
|
}
|
|
21
27
|
export declare const createVariableValueContainingReferencesFromString: (value: string, options: {
|
|
@@ -30,6 +30,14 @@ class VariableValueContainingReferences {
|
|
|
30
30
|
? []
|
|
31
31
|
: [part]);
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* concats values to this one and returns a new VariableValueContainingReferences.
|
|
35
|
+
* mirrors String.prototype.concat / BashExpression.concat so a VariableValue
|
|
36
|
+
* can be extended regardless of its concrete type
|
|
37
|
+
*/
|
|
38
|
+
concat(...values) {
|
|
39
|
+
return new VariableValueContainingReferences([...this.parts, ...values]);
|
|
40
|
+
}
|
|
33
41
|
toString(options = {
|
|
34
42
|
quotes: false,
|
|
35
43
|
}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableValueContainingReferences.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/VariableValueContainingReferences.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,8CAAmE;AAEnE,MAAa,qBAAqB;IAChC,YAAmB,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;IAAG,CAAC;IAC5C,QAAQ;QACb,OAAO,2BAA2B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;IAChE,CAAC;CACF;AALD,sDAKC;AACD,MAAa,iBAAiB;IAI5B,YAAY,aAAqB,EAAE,YAAoB;QACrD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,QAAQ;QACb,OAAO,MAAM,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC;IAC1D,CAAC;CACF;AAZD,8CAYC;AASD,MAAa,iCAAiC;IAE5C,YACE,KAAwE;QAExE,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACrE,IAAI,YAAY,iCAAiC;YAC/C,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,IAAI,KAAK,EAAE;gBACX,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC;IAEM,QAAQ,CACb,UAAyB;QACvB,MAAM,EAAE,KAAK;KACd;QAED,OAAO,IAAI,CAAC,KAAK;aACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,OAAO,IAAA,yBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACrC,CAAC;iBAAM,IAAI,IAAI,YAAY,+BAAc,EAAE,CAAC;gBAC1C,OAAO,IAAA,iCAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"VariableValueContainingReferences.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/VariableValueContainingReferences.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { VariableValue } from "./VariableValue";
|
|
2
|
-
|
|
3
|
-
export declare const resolveAllReferences: (values: Record<string, VariableValueContainingReferences>, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | null | undefined>>) => Promise<Record<string, VariableValueContainingReferences>>;
|
|
2
|
+
export declare const resolveAllReferences: <T extends Record<string, VariableValue>>(values: T, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | null | undefined>>) => Promise<T>;
|
|
@@ -3,16 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveAllReferences = void 0;
|
|
4
4
|
const VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
|
|
5
5
|
const resolveAllReferencesOnce_1 = require("./resolveAllReferencesOnce");
|
|
6
|
+
const hasUnresolvedReferences = (value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences &&
|
|
7
|
+
value.parts.some((part) => part instanceof VariableValueContainingReferences_1.VariableReference);
|
|
6
8
|
const resolveAllReferences = async (values, getEnvVars) => {
|
|
7
9
|
// replace until there aren't any references left
|
|
8
10
|
let result = values;
|
|
9
11
|
let i = 0;
|
|
10
|
-
while (Object.values(result).some(
|
|
12
|
+
while (Object.values(result).some(hasUnresolvedReferences)) {
|
|
11
13
|
const replaced = await (0, resolveAllReferencesOnce_1.resolveAllReferencesOnce)(result, getEnvVars);
|
|
12
14
|
result = replaced;
|
|
13
15
|
i++;
|
|
14
16
|
if (i > 1000) {
|
|
15
|
-
const unresolved = Object.entries(result).filter(([key, value]) => value
|
|
17
|
+
const unresolved = Object.entries(result).filter(([key, value]) => hasUnresolvedReferences(value));
|
|
16
18
|
throw new Error("Infinite loop detected in these variables: " +
|
|
17
19
|
unresolved
|
|
18
20
|
.map(([key, value]) => `${key} (last reference: ${value.parts.find((part) => part instanceof VariableValueContainingReferences_1.VariableReference)})`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAllReferences.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/resolveAllReferences.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"resolveAllReferences.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/resolveAllReferences.ts"],"names":[],"mappings":";;;AACA,2FAG6C;AAC7C,yEAAkG;AAElG,MAAM,uBAAuB,GAAG,CAAC,KAAuC,EAAE,EAAE,CAC1E,KAAK,YAAY,qEAAiC;IAClD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,qDAAiB,CAAC,CAAC;AAEzD,MAAM,oBAAoB,GAAG,KAAK,EAGvC,MAAS,EACT,UAE8D,EAClD,EAAE;IACd,iDAAiD;IACjD,IAAI,MAAM,GAAG,MAAM,CAAC;IAEpB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAA,mDAAwB,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAEpE,MAAM,GAAG,QAAQ,CAAC;QAClB,CAAC,EAAE,CAAC;QACJ,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAChE,uBAAuB,CAAC,KAAK,CAAC,CAC/B,CAAC;YAEF,MAAM,IAAI,KAAK,CACb,6CAA6C;gBAC3C,UAAU;qBACP,GAAG,CACF,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CACf,GAAG,GAAG,qBACJ,KACD,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,qDAAiB,CAAC,GAAG,CAC/D;qBACA,IAAI,CAAC,IAAI,CAAC,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAtCW,QAAA,oBAAoB,wBAsC/B"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import type { VariableValue } from "./VariableValue";
|
|
2
|
-
|
|
3
|
-
export declare const resolveAllReferencesOnce: (values: Record<string, VariableValueContainingReferences>, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | undefined | null>>) => Promise<{
|
|
4
|
-
[k: string]: VariableValueContainingReferences;
|
|
5
|
-
}>;
|
|
2
|
+
export declare const resolveAllReferencesOnce: <T extends Record<string, VariableValue>>(values: T, getEnvVars: (componentName: string) => Promise<Record<string, VariableValue | undefined | null>>) => Promise<T>;
|
|
@@ -4,7 +4,9 @@ exports.resolveAllReferencesOnce = void 0;
|
|
|
4
4
|
const VariableValueContainingReferences_1 = require("./VariableValueContainingReferences");
|
|
5
5
|
const resolveReferencesOnce_1 = require("./resolveReferencesOnce");
|
|
6
6
|
const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
7
|
-
const allReferences = Object.values(values).flatMap((value) => value
|
|
7
|
+
const allReferences = Object.values(values).flatMap((value) => value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
8
|
+
? value.parts.filter((part) => part instanceof VariableValueContainingReferences_1.VariableReference)
|
|
9
|
+
: []);
|
|
8
10
|
const allComponentsUnique = Array.from(new Set(allReferences.map((reference) => reference.componentName)));
|
|
9
11
|
const allEnvVarsInComponents = Object.fromEntries(await Promise.all(allComponentsUnique.map(async (componentName) => [
|
|
10
12
|
componentName,
|
|
@@ -12,7 +14,7 @@ const resolveAllReferencesOnce = async (values, getEnvVars) => {
|
|
|
12
14
|
])));
|
|
13
15
|
return Object.fromEntries(Object.entries(values).map(([key, value]) => [
|
|
14
16
|
key,
|
|
15
|
-
value
|
|
17
|
+
value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences
|
|
16
18
|
? (0, resolveReferencesOnce_1.resolveReferencesOnce)(value, ({ componentName, variableName }) => {
|
|
17
19
|
return allEnvVarsInComponents[componentName][variableName];
|
|
18
20
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAllReferencesOnce.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/resolveAllReferencesOnce.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"resolveAllReferencesOnce.js","sourceRoot":"","sources":["../../../../../../../packages/bash/src/variables/resolveAllReferencesOnce.ts"],"names":[],"mappings":";;;AACA,2FAG6C;AAC7C,mEAAgE;AAEzD,MAAM,wBAAwB,GAAG,KAAK,EAG3C,MAAS,EACT,UAE8D,EAClD,EAAE;IACd,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5D,KAAK,YAAY,qEAAiC;QAChD,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CACjB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,YAAY,qDAAiB,CACpB;QAC3B,CAAC,CAAC,EAAE,CACP,CAAC;IAEF,MAAM,mBAAmB,GAAG,KAAK,CAAC,IAAI,CACpC,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CACnE,CAAC;IAEF,MAAM,sBAAsB,GAAG,MAAM,CAAC,WAAW,CAC/C,MAAM,OAAO,CAAC,GAAG,CACf,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC;QAC/C,aAAa;QACb,MAAM,UAAU,CAAC,aAAa,CAAC;KAChC,CAEA,CACF,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3C,GAAG;QACH,KAAK,YAAY,qEAAiC;YAChD,CAAC,CAAC,IAAA,6CAAqB,EAAC,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE;gBAC/D,OAAO,sBAAsB,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC;YAC7D,CAAC,CAAC;YACJ,CAAC,CAAC,KAAK;KACV,CAAC,CACE,CAAC;AACT,CAAC,CAAC;AAzCW,QAAA,wBAAwB,4BAyCnC"}
|
|
@@ -46,7 +46,9 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
46
46
|
const additionalEnvVars = deployConfigRaw
|
|
47
47
|
? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext)
|
|
48
48
|
: {};
|
|
49
|
-
|
|
49
|
+
// deploy types provide HOSTNAME_INTERNAL as a plain string or bash
|
|
50
|
+
// expression (never containing references)
|
|
51
|
+
const HOSTNAME_INTERNAL = ((_b = additionalEnvVars.HOSTNAME_INTERNAL) !== null && _b !== void 0 ? _b : "unknown-host.example.com");
|
|
50
52
|
host = (_c = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _c !== void 0 ? _c : HOSTNAME_INTERNAL;
|
|
51
53
|
url = (0, bash_1.joinBashExpressions)(["https://", host]);
|
|
52
54
|
predefinedVariables = {
|
|
@@ -74,8 +76,18 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
74
76
|
componentName: ctx.componentName,
|
|
75
77
|
}),
|
|
76
78
|
]));
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
// predefined variables may contain references too (e.g. the embedded
|
|
80
|
+
// database connection string references the component's own DB_* vars), so
|
|
81
|
+
// we resolve references over the merged map. This way public var overrides
|
|
82
|
+
// (like DB_PASSWORD: "${otherComponent:DB_PASSWORD}") are picked up by the
|
|
83
|
+
// predefined variables that reference them
|
|
84
|
+
const mergedEnvVars = {
|
|
85
|
+
...predefinedVariables,
|
|
86
|
+
...secretEnvVars,
|
|
87
|
+
...publicEnvVarsUnresolved,
|
|
88
|
+
};
|
|
89
|
+
const resolvedEnvVars = ((_g = options.shouldResolveReferences) !== null && _g !== void 0 ? _g : true)
|
|
90
|
+
? await (0, bash_3.resolveAllReferences)(mergedEnvVars, async (otherComponentName) => {
|
|
79
91
|
const { envVars: otherEnvVars } = await (0, exports.getEnvironmentVariables)({
|
|
80
92
|
...ctx,
|
|
81
93
|
componentName: otherComponentName,
|
|
@@ -84,12 +96,8 @@ const getEnvironmentVariables = async (ctx, options = {}) => {
|
|
|
84
96
|
});
|
|
85
97
|
return otherEnvVars;
|
|
86
98
|
})
|
|
87
|
-
:
|
|
88
|
-
const envVars = addIndexVar(
|
|
89
|
-
...predefinedVariables,
|
|
90
|
-
...secretEnvVars,
|
|
91
|
-
...publicEnvVars,
|
|
92
|
-
});
|
|
99
|
+
: mergedEnvVars;
|
|
100
|
+
const envVars = addIndexVar(resolvedEnvVars);
|
|
93
101
|
return {
|
|
94
102
|
envVars,
|
|
95
103
|
secretEnvVarKeys,
|