@catladder/pipeline 0.0.0-refactor-cache-1b2d6c36 → 0.0.0-refactor-resolve-references-862e93ac
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/bash/BashExpression.d.ts +3 -1
- package/dist/bash/BashExpression.js +11 -2
- package/dist/bash/bashYaml.js +23 -2
- package/dist/bash/replaceAsync.d.ts +1 -1
- package/dist/bash/replaceAsync.js +2 -2
- package/dist/build/cache/createJobCache.js +7 -1
- package/dist/build/docker.js +1 -1
- package/dist/bundles/catladder-gitlab/index.js +672 -514
- package/dist/constants.js +1 -1
- package/dist/context/getEnvironmentVariables.d.ts +1 -1
- package/dist/context/getEnvironmentVariables.js +42 -25
- package/dist/context/resolveReferences.d.ts +0 -3
- package/dist/context/resolveReferences.js +1 -245
- package/dist/deploy/cloudRun/createJobs/cloudRunServices.js +2 -0
- package/dist/deploy/kubernetes/cloudSql/index.d.ts +2 -2
- package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -3
- package/dist/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +2 -2
- package/dist/deploy/types/googleCloudRun.d.ts +7 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +2 -1
- package/dist/variables/VariableValue.d.ts +3 -0
- package/dist/variables/VariableValue.js +5 -0
- package/dist/variables/VariableValueContainingReferences.d.ts +25 -0
- package/dist/variables/VariableValueContainingReferences.js +93 -0
- package/dist/variables/__tests__/replaceAllReferences.test.js +219 -0
- package/dist/variables/__tests__/replaceAllReferencesOnce.test.d.ts +1 -0
- package/dist/variables/__tests__/replaceAllReferencesOnce.test.js +171 -0
- package/dist/variables/__tests__/replaceReferencesOnce.test.d.ts +1 -0
- package/dist/variables/__tests__/replaceReferencesOnce.test.js +202 -0
- package/dist/variables/__tests__/variableValue.test.d.ts +1 -0
- package/dist/variables/__tests__/variableValue.test.js +36 -0
- package/dist/variables/replaceAllReferences.d.ts +3 -0
- package/dist/variables/replaceAllReferences.js +191 -0
- package/dist/variables/replaceAllReferencesOnce.d.ts +5 -0
- package/dist/variables/replaceAllReferencesOnce.js +191 -0
- package/dist/variables/replaceReferencesOnce.d.ts +8 -0
- package/dist/variables/replaceReferencesOnce.js +22 -0
- package/examples/__snapshots__/cloud-run-http2.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +1346 -0
- package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +44 -40
- package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +40 -36
- package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +90 -82
- package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +45 -41
- package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +40 -36
- package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +40 -36
- package/examples/__snapshots__/custom-build-job.test.ts.snap +40 -36
- package/examples/__snapshots__/custom-deploy.test.ts.snap +4 -0
- package/examples/__snapshots__/custom-sbom-java.test.ts.snap +40 -36
- package/examples/__snapshots__/git-submodule.test.ts.snap +40 -36
- package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +24 -20
- package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +33 -29
- package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +33 -29
- package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +48 -40
- package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +32 -28
- package/examples/__snapshots__/local-dot-env.test.ts.snap +40 -36
- package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +29 -25
- package/examples/__snapshots__/multiline-var.test.ts.snap +2971 -1049
- package/examples/__snapshots__/native-app.test.ts.snap +40 -36
- package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +40 -36
- package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +40 -36
- package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +36 -32
- package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +36 -32
- package/examples/__snapshots__/referencing-other-vars.test.ts.snap +4535 -0
- package/examples/__snapshots__/workspace-api-www-custom-cache.test.ts.snap +84 -76
- package/examples/__snapshots__/workspace-api-www.test.ts.snap +84 -76
- package/examples/cloud-run-service-custom-vpc-connector.test.ts +11 -0
- package/examples/cloud-run-service-custom-vpc-connector.ts +30 -0
- package/examples/cloud-run-service-custom-vpc.ts +2 -1
- package/examples/multiline-var.ts +57 -15
- package/examples/referencing-other-vars.test.ts +11 -0
- package/examples/referencing-other-vars.ts +83 -0
- package/package.json +1 -1
- package/src/bash/BashExpression.ts +20 -3
- package/src/bash/bashYaml.ts +35 -2
- package/src/bash/replaceAsync.ts +8 -9
- package/src/build/cache/createJobCache.ts +2 -1
- package/src/build/docker.ts +1 -1
- package/src/context/getEnvironmentVariables.ts +32 -22
- package/src/context/resolveReferences.ts +0 -81
- package/src/deploy/cloudRun/createJobs/cloudRunServices.ts +2 -0
- package/src/deploy/kubernetes/cloudSql/index.ts +2 -1
- package/src/deploy/kubernetes/kubeEnv.ts +3 -3
- package/src/deploy/kubernetes/processSecretsAsFiles.ts +2 -1
- package/src/deploy/types/googleCloudRun.ts +10 -2
- package/src/types/context.ts +2 -1
- package/src/variables/VariableValue.ts +6 -0
- package/src/variables/VariableValueContainingReferences.ts +83 -0
- package/src/variables/__tests__/replaceAllReferences.test.ts +110 -0
- package/src/variables/__tests__/replaceAllReferencesOnce.test.ts +64 -0
- package/src/variables/__tests__/replaceReferencesOnce.test.ts +117 -0
- package/src/variables/__tests__/variableValue.test.ts +73 -0
- package/src/variables/replaceAllReferences.ts +47 -0
- package/src/variables/replaceAllReferencesOnce.ts +44 -0
- package/src/variables/replaceReferencesOnce.ts +29 -0
- package/dist/context/__tests__/resolveReferences.test.js +0 -368
- package/src/context/__tests__/resolveReferences.test.ts +0 -148
- /package/dist/{context/__tests__/resolveReferences.test.d.ts → variables/__tests__/replaceAllReferences.test.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VariableValue } from "../variables/VariableValue";
|
|
1
2
|
/**
|
|
2
3
|
* this class represents a string that can be evaluated in bash scripts.
|
|
3
4
|
*
|
|
@@ -8,6 +9,7 @@ export declare class BashExpression {
|
|
|
8
9
|
constructor(value: string | BashExpression);
|
|
9
10
|
toJSON(): string;
|
|
10
11
|
toString(): string;
|
|
12
|
+
replace(searchValue: any, replacer: (substring: string, ...args: any[]) => string): BashExpression;
|
|
11
13
|
/**
|
|
12
14
|
*
|
|
13
15
|
* @returns a bash expression to lowercase the string
|
|
@@ -37,4 +39,4 @@ export declare const joinBashExpressions: (parts: Array<StringOrBashExpression>,
|
|
|
37
39
|
* escapes a string or bash expression for bash
|
|
38
40
|
* it mainly escapes double quotes
|
|
39
41
|
*/
|
|
40
|
-
export declare const bashEscape: (value:
|
|
42
|
+
export declare const bashEscape: (value: VariableValue | any) => any;
|
|
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
35
35
|
value: true
|
|
36
36
|
});
|
|
37
37
|
exports.bashEscape = exports.joinBashExpressions = exports.getBashVariable = exports.BashExpression = void 0;
|
|
38
|
+
var VariableValueContainingReferences_1 = require("../variables/VariableValueContainingReferences");
|
|
38
39
|
/**
|
|
39
40
|
* this class represents a string that can be evaluated in bash scripts.
|
|
40
41
|
*
|
|
@@ -50,6 +51,9 @@ var BashExpression = /** @class */function () {
|
|
|
50
51
|
BashExpression.prototype.toString = function () {
|
|
51
52
|
return this.value.toString();
|
|
52
53
|
};
|
|
54
|
+
BashExpression.prototype.replace = function (searchValue, replacer) {
|
|
55
|
+
return new BashExpression(this.value.toString().replace(searchValue, replacer));
|
|
56
|
+
};
|
|
53
57
|
/**
|
|
54
58
|
*
|
|
55
59
|
* @returns a bash expression to lowercase the string
|
|
@@ -117,8 +121,13 @@ var bashEscape = function (value) {
|
|
|
117
121
|
if (value instanceof BashExpression) {
|
|
118
122
|
return value.toString(); // no need to escape bash expressions, as we want them to evaluate
|
|
119
123
|
}
|
|
124
|
+
|
|
125
|
+
if (value instanceof VariableValueContainingReferences_1.VariableValueContainingReferences) {
|
|
126
|
+
return value.toString({
|
|
127
|
+
escapeQuotes: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
120
130
|
// we wrap it in double quotes, so we need to escape them
|
|
121
|
-
|
|
122
|
-
return value;
|
|
131
|
+
return value === null || value === void 0 ? void 0 : value.toString().replace(/"/g, '\\"');
|
|
123
132
|
};
|
|
124
133
|
exports.bashEscape = bashEscape;
|
package/dist/bash/bashYaml.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.writeBashYamlToFileScript = exports.yamlBashString = void 0;
|
|
7
7
|
var yaml_1 = require("yaml");
|
|
8
8
|
var BashExpression_1 = require("./BashExpression");
|
|
9
|
+
var VariableValueContainingReferences_1 = require("../variables/VariableValueContainingReferences");
|
|
9
10
|
var bashExpressionType = {
|
|
10
11
|
tag: "",
|
|
11
12
|
resolve: function (str) {
|
|
@@ -16,12 +17,32 @@ var bashExpressionType = {
|
|
|
16
17
|
// we create a BLOCK_LITERAL
|
|
17
18
|
// but because bash will interpret the value, it may resolve to a multiline string
|
|
18
19
|
// so we need to indent every line using sed
|
|
19
|
-
return "|-\n" + node.value
|
|
20
|
+
return "|-\n" + ctx.indent + indentNewlinesInBashExpression(node.value, ctx.indent);
|
|
20
21
|
},
|
|
21
22
|
identify: function (v) {
|
|
22
23
|
return v instanceof BashExpression_1.BashExpression;
|
|
23
24
|
}
|
|
24
25
|
};
|
|
26
|
+
var indentNewlinesInBashExpression = function (expression, indent) {
|
|
27
|
+
return expression.transformWithCommand("sed '1!s/^/".concat(indent, "/'"));
|
|
28
|
+
};
|
|
29
|
+
var variableContainingReferences = {
|
|
30
|
+
tag: "",
|
|
31
|
+
resolve: function (str) {
|
|
32
|
+
// not really needed,but let's make typescript happy
|
|
33
|
+
return new VariableValueContainingReferences_1.VariableValueContainingReferences(str);
|
|
34
|
+
},
|
|
35
|
+
stringify: function (node, ctx) {
|
|
36
|
+
var value = node.value;
|
|
37
|
+
var stringified = value.parts.map(function (part) {
|
|
38
|
+
return part instanceof BashExpression_1.BashExpression ? indentNewlinesInBashExpression(part, ctx.indent) : part.toString().replace(/\n/g, "\n".concat(ctx.indent));
|
|
39
|
+
}).join("");
|
|
40
|
+
return "|-\n" + ctx.indent + stringified;
|
|
41
|
+
},
|
|
42
|
+
identify: function (v) {
|
|
43
|
+
return v instanceof VariableValueContainingReferences_1.VariableValueContainingReferences;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
25
46
|
/***
|
|
26
47
|
* creates a yaml string that can be used in bash scripts
|
|
27
48
|
* it handles BashExpressions correctly so that they can be evaluated in bash
|
|
@@ -30,7 +51,7 @@ var yamlBashString = function (value) {
|
|
|
30
51
|
return (0, yaml_1.stringify)(value, {
|
|
31
52
|
defaultStringType: "BLOCK_LITERAL",
|
|
32
53
|
defaultKeyType: "PLAIN",
|
|
33
|
-
customTags: [bashExpressionType],
|
|
54
|
+
customTags: [bashExpressionType, variableContainingReferences],
|
|
34
55
|
aliasDuplicateObjects: false,
|
|
35
56
|
lineWidth: 0
|
|
36
57
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { BashExpression } from "./BashExpression";
|
|
2
|
-
export default function replaceAsync(string: string | BashExpression, searchValue: any, replacer: (substring: string, ...args: any[]) => Promise<string | BashExpression>): Promise<
|
|
2
|
+
export default function replaceAsync(string: string | BashExpression, searchValue: any, replacer: (substring: string, ...args: any[]) => Promise<string | BashExpression>): Promise<any>;
|
|
@@ -132,7 +132,7 @@ function replaceAsync(string, searchValue, replacer) {
|
|
|
132
132
|
case 1:
|
|
133
133
|
_a.trys.push([1, 3,, 4]);
|
|
134
134
|
values_1 = [];
|
|
135
|
-
String.prototype.replace.call(string.
|
|
135
|
+
String.prototype.replace.call(string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string), searchValue, function () {
|
|
136
136
|
var args = [];
|
|
137
137
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
138
138
|
args[_i] = arguments[_i];
|
|
@@ -148,7 +148,7 @@ function replaceAsync(string, searchValue, replacer) {
|
|
|
148
148
|
containsBashExpression = resolvedValues_1.some(function (value) {
|
|
149
149
|
return value instanceof BashExpression_1.BashExpression;
|
|
150
150
|
});
|
|
151
|
-
result =
|
|
151
|
+
result = (string instanceof BashExpression_1.BashExpression ? string : (0, BashExpression_1.bashEscape)(string)).replace(searchValue, function () {
|
|
152
152
|
var _a, _b;
|
|
153
153
|
return (_b = (_a = resolvedValues_1.shift()) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "";
|
|
154
154
|
});
|
|
@@ -49,12 +49,18 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
|
49
49
|
}
|
|
50
50
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
51
|
};
|
|
52
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
53
|
+
return mod && mod.__esModule ? mod : {
|
|
54
|
+
"default": mod
|
|
55
|
+
};
|
|
56
|
+
};
|
|
52
57
|
Object.defineProperty(exports, "__esModule", {
|
|
53
58
|
value: true
|
|
54
59
|
});
|
|
55
60
|
exports.createJobCacheFromConfig = exports.createJobCacheFromCacheConfigs = void 0;
|
|
56
61
|
var path_1 = require("path");
|
|
57
62
|
var getAllCacheConfigsFromConfig_1 = require("./getAllCacheConfigsFromConfig");
|
|
63
|
+
var slugify_1 = __importDefault(require("slugify"));
|
|
58
64
|
var createJobCacheFromCacheConfigs = function (context, caches) {
|
|
59
65
|
if (caches.length === 0) return undefined;
|
|
60
66
|
var simpleCacheDefs = caches.filter(function (c) {
|
|
@@ -86,7 +92,7 @@ var createJobCacheFromCacheConfigs = function (context, caches) {
|
|
|
86
92
|
rest = __rest(_a, ["key", "paths", "policy", "scope", "pathMode", "buildDir"]);
|
|
87
93
|
var baseDir = pathMode === "absolute" ? "" : buildDir !== null && buildDir !== void 0 ? buildDir : context.build.dir;
|
|
88
94
|
var transformedKey = scope === "global" ? key : typeof key === "string" ? (scope === "buildDir" // really edge case...
|
|
89
|
-
? baseDir : context.name) + "-" + key : __assign(__assign({}, key), {
|
|
95
|
+
? (0, slugify_1.default)(baseDir) : context.name) + "-" + key : __assign(__assign({}, key), {
|
|
90
96
|
files: (_b = key.files) === null || _b === void 0 ? void 0 : _b.map(function (f) {
|
|
91
97
|
return pathMode === "absolute" ? f : (0, path_1.join)(baseDir, f);
|
|
92
98
|
})
|
package/dist/build/docker.js
CHANGED
|
@@ -135,7 +135,7 @@ var getDockerJobBaseProps = function () {
|
|
|
135
135
|
services: [{
|
|
136
136
|
name: "docker:24.0.6-dind",
|
|
137
137
|
// see see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27300#note_466755332
|
|
138
|
-
command: ["--tls=false"]
|
|
138
|
+
command: ["--tls=false", "--registry-mirror=https://mirror.gcr.io"]
|
|
139
139
|
}],
|
|
140
140
|
variables: {},
|
|
141
141
|
runnerVariables: getDockerBuildRunnerVariables()
|