@leverege/build-tools 2.47.2 → 2.47.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.47.2",
3
+ "version": "2.47.4",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -16,6 +16,7 @@
16
16
  "build-tools": "src/build-tools.mjs",
17
17
  "chart-to-registry": "src/chart-to-registry.mjs",
18
18
  "circleate": "src/circleate.sh",
19
+ "cnpg-snapshot": "src/cnpg-snapshot.mjs",
19
20
  "decrypt-secrets": "src/decrypt-secrets.sh",
20
21
  "dirty-git": "src/dirty-git.sh",
21
22
  "dockreate": "src/dockreate.sh",
@@ -61,7 +62,7 @@
61
62
  "execa": "^8.0.1",
62
63
  "glob": "^10.3.10",
63
64
  "handlebars": "^4.7.8",
64
- "inquirer": "^9.2.14",
65
+ "inquirer": "^9.2.15",
65
66
  "js-yaml": "^4.1.0",
66
67
  "ms": "^2.1.3",
67
68
  "npm-registry-fetch": "^16.1.0",
@@ -71,6 +72,7 @@
71
72
  "readline-sync": "^1.4.10",
72
73
  "semver": "^7.6.0",
73
74
  "simple-git": "^3.22.0",
75
+ "tempy": "^3.1.0",
74
76
  "zx": "^7.2.3"
75
77
  },
76
78
  "devDependencies": {
package/src/Utils.mjs CHANGED
@@ -320,6 +320,7 @@ https://console.cloud.google.com/artifacts/browse/leverege-registry?project=leve
320
320
 
321
321
  export const parseHelmChart = async ( helmroot = './helm' ) => {
322
322
  /* eslint-disable security/detect-non-literal-fs-filename */
323
+ if ( !existsSync( helmroot ) ) { return undefined }
323
324
  const chartFiles = readdirSync( helmroot, { encoding : 'utf8', recursive : true } )
324
325
  const chartYaml = YAML.load( readFileSync( `${helmroot}/Chart.yaml`, 'utf8' ) )
325
326
  const valuesYaml = YAML.load( readFileSync( `${helmroot}/values.yaml`, 'utf8' ) )
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from 'node:fs'
4
+
5
+ import handlebars from 'handlebars'
6
+ import { temporaryFile } from 'tempy'
7
+
8
+ import {
9
+ getDateTimestamp,
10
+ debug,
11
+ shellCmd,
12
+ } from './Utils.mjs'
13
+
14
+ const backup = `
15
+ apiVersion: postgresql.cnpg.io/v1
16
+ kind: Backup
17
+ metadata:
18
+ name: {{clusterName}}-snapshot-{{dateTimestamp}}
19
+ namespace: cnpg-operands
20
+ labels:
21
+ cnpg-backup: manual
22
+ cnpg-operand: {{clusterName}}
23
+ spec:
24
+ method: volumeSnapshot
25
+ cluster:
26
+ name: {{clusterName}}`
27
+
28
+ const dateTimestamp = getDateTimestamp()
29
+ const clusterName = process.argv[2]
30
+ const compiled = handlebars.compile( backup )
31
+ const replaced = compiled( { dateTimestamp, clusterName } )
32
+ const tmpfile = temporaryFile()
33
+
34
+ debug( { replaced, tmpfile }, '<==Apply That' )
35
+
36
+ fs.writeFileSync( tmpfile, replaced )
37
+ await shellCmd( 'overwhelm' )
38
+ await shellCmd( `kubectl apply -f ${tmpfile}` )
@@ -2,6 +2,8 @@
2
2
  /*
3
3
  * docker-to-registry will...
4
4
  */
5
+ import fs from 'node:fs'
6
+
5
7
  import chalk from 'chalk'
6
8
 
7
9
  import {
@@ -53,6 +55,18 @@ if ( willGitTag && repoIsDirty ) {
53
55
  process.exit( 1 )
54
56
  }
55
57
 
58
+ if ( !fs.existsSync( './helm' ) ) {
59
+ log( `
60
+ ${chalk.red.bold( '***Error: docker-to-registry requires a helm chart directory' )}
61
+
62
+ The docker-to-registry script expects to run in the root directory of a k8s
63
+ service, which requires a helm chart directory. It also expects a docker
64
+ directory but will build that if it does not exist.
65
+
66
+ ` )
67
+ process.exit( 1 )
68
+ }
69
+
56
70
  const repoDescr = await analyzeRepository()
57
71
  debug( { repoDescr }, '<==The Repo Description' )
58
72
 
@@ -157,7 +171,7 @@ if ( expectedChartRegistry !== values.image?.registry ) {
157
171
  its job.
158
172
 
159
173
  ` )
160
- }
174
+ }
161
175
 
162
176
  process.exit( 1 )
163
177
  }
@@ -1,3 +1,9 @@
1
1
  #!/bin/bash
2
2
 
3
- kubectl delete -f db-timescale-dense/db-timescale-dense.yaml $K8S_WHAT
3
+ printf "\nHibernating the db-timescale-dense cluster...\n"
4
+ kubectl cnpg hibernate on -n cnpg-operands db-timescale-dense
5
+
6
+ # *** DANGER ***
7
+ # kubectl delete will destroy the cluster
8
+ # *** DANGER ***
9
+ # kubectl delete -f db-timescale-dense/db-timescale-dense.yaml $K8S_WHAT