@catladder/pipeline 0.0.0-refactor-gcloud-api-27052869 → 0.0.0-refactor-needs-aae6e67d

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.
Files changed (69) hide show
  1. package/dist/build/custom/buildJob.js +1 -0
  2. package/dist/build/index.js +7 -1
  3. package/dist/build/rails/build.js +41 -16
  4. package/dist/build/rails/index.d.ts +2 -2
  5. package/dist/build/types.d.ts +36 -4
  6. package/dist/bundles/catladder-gitlab/index.js +125 -54
  7. package/dist/constants.js +1 -1
  8. package/dist/context/__tests__/resolveReferences.test.js +15 -20
  9. package/dist/context/getEnvironment.js +1 -0
  10. package/dist/context/getEnvironmentContext.js +5 -3
  11. package/dist/context/getEnvironmentVariables.js +2 -2
  12. package/dist/context/resolveReferences.d.ts +1 -1
  13. package/dist/context/resolveReferences.js +3 -1
  14. package/dist/deploy/base.js +1 -1
  15. package/dist/deploy/cloudRun/deployJob.js +9 -7
  16. package/dist/deploy/cloudRun/index.js +7 -6
  17. package/dist/deploy/cloudRun/utils/createArgsString.d.ts +1 -1
  18. package/dist/deploy/cloudRun/utils/createArgsString.js +6 -1
  19. package/dist/deploy/kubernetes/deployJob.js +4 -4
  20. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -0
  21. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +3 -0
  22. package/dist/deploy/types/custom.d.ts +2 -1
  23. package/dist/deploy/types/googleCloudRun.d.ts +11 -2
  24. package/dist/deploy/types/kubernetes.d.ts +11 -0
  25. package/dist/pipeline/createJobs.js +4 -9
  26. package/dist/pipeline/gitlab/makeGitlabJob.js +33 -2
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/dist/types/context.d.ts +1 -0
  29. package/dist/types/environmentContext.d.ts +7 -0
  30. package/dist/types/gitlab-types.d.ts +25 -1
  31. package/dist/types/jobs.d.ts +9 -2
  32. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +1572 -0
  33. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +1572 -0
  34. package/examples/__snapshots__/cloud-run-non-public.ts.snap +48 -48
  35. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +3116 -0
  36. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +108 -108
  37. package/examples/__snapshots__/custom-build-job.ts.snap +48 -48
  38. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +24 -24
  39. package/examples/__snapshots__/rails-k8s-with-worker.ts.snap +1911 -0
  40. package/examples/cloud-run-memory-limit.ts +28 -0
  41. package/examples/cloud-run-no-cpu-throttling.ts +33 -0
  42. package/examples/cloud-run-with-sql-reuse-db.ts +54 -0
  43. package/examples/cloud-run-with-sql.ts +1 -1
  44. package/examples/rails-k8s-with-worker.ts +95 -0
  45. package/package.json +1 -1
  46. package/src/build/custom/buildJob.ts +1 -0
  47. package/src/build/index.ts +7 -1
  48. package/src/build/rails/build.ts +17 -10
  49. package/src/build/rails/index.ts +2 -2
  50. package/src/build/types.ts +40 -5
  51. package/src/context/__tests__/resolveReferences.test.ts +15 -30
  52. package/src/context/getEnvironment.ts +1 -0
  53. package/src/context/getEnvironmentContext.ts +6 -6
  54. package/src/context/getEnvironmentVariables.ts +7 -5
  55. package/src/context/resolveReferences.ts +3 -6
  56. package/src/deploy/base.ts +1 -1
  57. package/src/deploy/cloudRun/deployJob.ts +9 -11
  58. package/src/deploy/cloudRun/index.ts +5 -4
  59. package/src/deploy/cloudRun/utils/createArgsString.ts +9 -2
  60. package/src/deploy/kubernetes/deployJob.ts +1 -1
  61. package/src/deploy/types/custom.ts +2 -1
  62. package/src/deploy/types/googleCloudRun.ts +14 -2
  63. package/src/deploy/types/kubernetes.ts +12 -0
  64. package/src/pipeline/createJobs.ts +14 -17
  65. package/src/pipeline/gitlab/makeGitlabJob.ts +3 -1
  66. package/src/types/context.ts +1 -0
  67. package/src/types/environmentContext.ts +7 -0
  68. package/src/types/gitlab-types.ts +18 -1
  69. package/src/types/jobs.ts +11 -2
@@ -64,6 +64,7 @@ var createCustomBuildJobs = function (context) {
64
64
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
65
65
  image: buildConfig.jobImage,
66
66
  variables: __assign({}, RUNNER_BUILD_VARIABLES),
67
+ cache: buildConfig.jobCache,
67
68
  services: buildConfig.jobServices,
68
69
  script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
69
70
  artifacts: {
@@ -65,7 +65,13 @@ exports.BUILD_TYPES = {
65
65
  rails: {
66
66
  jobs: rails_1.createRailsJobs,
67
67
  defaults: function () {
68
- return {};
68
+ return {
69
+ startCommand: "/cnb/process/web",
70
+ cnbBuilder: {
71
+ image: "heroku/buildpacks:20",
72
+ packVersion: "0.28.0"
73
+ }
74
+ };
69
75
  }
70
76
  }
71
77
  };
@@ -1,30 +1,55 @@
1
1
  "use strict";
2
2
 
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3
+ var __read = this && this.__read || function (o, n) {
4
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
5
+ if (!m) return o;
6
+ var i = m.call(o),
7
+ r,
8
+ ar = [],
9
+ e;
10
+ try {
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
+ } catch (error) {
13
+ e = {
14
+ error: error
15
+ };
16
+ } finally {
17
+ try {
18
+ if (r && !r.done && (m = i["return"])) m.call(i);
19
+ } finally {
20
+ if (e) throw e.error;
8
21
  }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
22
+ }
23
+ return ar;
12
24
  };
13
25
  exports.__esModule = true;
14
26
  exports.createRailsBuildJobs = void 0;
27
+ var types_1 = require("../types");
15
28
  var docker_1 = require("../docker");
16
29
  var createRailsBuildJobs = function (context) {
30
+ var _a, _b, _c, _d, _e, _f;
31
+ var buildConfig = context.componentConfig.build;
32
+ if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
33
+ // should not happen
34
+ throw new Error("build type is not rails");
35
+ }
36
+ var cnbConf = buildConfig.cnbBuilder;
37
+ // backwards compatabilty with CNB_ENV_VARS
38
+ // TODO: remove when all projects are migrated
39
+ var packEnvArgs = (_c = (_b = (_a = buildConfig.extraVars) === null || _a === void 0 ? void 0 : _a.CNB_ENV_VARS) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (v) {
40
+ return "--env '".concat(v, "'");
41
+ })) !== null && _c !== void 0 ? _c : Object.entries((_d = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
42
+ var _b = __read(_a, 2),
43
+ k = _b[0],
44
+ v = _b[1];
45
+ return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
46
+ });
17
47
  return [(0, docker_1.createDockerBuildJobBase)(context, {
18
- variables: __assign({
19
- CNB_BUILDER: "heroku/buildpacks:18",
20
- CNB_ENV_VARS: "BUNDLE_GIT__PANTER__CH",
21
- CNB_EXTRA_ARGS: "",
22
- CNB_PACK_VERSION: "0.20.0"
23
- }, context.componentConfig.build.extraVars),
48
+ variables: context.componentConfig.build.extraVars,
24
49
  // custom script
25
- script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$CNB_PACK_VERSION/pack-v$CNB_PACK_VERSION-linux.tgz | tar -zx --directory /usr/local/bin pack", "chmod +x /usr/local/bin/pack",
50
+ script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
26
51
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
27
- "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "for v in $CNB_ENV_VARS; do env_args=\"$env_args --env $v\"; done", "pack build $DOCKER_IMAGE:$DOCKER_IMAGE_TAG --builder $CNB_BUILDER --publish --cache-image $DOCKER_CACHE_IMAGE $env_args $CNB_EXTRA_ARGS"]
52
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs.join(" "), " ").concat((_f = (_e = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _e === void 0 ? void 0 : _e.join(" ")) !== null && _f !== void 0 ? _f : "")]
28
53
  })];
29
54
  };
30
55
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -1,3 +1,3 @@
1
- import { Context } from "../../types";
2
- import { CatladderJob } from "../../types/jobs";
1
+ import type { Context } from "../../types";
2
+ import type { CatladderJob } from "../../types/jobs";
3
3
  export declare const createRailsJobs: (context: Context) => CatladderJob[];
@@ -1,4 +1,5 @@
1
- import type { GitlabJobService } from "../types";
1
+ import type { GitlabJobImage, GitlabJobService } from "../types";
2
+ import type { CatladderJob } from "../types/jobs";
2
3
  export declare type BuildConfigBase = {
3
4
  /**
4
5
  * command to run on the image to start the app (e.g. yarn start)
@@ -24,21 +25,21 @@ export declare type BuildConfigBase = {
24
25
  */
25
26
  lint?: false | {
26
27
  command?: string | string[];
27
- jobImage?: string;
28
+ jobImage?: GitlabJobImage;
28
29
  };
29
30
  /**
30
31
  * customize test, set false to disable
31
32
  */
32
33
  test?: false | {
33
34
  command?: string | string[];
34
- jobImage?: string;
35
+ jobImage?: GitlabJobImage;
35
36
  };
36
37
  /**
37
38
  * customize audit, set false to disable
38
39
  */
39
40
  audit?: false | {
40
41
  command?: string | string[];
41
- jobImage?: string;
42
+ jobImage?: GitlabJobImage;
42
43
  };
43
44
  /**
44
45
  * additional paths for artifacts,
@@ -91,9 +92,40 @@ export declare type BuildConfigCustom = BuildConfigBase & {
91
92
  jobImage: string;
92
93
  jobServices?: GitlabJobService[];
93
94
  docker: BuildConfigCustomDocker;
95
+ /**
96
+ * customize cache for the job
97
+ */
98
+ jobCache?: CatladderJob["cache"];
94
99
  };
95
100
  export declare type BuildConfigRails = BuildConfigBase & {
96
101
  type: "rails";
102
+ cnbBuilder?: {
103
+ /**
104
+ * The Cloud Native Buildpacks builder image to use.
105
+ * See e.g. https://github.com/heroku/builder or others.
106
+ * Default: heroku/buildpacks:20
107
+ */
108
+ image?: string;
109
+ /**
110
+ * The version of the Cloud Native Buildpacks pack command to use.
111
+ * See https://buildpacks.io/docs/tools/pack/
112
+ * Default: 0.28.0
113
+ */
114
+ packVersion?: string;
115
+ /**
116
+ * Additional command arguments passed to the pack command.
117
+ * See https://buildpacks.io/docs/tools/pack/
118
+ */
119
+ packExtraArgs?: string[];
120
+ /**
121
+ * Variables needed for Bundler and Rails asset precompilation.
122
+ *
123
+ * Specify a key with the value `undefined` to inherit it from the EnvVars.
124
+ *
125
+ * See https://github.com/rails/rails/issues/32947
126
+ */
127
+ buildVars?: Record<string, string | undefined>;
128
+ };
97
129
  };
98
130
  export declare type BuildConfigStorybook = BuildConfigNodeBase & {
99
131
  type: "storybook";
@@ -27071,6 +27071,7 @@ var createCustomBuildJobs = function (context) {
27071
27071
  var appBuildJob = buildConfig.buildCommand !== null ? (0, createBuildJob_1.createBuildJob)(context, {
27072
27072
  image: buildConfig.jobImage,
27073
27073
  variables: __assign({}, RUNNER_BUILD_VARIABLES),
27074
+ cache: buildConfig.jobCache,
27074
27075
  services: buildConfig.jobServices,
27075
27076
  script: __spreadArray([], __read((_a = (0, utils_1.ensureArray)(buildConfig.buildCommand)) !== null && _a !== void 0 ? _a : []), false),
27076
27077
  artifacts: {
@@ -27352,7 +27353,13 @@ exports.BUILD_TYPES = {
27352
27353
  rails: {
27353
27354
  jobs: rails_1.createRailsJobs,
27354
27355
  defaults: function () {
27355
- return {};
27356
+ return {
27357
+ startCommand: "/cnb/process/web",
27358
+ cnbBuilder: {
27359
+ image: "heroku/buildpacks:20",
27360
+ packVersion: "0.28.0"
27361
+ }
27362
+ };
27356
27363
  }
27357
27364
  }
27358
27365
  };
@@ -27882,31 +27889,56 @@ exports.getYarnInstall = getYarnInstall;
27882
27889
  "use strict";
27883
27890
 
27884
27891
 
27885
- var __assign = this && this.__assign || function () {
27886
- __assign = Object.assign || function (t) {
27887
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27888
- s = arguments[i];
27889
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
27892
+ var __read = this && this.__read || function (o, n) {
27893
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27894
+ if (!m) return o;
27895
+ var i = m.call(o),
27896
+ r,
27897
+ ar = [],
27898
+ e;
27899
+ try {
27900
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27901
+ } catch (error) {
27902
+ e = {
27903
+ error: error
27904
+ };
27905
+ } finally {
27906
+ try {
27907
+ if (r && !r.done && (m = i["return"])) m.call(i);
27908
+ } finally {
27909
+ if (e) throw e.error;
27890
27910
  }
27891
- return t;
27892
- };
27893
- return __assign.apply(this, arguments);
27911
+ }
27912
+ return ar;
27894
27913
  };
27895
27914
  exports.__esModule = true;
27896
27915
  exports.createRailsBuildJobs = void 0;
27916
+ var types_1 = __nccwpck_require__(6575);
27897
27917
  var docker_1 = __nccwpck_require__(9953);
27898
27918
  var createRailsBuildJobs = function (context) {
27919
+ var _a, _b, _c, _d, _e, _f;
27920
+ var buildConfig = context.componentConfig.build;
27921
+ if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
27922
+ // should not happen
27923
+ throw new Error("build type is not rails");
27924
+ }
27925
+ var cnbConf = buildConfig.cnbBuilder;
27926
+ // backwards compatabilty with CNB_ENV_VARS
27927
+ // TODO: remove when all projects are migrated
27928
+ var packEnvArgs = (_c = (_b = (_a = buildConfig.extraVars) === null || _a === void 0 ? void 0 : _a.CNB_ENV_VARS) === null || _b === void 0 ? void 0 : _b.split(" ").map(function (v) {
27929
+ return "--env '".concat(v, "'");
27930
+ })) !== null && _c !== void 0 ? _c : Object.entries((_d = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
27931
+ var _b = __read(_a, 2),
27932
+ k = _b[0],
27933
+ v = _b[1];
27934
+ return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
27935
+ });
27899
27936
  return [(0, docker_1.createDockerBuildJobBase)(context, {
27900
- variables: __assign({
27901
- CNB_BUILDER: "heroku/buildpacks:18",
27902
- CNB_ENV_VARS: "BUNDLE_GIT__PANTER__CH",
27903
- CNB_EXTRA_ARGS: "",
27904
- CNB_PACK_VERSION: "0.20.0"
27905
- }, context.componentConfig.build.extraVars),
27937
+ variables: context.componentConfig.build.extraVars,
27906
27938
  // custom script
27907
- script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v$CNB_PACK_VERSION/pack-v$CNB_PACK_VERSION-linux.tgz | tar -zx --directory /usr/local/bin pack", "chmod +x /usr/local/bin/pack",
27939
+ script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
27908
27940
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
27909
- "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "for v in $CNB_ENV_VARS; do env_args=\"$env_args --env $v\"; done", "pack build $DOCKER_IMAGE:$DOCKER_IMAGE_TAG --builder $CNB_BUILDER --publish --cache-image $DOCKER_CACHE_IMAGE $env_args $CNB_EXTRA_ARGS"]
27941
+ "sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs.join(" "), " ").concat((_f = (_e = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _e === void 0 ? void 0 : _e.join(" ")) !== null && _f !== void 0 ? _f : "")]
27910
27942
  })];
27911
27943
  };
27912
27944
  exports.createRailsBuildJobs = createRailsBuildJobs;
@@ -28318,7 +28350,7 @@ exports.readConfigSync = readConfigSync;
28318
28350
 
28319
28351
  exports.__esModule = true;
28320
28352
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28321
- exports.PIPELINE_IMAGE_TAG = "refactor-gcloud-api-27052869" || 0;
28353
+ exports.PIPELINE_IMAGE_TAG = "refactor-needs-aae6e67d" || 0;
28322
28354
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28323
28355
 
28324
28356
  /***/ }),
@@ -28513,6 +28545,7 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
28513
28545
  url: url
28514
28546
  },
28515
28547
  fullName: envContext.fullName,
28548
+ slugPrefix: envContext.environmentSlugPrefix,
28516
28549
  slug: envContext.environmentSlug,
28517
28550
  shortName: env,
28518
28551
  envVars: envVars,
@@ -28536,20 +28569,22 @@ exports.__esModule = true;
28536
28569
  exports.getEnvironmentContext = void 0;
28537
28570
  var getEnvConfig_1 = __nccwpck_require__(1691);
28538
28571
  var getEnvType_1 = __nccwpck_require__(2187);
28539
- var getEnvironmentSlug = function (envConfig, env, componentName, commitInfo) {
28572
+ var getEnvironmentSlugPrefix = function (envConfig, env, commitInfo) {
28540
28573
  var envType = (0, getEnvType_1.getEnvType)(env, envConfig);
28541
- return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug, "-").concat(componentName) : "".concat(env, "-").concat(componentName);
28574
+ return envType === "review" && commitInfo ? "".concat(env, "-").concat(commitInfo.reviewSlug) : "".concat(env);
28542
28575
  };
28543
28576
  var getEnvironmentContext = function (config, env, componentName, commitInfo) {
28544
28577
  var envConfigRaw = (0, getEnvConfig_1.getEnvConfig)(config, componentName, env);
28545
28578
  var envType = (0, getEnvType_1.getEnvType)(env, envConfigRaw);
28546
- var environmentSlug = getEnvironmentSlug(envConfigRaw, env, componentName, commitInfo);
28579
+ var environmentSlugPrefix = getEnvironmentSlugPrefix(envConfigRaw, env, commitInfo);
28580
+ var environmentSlug = "".concat(environmentSlugPrefix, "-").concat(componentName);
28547
28581
  var gitlabEnvironmentName = envType === "review" && commitInfo ? "".concat(env, "/").concat(commitInfo.refName, "/").concat(componentName) : "".concat(env, "/").concat(componentName);
28548
28582
  var fullName = "".concat(config.customerName, "-").concat(config.appName, "-").concat(environmentSlug);
28549
28583
  return {
28550
28584
  envConfigRaw: envConfigRaw,
28551
28585
  deployConfigRaw: envConfigRaw.deploy,
28552
28586
  buildConfigRaw: envConfigRaw.build,
28587
+ environmentSlugPrefix: environmentSlugPrefix,
28553
28588
  environmentSlug: environmentSlug,
28554
28589
  gitlabEnvironmentName: gitlabEnvironmentName,
28555
28590
  fullName: fullName,
@@ -28785,7 +28820,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
28785
28820
  return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
28786
28821
  }));
28787
28822
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
28788
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, variableName, alreadyVisited) {
28823
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
28789
28824
  return __awaiter(void 0, void 0, void 0, function () {
28790
28825
  var otherEnvVars;
28791
28826
  return __generator(this, function (_a) {
@@ -28794,7 +28829,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
28794
28829
  return [4 /*yield*/, (0, exports.getEnvironmentVariables)(config, otherComponentName, env, commitInfo, alreadyVisited)];
28795
28830
  case 1:
28796
28831
  otherEnvVars = _a.sent().envVars;
28797
- return [2 /*return*/, otherEnvVars[variableName]];
28832
+ return [2 /*return*/, otherEnvVars];
28798
28833
  }
28799
28834
  });
28800
28835
  });
@@ -29242,7 +29277,9 @@ var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
29242
29277
 
29243
29278
  newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_c = {}, _c[componentName] = (_d = {}, _d[variableName] = true, _d), _c));
29244
29279
  if (!componentName) return [3 /*break*/, 2];
29245
- return [4 /*yield*/, getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, variableName, newAlreadyVisited)];
29280
+ return [4 /*yield*/, getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, newAlreadyVisited).then(function (r) {
29281
+ return r === null || r === void 0 ? void 0 : r[variableName];
29282
+ })];
29246
29283
  case 1:
29247
29284
  _a = (_f = _g.sent()) !== null && _f !== void 0 ? _f : null;
29248
29285
  return [3 /*break*/, 3];
@@ -29375,7 +29412,7 @@ var getBaseDeploymentJob = function (context) {
29375
29412
  return {
29376
29413
  name: exports.DEPLOY_JOB_NAME,
29377
29414
  envMode: "stagePerEnv",
29378
- needsOtherComponent: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29415
+ needs: context.componentConfig.deploy ? (_c = (_b = context.componentConfig.deploy.waitFor) === null || _b === void 0 ? void 0 : _b.map(function (c) {
29379
29416
  return {
29380
29417
  componentName: c,
29381
29418
  job: exports.DEPLOY_JOB_NAME,
@@ -29576,19 +29613,21 @@ var createGoogleCloudRunDeployJobs = function (context) {
29576
29613
  };
29577
29614
  });
29578
29615
  var getServiceDeployScript = function (service, nameSuffix) {
29579
- var _a, _b;
29616
+ var _a, _b, _c, _d;
29580
29617
  var customConfig = service !== true ? service : undefined;
29581
29618
  var command = service !== true ? (_a = service === null || service === void 0 ? void 0 : service.command) !== null && _a !== void 0 ? _a : context.componentConfig.build.startCommand : undefined;
29582
29619
  var argsString = (0, createArgsString_1.createArgsString)(__assign(__assign({
29583
- command: command ? '"' + command.split(" ").join(",") + '"' : undefined
29620
+ // command as empty string resets it to default (uses the image's entrypoint)
29621
+ command: command ? '"' + command.split(" ").join(",") + '"' : '""'
29584
29622
  }, commonDeployArgs), {
29585
29623
  "env-vars-file": "____envvars.yaml",
29586
- "min-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances,
29587
- "max-instances": customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances,
29588
- "no-cpu-throttling": customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling
29624
+ "min-instances": (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.minInstances) !== null && _b !== void 0 ? _b : 0,
29625
+ "max-instances": (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.maxInstances) !== null && _c !== void 0 ? _c : 100,
29626
+ "cpu-throttling": (customConfig === null || customConfig === void 0 ? void 0 : customConfig.noCpuThrottling) !== true,
29627
+ memory: customConfig === null || customConfig === void 0 ? void 0 : customConfig.memory,
29628
+ "allow-unauthenticated": (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _d !== void 0 ? _d : true
29589
29629
  }));
29590
- var authenticationString = ((_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.allowUnauthenticated) !== null && _b !== void 0 ? _b : true) ? "--allow-unauthenticated" : "--no-allow-unauthenticated";
29591
- return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(argsString, " ").concat(authenticationString);
29630
+ return "gcloud run deploy ".concat(serviceName).concat(nameSuffix !== null && nameSuffix !== void 0 ? nameSuffix : "", " ").concat(argsString);
29592
29631
  };
29593
29632
  var getJobCreateScriptsForJob = function (jobName, job) {
29594
29633
  // due to some oversight from google, jobs create does not accept `--env-vars-file` 🤦
@@ -29749,15 +29788,15 @@ var jobName_1 = __nccwpck_require__(9357);
29749
29788
  exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
29750
29789
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
29751
29790
  var getCloudSqlVariables = function (_a) {
29752
- var _b, _c, _d;
29791
+ var _b, _c, _d, _e;
29753
29792
  var deployConfigRaw = _a.deployConfigRaw,
29754
- environmentSlug = _a.environmentSlug,
29793
+ environmentSlugPrefix = _a.environmentSlugPrefix,
29755
29794
  env = _a.env,
29756
29795
  componentName = _a.componentName,
29757
29796
  fullConfig = _a.fullConfig;
29758
29797
  if (deployConfigRaw && deployConfigRaw.cloudSql) {
29759
- var DB_NAME = [(_b = deployConfigRaw.cloudSql.dbNamePrefix) !== null && _b !== void 0 ? _b : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlug].filter(Boolean).join("-");
29760
- var additionalQueryParamsString = Object.entries((_c = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _c !== void 0 ? _c : {}).map(function (_a) {
29798
+ var DB_NAME = [(_b = deployConfigRaw.cloudSql.dbNamePrefix) !== null && _b !== void 0 ? _b : "".concat(fullConfig.customerName, "-").concat(fullConfig.appName), environmentSlugPrefix, (_c = deployConfigRaw.cloudSql.dbBaseName) !== null && _c !== void 0 ? _c : componentName].filter(Boolean).join("-");
29799
+ var additionalQueryParamsString = Object.entries((_d = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _d !== void 0 ? _d : {}).map(function (_a) {
29761
29800
  var _b = __read(_a, 2),
29762
29801
  key = _b[0],
29763
29802
  value = _b[1];
@@ -29766,7 +29805,7 @@ var getCloudSqlVariables = function (_a) {
29766
29805
  return {
29767
29806
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
29768
29807
  DB_NAME: DB_NAME,
29769
- DB_USER: (_d = deployConfigRaw.cloudSql.dbUser) !== null && _d !== void 0 ? _d : "postgres",
29808
+ DB_USER: (_e = deployConfigRaw.cloudSql.dbUser) !== null && _e !== void 0 ? _e : "postgres",
29770
29809
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
29771
29810
  DATABASE_URL: "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME".concat(additionalQueryParamsString),
29772
29811
  DATABASE_JDBC_URL: "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD".concat(additionalQueryParamsString)
@@ -29792,11 +29831,12 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
29792
29831
  return __spreadArray([exports.GCLOUD_DEPLOY_CREDENTIALS_KEY], __read(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql ? ["DB_PASSWORD"] : []), false);
29793
29832
  },
29794
29833
  getAdditionalEnvVars: function (ctx) {
29834
+ var _a;
29795
29835
  var fullName = ctx.fullName,
29796
29836
  env = ctx.env,
29797
29837
  componentName = ctx.componentName,
29798
29838
  deployConfigRaw = ctx.deployConfigRaw;
29799
- var HOST_CANONICAL = fullName.toLowerCase() + "-" + process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)];
29839
+ var HOST_CANONICAL = fullName.toLowerCase() + "-" + ((_a = process.env[(0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)]) !== null && _a !== void 0 ? _a : "unknown-host.example.com");
29800
29840
  var jobTriggers = deployConfigRaw && deployConfigRaw.jobs ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(function (_a) {
29801
29841
  var _b = __read(_a, 2),
29802
29842
  name = _b[0],
@@ -29861,7 +29901,12 @@ var createArgsString = function (args) {
29861
29901
  var _b = __read(_a, 2),
29862
29902
  key = _b[0],
29863
29903
  value = _b[1];
29864
- return "--".concat(key).concat(value !== true ? "=".concat(value) : "");
29904
+ if (value === true) {
29905
+ return "--".concat(key);
29906
+ } else if (value === false) {
29907
+ return "--no-".concat(key);
29908
+ }
29909
+ return "--".concat(key, "=").concat(value);
29865
29910
  }).join(" ");
29866
29911
  };
29867
29912
  exports.createArgsString = createArgsString;
@@ -30281,7 +30326,7 @@ var base_1 = __nccwpck_require__(1188);
30281
30326
  var types_1 = __nccwpck_require__(4436);
30282
30327
  var kubeValues_1 = __nccwpck_require__(2830);
30283
30328
  var createKubernetesDeployJobs = function (context) {
30284
- var _a, _b;
30329
+ var _a, _b, _c;
30285
30330
  var deployConfig = context.componentConfig.deploy;
30286
30331
  if (deployConfig === false) {
30287
30332
  return [];
@@ -30305,10 +30350,10 @@ var createKubernetesDeployJobs = function (context) {
30305
30350
  quotingType: "'",
30306
30351
  forceQuotes: true
30307
30352
  }),
30308
- HELM_GITLAB_CHART_NAME: "the-panter-chart",
30309
- HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_a = deployConfig.additionalHelmArgs) !== null && _a !== void 0 ? _a : []), false).join(" "),
30353
+ HELM_GITLAB_CHART_NAME: (_a = deployConfig.chartName) !== null && _a !== void 0 ? _a : "/helm-charts/the-panter-chart",
30354
+ HELM_ARGS: __spreadArray(__spreadArray([], __read(deployConfig.debug ? ["--debug"] : []), false), __read((_b = deployConfig.additionalHelmArgs) !== null && _b !== void 0 ? _b : []), false).join(" "),
30310
30355
  COMPONENT_NAME: context.componentName,
30311
- BUILD_ID: (_b = context.commitInfo) === null || _b === void 0 ? void 0 : _b.buildId
30356
+ BUILD_ID: (_c = context.commitInfo) === null || _c === void 0 ? void 0 : _c.buildId
30312
30357
  })
30313
30358
  };
30314
30359
  var baseDeploymentJob = (0, base_1.getBaseDeploymentJob)(context);
@@ -31653,19 +31698,14 @@ var getFullReferencedJobName = function (referencedJobName, componentName, env,
31653
31698
  var replaceReferences = function (job, componentName, env, allRawJobs) {
31654
31699
  var _a, _b, _c;
31655
31700
  var stage = job.envMode === "stagePerEnv" ? "".concat(job.stage, " ").concat(env) : job.stage;
31656
- var needsFromNeeds = (_a = job.needs) === null || _a === void 0 ? void 0 : _a.map(function (n) {
31701
+ var cleanedNeeds = __spreadArray(__spreadArray([], __read((_a = job.needs) !== null && _a !== void 0 ? _a : []), false), __read((_b = job.needsOtherComponent) !== null && _b !== void 0 ? _b : []), false);
31702
+ var needs = cleanedNeeds === null || cleanedNeeds === void 0 ? void 0 : cleanedNeeds.map(function (n) {
31703
+ var _a;
31657
31704
  return (0, lodash_1.isObject)(n) ? {
31658
- job: getFullReferencedJobName(n.job, componentName, env, allRawJobs),
31705
+ job: getFullReferencedJobName(n.job, (_a = n.componentName) !== null && _a !== void 0 ? _a : componentName, env, allRawJobs),
31659
31706
  artifacts: n.artifacts
31660
31707
  } : getFullReferencedJobName(n, componentName, env, allRawJobs);
31661
31708
  });
31662
- var needsFromOtherComponents = (_b = job.needsOtherComponent) === null || _b === void 0 ? void 0 : _b.map(function (other) {
31663
- return {
31664
- artifacts: other.artifacts,
31665
- job: getFullReferencedJobName(other.job, other.componentName, env, allRawJobs)
31666
- };
31667
- });
31668
- var needs = __spreadArray(__spreadArray([], __read(needsFromNeeds !== null && needsFromNeeds !== void 0 ? needsFromNeeds : []), false), __read(needsFromOtherComponents !== null && needsFromOtherComponents !== void 0 ? needsFromOtherComponents : []), false);
31669
31709
  return __assign(__assign({}, job), {
31670
31710
  stage: stage,
31671
31711
  needs: needs,
@@ -31778,6 +31818,37 @@ var __rest = this && this.__rest || function (s, e) {
31778
31818
  }
31779
31819
  return t;
31780
31820
  };
31821
+ var __read = this && this.__read || function (o, n) {
31822
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
31823
+ if (!m) return o;
31824
+ var i = m.call(o),
31825
+ r,
31826
+ ar = [],
31827
+ e;
31828
+ try {
31829
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31830
+ } catch (error) {
31831
+ e = {
31832
+ error: error
31833
+ };
31834
+ } finally {
31835
+ try {
31836
+ if (r && !r.done && (m = i["return"])) m.call(i);
31837
+ } finally {
31838
+ if (e) throw e.error;
31839
+ }
31840
+ }
31841
+ return ar;
31842
+ };
31843
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
31844
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
31845
+ if (ar || !(i in from)) {
31846
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
31847
+ ar[i] = from[i];
31848
+ }
31849
+ }
31850
+ return to.concat(ar || Array.prototype.slice.call(from));
31851
+ };
31781
31852
  exports.__esModule = true;
31782
31853
  exports.makeGitlabJob = void 0;
31783
31854
  var lodash_1 = __nccwpck_require__(3255);
@@ -31794,9 +31865,9 @@ var makeGitlabJob = function (_a) {
31794
31865
  rest = __rest(_a, ["envMode", "needsStages", "needsOtherComponent", "name", "needs"]);
31795
31866
  return __assign(__assign({}, rest), {
31796
31867
  // sort in a predictable manner for snapshot tests
31797
- needs: needs === null || needs === void 0 ? void 0 : needs.sort(function (a, b) {
31868
+ needs: needs ? __spreadArray([], __read(needs), false).sort(function (a, b) {
31798
31869
  return getJobName(a).localeCompare(getJobName(b));
31799
- }),
31870
+ }) : undefined,
31800
31871
  retry: defaults_1.BASE_RETRY,
31801
31872
  interruptible: true
31802
31873
  });
package/dist/constants.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5
- exports.PIPELINE_IMAGE_TAG = "refactor-gcloud-api-27052869" || "";
5
+ exports.PIPELINE_IMAGE_TAG = "refactor-needs-aae6e67d" || "";
6
6
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
@@ -136,11 +136,10 @@ describe("resolveReferences", function () {
136
136
  FOO: "foo from frontend"
137
137
  }
138
138
  };
139
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
139
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
140
140
  return __awaiter(void 0, void 0, void 0, function () {
141
- var _a;
142
- return __generator(this, function (_b) {
143
- return [2 /*return*/, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
141
+ return __generator(this, function (_a) {
142
+ return [2 /*return*/, otherVariables[componentName]];
144
143
  });
145
144
  });
146
145
  })];
@@ -194,11 +193,10 @@ describe("resolveReferences", function () {
194
193
  FOO: "foo from api"
195
194
  }
196
195
  };
197
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
196
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
198
197
  return __awaiter(void 0, void 0, void 0, function () {
199
- var _a;
200
- return __generator(this, function (_b) {
201
- return [2 /*return*/, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
198
+ return __generator(this, function (_a) {
199
+ return [2 /*return*/, otherVariables[componentName]];
202
200
  });
203
201
  });
204
202
  })];
@@ -225,11 +223,10 @@ describe("resolveReferences", function () {
225
223
  b: "a not found value looks like this: '${api:FOO}'"
226
224
  };
227
225
  otherVariables = {};
228
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
226
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
229
227
  return __awaiter(void 0, void 0, void 0, function () {
230
- var _a;
231
- return __generator(this, function (_b) {
232
- return [2 /*return*/, (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]];
228
+ return __generator(this, function (_a) {
229
+ return [2 /*return*/, otherVariables[componentName]];
233
230
  });
234
231
  });
235
232
  })];
@@ -262,11 +259,10 @@ describe("resolveReferences", function () {
262
259
  FOO: "hi, ${api:FOO}"
263
260
  }
264
261
  };
265
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
262
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
266
263
  return __awaiter(void 0, void 0, void 0, function () {
267
- var _a, _b;
268
- return __generator(this, function (_c) {
269
- return [2 /*return*/, (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
264
+ return __generator(this, function (_a) {
265
+ return [2 /*return*/, otherVariables[componentName]];
270
266
  });
271
267
  });
272
268
  })];
@@ -298,11 +294,10 @@ describe("resolveReferences", function () {
298
294
  FOO: "frontend ${api:FOO}"
299
295
  }
300
296
  };
301
- return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName, variableName) {
297
+ return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(variables, function (componentName) {
302
298
  return __awaiter(void 0, void 0, void 0, function () {
303
- var _a, _b;
304
- return __generator(this, function (_c) {
305
- return [2 /*return*/, (_b = (_a = otherVariables[componentName]) === null || _a === void 0 ? void 0 : _a[variableName]) !== null && _b !== void 0 ? _b : ""];
299
+ return __generator(this, function (_a) {
300
+ return [2 /*return*/, otherVariables[componentName]];
306
301
  });
307
302
  });
308
303
  })];
@@ -139,6 +139,7 @@ var getEnvironment = function (config, componentName, env, commitInfo) {
139
139
  url: url
140
140
  },
141
141
  fullName: envContext.fullName,
142
+ slugPrefix: envContext.environmentSlugPrefix,
142
143
  slug: envContext.environmentSlug,
143
144
  shortName: env,
144
145
  envVars: envVars,