@catladder/pipeline 1.89.4 → 1.90.0

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.
@@ -0,0 +1,25 @@
1
+ import type { Config } from "../src";
2
+ import { createAllPipelines } from "./__utils__/helpers";
3
+
4
+ const config: Config = {
5
+ appName: "test-app",
6
+ customerName: "pan",
7
+ components: {
8
+ www: {
9
+ dir: "www",
10
+ build: {
11
+ type: "node",
12
+ },
13
+ deploy: {
14
+ type: "custom",
15
+ requiresDocker: true,
16
+ script: ["echo 'would deploy'"],
17
+ stopScript: ["echo 'would stop'"],
18
+ },
19
+ },
20
+ },
21
+ };
22
+
23
+ it("matches snapshot", async () => {
24
+ expect(await createAllPipelines(config)).toMatchSnapshot();
25
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catladder/pipeline",
3
- "version": "1.89.4",
3
+ "version": "1.90.0",
4
4
  "scripts": {
5
5
  "build:tsc": "yarn tsc",
6
6
  "build": "yarn build:compile && yarn build:inline-variables && yarn build:bundle",
@@ -9,6 +9,11 @@ import {
9
9
  translateLegacyFromComponents,
10
10
  } from "./resolveReferences";
11
11
 
12
+ export type SecretEnvVar = {
13
+ key: string;
14
+ // hidden env vars are not shown in config-secrets
15
+ hidden?: boolean;
16
+ };
12
17
  export const getEnvironmentVariables = async (
13
18
  config: Config,
14
19
  componentName: string,
@@ -17,7 +22,7 @@ export const getEnvironmentVariables = async (
17
22
  alreadyVisited: Record<string, Record<string, boolean>> = {} // to prevent endless loop
18
23
  ): Promise<{
19
24
  envVars: Record<string, string>;
20
- secretEnvVarKeys: string[];
25
+ secretEnvVarKeys: SecretEnvVar[];
21
26
  host: string;
22
27
  url: string;
23
28
  }> => {
@@ -81,12 +86,12 @@ export const getEnvironmentVariables = async (
81
86
  )
82
87
  : [];
83
88
 
84
- const secretEnvVarKeys = [
85
- ...(envConfigRaw.vars?.secret ?? []),
89
+ const secretEnvVarKeys: SecretEnvVar[] = [
90
+ ...(envConfigRaw.vars?.secret ?? []).map((key) => ({ key })),
86
91
  ...additionalSecretKeys,
87
92
  ];
88
93
  const secretEnvVars = Object.fromEntries(
89
- secretEnvVarKeys.map((key) => [
94
+ secretEnvVarKeys.map(({ key }) => [
90
95
  key,
91
96
  `$${getSecretVarName(env, componentName, key)}`,
92
97
  ])
@@ -1,5 +1,5 @@
1
1
  import { dump } from "js-yaml";
2
- import { isNil, merge, omit } from "lodash";
2
+ import { merge, omit } from "lodash";
3
3
  import { GCLOUD_DEPLOY_CREDENTIALS_KEY } from ".";
4
4
  import { getDockerJobBaseProps, gitlabDockerLogin } from "../../build/docker";
5
5
  import { getLabels } from "../../context/getLabels";
@@ -58,9 +58,16 @@ export const GCLOUD_RUN_DEPLOY_TYPE: DeployTypeDefinition<"google-cloudrun"> = {
58
58
  return {};
59
59
  },
60
60
  additionalSecretKeys: (ctx) => [
61
- GCLOUD_DEPLOY_CREDENTIALS_KEY,
61
+ {
62
+ key: GCLOUD_DEPLOY_CREDENTIALS_KEY,
63
+ hidden: true,
64
+ },
65
+ {
66
+ key: GCLOUD_RUN_CANONICAL_HOST_SUFFIX,
67
+ hidden: true,
68
+ },
62
69
  ...(ctx.deployConfigRaw && ctx.deployConfigRaw.cloudSql
63
- ? ["DB_PASSWORD"]
70
+ ? [{ key: "DB_PASSWORD" }]
64
71
  : []),
65
72
  ],
66
73
  getAdditionalEnvVars: (ctx) => {
@@ -4,7 +4,7 @@ import { getYarnInstall } from "../../build/node/yarn";
4
4
  import { getRunnerImage } from "../../runner";
5
5
  import type { Context } from "../../types/context";
6
6
  import type { CatladderJob } from "../../types/jobs";
7
- import { getBaseDeploymentJob } from "../base";
7
+ import { getBaseDeploymentJob, getBaseDeploymentStopJob } from "../base";
8
8
  import { isOfDeployType } from "../types";
9
9
 
10
10
  export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
@@ -29,5 +29,13 @@ export const createCustomDeployJobs = (context: Context): CatladderJob[] => {
29
29
  ...deployConfig.script,
30
30
  ],
31
31
  }),
32
+ ...(deployConfig.stopScript
33
+ ? [
34
+ merge({}, getBaseDeploymentStopJob(context), {
35
+ image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
36
+ script: deployConfig.stopScript,
37
+ }),
38
+ ]
39
+ : []),
32
40
  ];
33
41
  };
@@ -1,3 +1,4 @@
1
+ import type { SecretEnvVar } from "..";
1
2
  import type { Context } from "../types/context";
2
3
  import type { EnvironmentContext } from "../types/environmentContext";
3
4
  import type { CatladderJob } from "../types/jobs";
@@ -17,7 +18,9 @@ export type DeployTypeDefinition<T extends DeployConfigType> = {
17
18
  defaults: (
18
19
  envContext: EnvironmentContext<any, T>
19
20
  ) => PartialDeep<DeployConfigGeneric<T>>;
20
- additionalSecretKeys: (envContext: EnvironmentContext<any, T>) => string[];
21
+ additionalSecretKeys: (
22
+ envContext: EnvironmentContext<any, T>
23
+ ) => SecretEnvVar[];
21
24
  getAdditionalEnvVars: (
22
25
  envContext: EnvironmentContext<any, T>
23
26
  ) => Record<string, string | undefined | null>;
@@ -19,5 +19,5 @@ export const additionalKubernetesSecretKeys = ({
19
19
  keys.push("cloudsqlProxyCredentials");
20
20
  }
21
21
 
22
- return keys;
22
+ return keys.map((key) => ({ key }));
23
23
  };
@@ -1,3 +1,4 @@
1
+ import type { SecretEnvVar } from "../context";
1
2
  import type {
2
3
  PipelineTrigger,
3
4
  ComponentConfig,
@@ -25,7 +26,7 @@ export type Environment = {
25
26
  */
26
27
  envVars: Record<string, string>;
27
28
  envType: EnvType;
28
- secretEnvVarKeys: string[];
29
+ secretEnvVarKeys: SecretEnvVar[];
29
30
  };
30
31
 
31
32
  export type CommitInfo = {