@vaharoni/devops 1.3.1 → 1.3.3

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConst
3
- } from "./chunk-6FEVIEFY.js";
3
+ } from "./chunk-VZ6XNNUH.js";
4
4
 
5
5
  // src/app-support/crypto/aes.ts
6
6
  import crypto from "crypto";
@@ -2,7 +2,7 @@ import {
2
2
  getConst,
3
3
  getImageData,
4
4
  globEnvYamlFiles
5
- } from "./chunk-6FEVIEFY.js";
5
+ } from "./chunk-VZ6XNNUH.js";
6
6
 
7
7
  // src/cli/common.ts
8
8
  import chalk from "chalk";
@@ -10,7 +10,7 @@ var SUPPORTED_LANGUAGES = ["python", "node"];
10
10
  var constFileSchema = z.object({
11
11
  "project-name": z.string(),
12
12
  "registry-infra": z.enum(["digitalocean", "gcp", "harbor"]),
13
- "use-image-pull-secret": z.boolean().optional(),
13
+ "image-pull-secret-name": z.string().optional(),
14
14
  "image-versions-to-keep": z.number().optional(),
15
15
  "registry-base-url": z.string(),
16
16
  "registry-image-path-prefix": z.string().optional(),
package/dist/devops.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import {
3
3
  InternalToken
4
- } from "./chunk-UZAJJUGJ.js";
4
+ } from "./chunk-JQGPJAPS.js";
5
5
  import {
6
6
  CLICommandParser,
7
7
  CommandExecutor,
@@ -24,7 +24,7 @@ import {
24
24
  printUsageAndExit,
25
25
  secretName,
26
26
  upsertConfigMapCommand
27
- } from "./chunk-QOZ6NZJC.js";
27
+ } from "./chunk-STUOTOGE.js";
28
28
  import {
29
29
  IGNORED_PATHS,
30
30
  __export,
@@ -36,7 +36,7 @@ import {
36
36
  getWorkspace,
37
37
  globEnvYamlFiles,
38
38
  workspaceDirectoryForLanguage
39
- } from "./chunk-6FEVIEFY.js";
39
+ } from "./chunk-VZ6XNNUH.js";
40
40
 
41
41
  // src/devops.ts
42
42
  import { globSync as globSync2 } from "glob";
@@ -386,8 +386,8 @@ function setWorkspaceScale(monorepoEnv, image2, workspaceName, replicaCount) {
386
386
  }
387
387
  const { scale: _scale, ...rest } = getImageConfigMap(monorepoEnv, image2);
388
388
  const parsedScale = deserializeImageConfigMapKey(monorepoEnv, image2, "scale");
389
- const isApplicable2 = setK8sScale(monorepoEnv, workspaceName, replicaCount);
390
- if (!isApplicable2) return;
389
+ const isApplicable = setK8sScale(monorepoEnv, workspaceName, replicaCount);
390
+ if (!isApplicable) return;
391
391
  updateImageConfigMap(monorepoEnv, image2, {
392
392
  ...rest,
393
393
  scale: JSON.stringify({
@@ -2068,18 +2068,15 @@ function run11(cmdObj) {
2068
2068
  var job = { oneLiner: oneLiner11, keyExamples: keyExamples11, run: run11 };
2069
2069
 
2070
2070
  // src/libs/registry/image-pull-secret.ts
2071
- var SECRET_NAME = "external-registry-secret";
2072
2071
  var SOURCE_NAMESPACE = "default";
2073
- function isApplicable() {
2074
- const useImagePullSecret = getConst("use-image-pull-secret");
2075
- if (!useImagePullSecret) {
2076
- return false;
2077
- }
2078
- return true;
2072
+ function getSecretName() {
2073
+ const secretName2 = getConst("image-pull-secret-name");
2074
+ return secretName2 || null;
2079
2075
  }
2080
2076
  function copyRegistrySecretToNamespace(monorepoEnv) {
2081
- if (!isApplicable()) return;
2082
- const cmd = kubectlCommand(`get secret ${SECRET_NAME} -o json`, {
2077
+ const secretName2 = getSecretName();
2078
+ if (!secretName2) return;
2079
+ const cmd = kubectlCommand(`get secret ${secretName2} -o json`, {
2083
2080
  monorepoEnv,
2084
2081
  namespace: SOURCE_NAMESPACE
2085
2082
  });
@@ -2103,9 +2100,10 @@ function copyRegistrySecretToNamespace(monorepoEnv) {
2103
2100
  new CommandExecutor(copyCmd, { quiet: true }).exec();
2104
2101
  }
2105
2102
  function patchServiceAccountImagePullSecret(monorepoEnv) {
2106
- if (!isApplicable()) return;
2103
+ const secretName2 = getSecretName();
2104
+ if (!secretName2) return;
2107
2105
  const cmd = kubectlCommand(
2108
- `patch serviceaccount default -p '{"imagePullSecrets": [{"name": "${SECRET_NAME}"}]}'`,
2106
+ `patch serviceaccount default -p '{"imagePullSecrets": [{"name": "${secretName2}"}]}'`,
2109
2107
  { monorepoEnv }
2110
2108
  );
2111
2109
  new CommandExecutor(cmd, { quiet: true }).exec();
@@ -2127,7 +2125,7 @@ GENERAL USAGE
2127
2125
  'create' does the following:
2128
2126
  1. Creates the namepace
2129
2127
  2. Creates a secret to hold environment variables (used by devops env) and the base cryptographic secret
2130
- 3. If use-image-pull-secret is true, copies the external-registry-secret to the namespace and patches the default service account to use it
2128
+ 3. If image-pull-secret-name is set, copies the named secret to the namespace and patches the default service account to use it
2131
2129
 
2132
2130
  'delete' removes the namespace in kubernetes, which deletes all entities within it.
2133
2131
 
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ type SupportedLanguages = typeof SUPPORTED_LANGUAGES[number];
5
5
  declare const constFileSchema: z.ZodObject<{
6
6
  "project-name": z.ZodString;
7
7
  "registry-infra": z.ZodEnum<["digitalocean", "gcp", "harbor"]>;
8
- "use-image-pull-secret": z.ZodOptional<z.ZodBoolean>;
8
+ "image-pull-secret-name": z.ZodOptional<z.ZodString>;
9
9
  "image-versions-to-keep": z.ZodOptional<z.ZodNumber>;
10
10
  "registry-base-url": z.ZodString;
11
11
  "registry-image-path-prefix": z.ZodOptional<z.ZodString>;
@@ -19,7 +19,7 @@ declare const constFileSchema: z.ZodObject<{
19
19
  "registry-base-url": string;
20
20
  "extra-remote-environments": string[];
21
21
  "extra-local-environments": string[];
22
- "use-image-pull-secret"?: boolean | undefined;
22
+ "image-pull-secret-name"?: string | undefined;
23
23
  "image-versions-to-keep"?: number | undefined;
24
24
  "registry-image-path-prefix"?: string | undefined;
25
25
  "cloudrun-artifact-registry-repo-path"?: string | undefined;
@@ -30,7 +30,7 @@ declare const constFileSchema: z.ZodObject<{
30
30
  "registry-base-url": string;
31
31
  "extra-remote-environments": string[];
32
32
  "extra-local-environments": string[];
33
- "use-image-pull-secret"?: boolean | undefined;
33
+ "image-pull-secret-name"?: string | undefined;
34
34
  "image-versions-to-keep"?: number | undefined;
35
35
  "registry-image-path-prefix"?: string | undefined;
36
36
  "cloudrun-artifact-registry-repo-path"?: string | undefined;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  InternalToken,
3
3
  decryptAes256Gcm,
4
4
  encryptAes256Gcm
5
- } from "./chunk-UZAJJUGJ.js";
5
+ } from "./chunk-JQGPJAPS.js";
6
6
  import {
7
7
  SUPPORTED_LANGUAGES,
8
8
  constFileSchema,
@@ -10,7 +10,7 @@ import {
10
10
  packageFileNodeSchema,
11
11
  packageFilePythonSchema,
12
12
  workspaces
13
- } from "./chunk-6FEVIEFY.js";
13
+ } from "./chunk-VZ6XNNUH.js";
14
14
 
15
15
  // src/app-support/discovery/dev-discovery-loader.ts
16
16
  var _portLookupByServiceName = null;
package/dist/plugins.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  kubectlCommand,
6
6
  pkgRoot,
7
7
  printUsageAndExit
8
- } from "./chunk-QOZ6NZJC.js";
9
- import "./chunk-6FEVIEFY.js";
8
+ } from "./chunk-STUOTOGE.js";
9
+ import "./chunk-VZ6XNNUH.js";
10
10
 
11
11
  // src/plugins.ts
12
12
  import path from "path";
@@ -4,9 +4,9 @@ project-name: $PROJECT_NAME
4
4
  # Registry infrastructure: digitalocean, gcp, or harbor
5
5
  registry-infra: harbor
6
6
 
7
- # When true, devops namespace create will copy external-registry-secret from default namespace
7
+ # When set, devops namespace create will copy this secret from default namespace
8
8
  # and patch the default service account to use it. See docs/infra/RegistrySetup.md for details.
9
- use-image-pull-secret: true
9
+ image-pull-secret-name: $PROJECT_NAME-registry-secret
10
10
 
11
11
  # Only relevant for Digital Ocean. Determines the number of versions to keep for each docker image.
12
12
  image-versions-to-keep: 5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vaharoni/devops",
3
3
  "type": "module",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
5
5
  "description": "Devops utility",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -24,7 +24,8 @@
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsup",
27
- "test": "vitest run"
27
+ "test": "vitest run",
28
+ "verify": "tsc --noEmit"
28
29
  },
29
30
  "repository": {
30
31
  "type": "git",
@@ -1,8 +1,8 @@
1
- import { CLICommandParser, printUsageAndExit, StrongParams } from "../../../src/cli/common";
1
+ import { CLICommandParser, printUsageAndExit, StrongParams } from "../common";
2
2
  import {
3
3
  copyRegistrySecretToNamespace,
4
4
  patchServiceAccountImagePullSecret,
5
- } from "../../../src/libs/registry/image-pull-secret";
5
+ } from "../../libs/registry/image-pull-secret";
6
6
  import { checkEnvSetup, createEmptyEnvSecret, createNamespace, deleteNamespace, patchBaseSecret } from "../../libs/k8s-namespace";
7
7
 
8
8
  const oneLiner = "Creates the basic prerequisites for a monorepo";
@@ -21,7 +21,7 @@ GENERAL USAGE
21
21
  'create' does the following:
22
22
  1. Creates the namepace
23
23
  2. Creates a secret to hold environment variables (used by devops env) and the base cryptographic secret
24
- 3. If use-image-pull-secret is true, copies the external-registry-secret to the namespace and patches the default service account to use it
24
+ 3. If image-pull-secret-name is set, copies the named secret to the namespace and patches the default service account to use it
25
25
 
26
26
  'delete' removes the namespace in kubernetes, which deletes all entities within it.
27
27
 
@@ -3,21 +3,18 @@ import { getConst } from "../config";
3
3
  import { envToNamespace } from "../k8s-constants";
4
4
  import { kubectlCommand } from "../k8s-helpers";
5
5
 
6
- const SECRET_NAME = "external-registry-secret";
7
6
  const SOURCE_NAMESPACE = "default";
8
7
 
9
- function isApplicable() {
10
- const useImagePullSecret = getConst("use-image-pull-secret");
11
- if (!useImagePullSecret) {
12
- return false;
13
- }
14
- return true;
8
+ function getSecretName(): string | null {
9
+ const secretName = getConst("image-pull-secret-name");
10
+ return secretName || null;
15
11
  }
16
12
 
17
13
  export function copyRegistrySecretToNamespace(monorepoEnv: string) {
18
- if (!isApplicable()) return;
14
+ const secretName = getSecretName();
15
+ if (!secretName) return;
19
16
 
20
- const cmd = kubectlCommand(`get secret ${SECRET_NAME} -o json`, {
17
+ const cmd = kubectlCommand(`get secret ${secretName} -o json`, {
21
18
  monorepoEnv,
22
19
  namespace: SOURCE_NAMESPACE,
23
20
  });
@@ -44,10 +41,11 @@ export function copyRegistrySecretToNamespace(monorepoEnv: string) {
44
41
  }
45
42
 
46
43
  export function patchServiceAccountImagePullSecret(monorepoEnv: string) {
47
- if (!isApplicable()) return;
44
+ const secretName = getSecretName();
45
+ if (!secretName) return;
48
46
 
49
47
  const cmd = kubectlCommand(
50
- `patch serviceaccount default -p '{"imagePullSecrets": [{"name": "${SECRET_NAME}"}]}'`,
48
+ `patch serviceaccount default -p '{"imagePullSecrets": [{"name": "${secretName}"}]}'`,
51
49
  { monorepoEnv }
52
50
  );
53
51
  new CommandExecutor(cmd, { quiet: true }).exec();
@@ -4,9 +4,9 @@ project-name: $PROJECT_NAME
4
4
  # Registry infrastructure: digitalocean, gcp, or harbor
5
5
  registry-infra: harbor
6
6
 
7
- # When true, devops namespace create will copy external-registry-secret from default namespace
7
+ # When set, devops namespace create will copy this secret from default namespace
8
8
  # and patch the default service account to use it. See docs/infra/RegistrySetup.md for details.
9
- use-image-pull-secret: true
9
+ image-pull-secret-name: $PROJECT_NAME-registry-secret
10
10
 
11
11
  # Only relevant for Digital Ocean. Determines the number of versions to keep for each docker image.
12
12
  image-versions-to-keep: 5
@@ -8,7 +8,7 @@ export type SupportedLanguages = typeof SUPPORTED_LANGUAGES[number];
8
8
  export const constFileSchema = z.object({
9
9
  "project-name": z.string(),
10
10
  "registry-infra": z.enum(["digitalocean", "gcp", "harbor"]),
11
- "use-image-pull-secret": z.boolean().optional(),
11
+ "image-pull-secret-name": z.string().optional(),
12
12
  "image-versions-to-keep": z.number().optional(),
13
13
  "registry-base-url": z.string(),
14
14
  "registry-image-path-prefix": z.string().optional(),