@leverege/build-tools 2.45.0-mono.1 → 2.46.0-beta.1

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.45.0-mono.1",
3
+ "version": "2.46.0-beta.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/Utils.mjs CHANGED
@@ -130,9 +130,11 @@ export const parsePackageJson = async ( packageFileName ) => {
130
130
  resemble something like:
131
131
 
132
132
  "leverege": {
133
- "registry": "us-docker.pkg.dev/leverege-registry/<REPO NAME>"
133
+ "registry": "us-docker.pkg.dev/leverege-registry/<registry folder>"
134
134
  },
135
135
 
136
+
137
+ Where <registry folder> should be an existing folder in the artifact-registry.
136
138
  `
137
139
  const registry = packageJson?.leverege?.registry
138
140
  if ( !registry ) {
@@ -243,6 +245,29 @@ export const parsePackageJson = async ( packageFileName ) => {
243
245
  deprecated( { deprecationError, deprecationInfo } )
244
246
  }
245
247
 
248
+ // DEPRECATED: old reference to ./dist should be ./build
249
+ const { build, clean, dockerize, } = packageJson.scripts
250
+
251
+ if ( build.match( 'dist' ) || clean.match( 'dist' ) || dockerize.match( 'dockreate|cd docker' ) ) {
252
+ const deprecationError = `
253
+
254
+ Update the npm build, clean and dockerize scripts to use ./build instead of
255
+ the old ./dist directory, and docker-to-registry instead of the deprecated
256
+ dockreate script - note there is no longer a need to change dir into docker
257
+ in the dockerize script.
258
+ `
259
+ const deprecationInfo = `
260
+ "scripts": {
261
+ "build": "npm run clean && mkdir ./build && cp -r ./src/* ./build",
262
+ ...
263
+ "clean": "rm -fr coverage build",
264
+ "dockerize": "npm run build && docker-to-registry",
265
+ ...
266
+ },
267
+ `
268
+
269
+ deprecated( { deprecationError, deprecationInfo } )
270
+ }
246
271
  return { artifactRegistry, ...packageJson }
247
272
  }
248
273
 
@@ -261,16 +286,18 @@ export const parseHelmChart = async ( helmroot ) => {
261
286
  } )
262
287
  }
263
288
 
264
- export const describeRepository = async () => {
289
+ export const analyzeRepository = async () => {
265
290
  const gitRoot = await getGitRootDirectory()
266
291
  const subPkgs = await glob( `${gitRoot}/packages/**/package.json`, { ignore : '/**/node_modules/**' } )
292
+ const isMonoRepo = subPkgs?.length > 0
267
293
 
268
294
  let rootPackageJson
269
295
  try {
270
296
  rootPackageJson = await parseJsonFile( `${gitRoot}/package.json` )
271
297
  } catch ( error ) {
272
- rootPackageJson = { inValid : true, error : 'invalid or non-existent root package.json file' }
298
+ rootPackageJson = { invalid : true, error : 'invalid or non-existent root package.json file' }
273
299
  }
300
+ const isNpmWorkspace = subPkgs?.length > 0
274
301
 
275
302
  log( chalk.green.bold( '\nParsing and analyzing the package.json file\n' ) )
276
303
  let closestPackageJson
@@ -308,8 +335,8 @@ export const describeRepository = async () => {
308
335
  closestPkg,
309
336
  gitRoot,
310
337
  gitRemote,
311
- isMonoRepo : subPkgs?.length > 0,
312
- isNpmWorkspace : rootPackageJson?.workspaces?.length > 0,
338
+ isMonoRepo,
339
+ isNpmWorkspace,
313
340
  rootPackageJson,
314
341
  closestPackageJson,
315
342
  subPkgs,
package/src/dirty-git.sh CHANGED
@@ -36,7 +36,7 @@ do
36
36
  fi
37
37
  fi
38
38
  [ -f "Versions.json" ] && locked="$LOCKD" || locked=" "
39
- [ ! -d "elasticsearch8" ] && elastic="$ELAS7" || elastic=" "
39
+ [ ! -d "elasticsearch8" ] && [ -d "elasticsearch" ] && elastic="$ELAS7" || elastic=" "
40
40
  cd - &>/dev/null
41
41
  printf "${status} %-28s ${stash}${ahead}${locked}${elastic} %s\n" $dir $branch
42
42
  done
@@ -7,7 +7,7 @@ import chalk from 'chalk'
7
7
  import {
8
8
  debug, log,
9
9
  errorExit,
10
- describeRepository,
10
+ analyzeRepository,
11
11
  proceed,
12
12
  shellCmd } from './Utils.mjs'
13
13
 
@@ -26,7 +26,7 @@ const tagInfo = willGitTag ?
26
26
  chalk.yellow.bold( 'will be git tagged' ) :
27
27
  chalk.red( 'BETA RELEASE WILL NOT BE GIT TAGGED' )
28
28
 
29
- const repoDescr = await describeRepository()
29
+ const repoDescr = await analyzeRepository()
30
30
  debug( { repoDescr }, '<==The Repo Description' )
31
31
 
32
32
  const dockerInfo = await docker.generateDockerfile()
File without changes
File without changes
@@ -0,0 +1,120 @@
1
+ # Artifact Chart => https://artifacthub.io/packages/helm/cloudnative-pg/cloudnative-pg
2
+ # Examples Charts => https://cloudnative-pg.io/documentation/current/samples/
3
+ apiVersion: postgresql.cnpg.io/v1
4
+ kind: Cluster
5
+ metadata:
6
+ name: db-timescale-plain
7
+ namespace: cnpg-operands
8
+ spec:
9
+ instances: 1
10
+ logLevel: debug
11
+
12
+ description: "Leverege Plain Timescale DB"
13
+ imageName: us-docker.pkg.dev/leverege-registry/system/images/leverege-pgsql:16.1-cnpg-tsdb2-beta.6
14
+ bootstrap:
15
+ initdb:
16
+ postInitTemplateSQL:
17
+ - CREATE EXTENSION timescaledb;
18
+ - CREATE EXTENSION jsquery;
19
+ database: imagine
20
+ owner: imagine
21
+ secret:
22
+ name: db-timescale-plain-imagine-pw # imagine db pw
23
+
24
+ enableSuperuserAccess: true
25
+ superuserSecret:
26
+ name: db-timescale-plain-postgres-pw # postgres db pw
27
+
28
+ affinity:
29
+ # enablePodAntiAffinity: true
30
+ # topologyKey: failure-domain.beta.kubernetes.io/zone
31
+ tolerations:
32
+ - key: "database"
33
+ operator: "Equal"
34
+ value: "true"
35
+ effect: "NoSchedule"
36
+
37
+ # Parameters and pg_hba configuration will be append
38
+ # to the default ones to make the cluster work
39
+ postgresql:
40
+ shared_preload_libraries:
41
+ - timescaledb
42
+ - jsquery
43
+ parameters:
44
+ # max_worker_processes: "60"
45
+ max_worker_processes: "8"
46
+ max_parallel_workers: "8"
47
+ shared_buffers: 2GB
48
+ effective_cache_size: 6GB
49
+ maintenance_work_mem: 1GB
50
+ work_mem: 20MB
51
+ pg_hba:
52
+ # To access through TCP/IP you will need to get username
53
+ # and password from the secret cluster-example-custom-app
54
+ - host all all all md5
55
+
56
+
57
+ # Example of rolling update strategy:
58
+ # - unsupervised: automated update of the primary once all
59
+ # replicas have been upgraded (default)
60
+ # - supervised: requires manual supervision to perform
61
+ # the switchover of the primary
62
+ primaryUpdateStrategy: unsupervised
63
+
64
+ serviceAccountTemplate:
65
+ metadata:
66
+ annotations:
67
+ iam.gke.io/gcp-service-account: cnpg-operands-sa@OVH:<PROJECT_ID>.iam.gserviceaccount.com
68
+
69
+ # Require 50Gi of space per instance using ssd storage class
70
+ storage:
71
+ storageClass: premium-rwo
72
+ size: 50Gi
73
+ walStorage:
74
+ storageClass: premium-rwo
75
+ size: 1Gi
76
+
77
+ backup:
78
+ volumeSnapshot:
79
+ labels:
80
+ snapshotOf: db-timescale-plain
81
+ className: cnpg-snapshotclass
82
+ barmanObjectStore:
83
+ destinationPath: gs://OVH:<PROJECT_ID>-barman
84
+ googleCredentials:
85
+ gkeEnvironment: true
86
+ tags:
87
+ cnpgCluster: db-timescale-plain
88
+ wal:
89
+ compression: gzip
90
+ ---
91
+ apiVersion: postgresql.cnpg.io/v1
92
+ kind: Pooler
93
+ metadata:
94
+ name: db-timescale-plain-pool-rw
95
+ namespace: cnpg-operands
96
+ spec:
97
+ cluster:
98
+ name: db-timescale-plain
99
+
100
+ instances: 1
101
+ type: rw
102
+ pgbouncer:
103
+ poolMode: session
104
+ parameters:
105
+ max_client_conn: "500"
106
+ default_pool_size: "10"
107
+ ---
108
+ apiVersion: postgresql.cnpg.io/v1
109
+ kind: ScheduledBackup
110
+ metadata:
111
+ name: db-timescale-plain-backup
112
+ namespace: cnpg-operands
113
+ spec:
114
+ # https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format
115
+ schedule: "0 0 * * * *"
116
+ cluster:
117
+ name: db-timescale-plain
118
+ method: volumeSnapshot
119
+ backupOwnerReference: self
120
+ immediate: true
@@ -0,0 +1 @@
1
+ db-timescale-plain.yaml
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ kubectl delete -f db-timescale-plain/db-timescale-plain.yaml $K8S_WHAT
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ #
3
+ kubectl apply -f db-timescale-plain/db-timescale-plain.yaml $K8S_WHAT
@@ -4,7 +4,7 @@ showInstalling "Redis"
4
4
 
5
5
  OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
6
6
 
7
- [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="18.7.1"
7
+ [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="18.12.1"
8
8
 
9
9
  helm upgrade --install redis $OCI_CHART \
10
10
  --values redis/redis-local.yaml \
package/src/k8x.sh CHANGED
@@ -1,21 +1,72 @@
1
1
  #!/bin/bash
2
2
 
3
+ . `build-tools --bashfun`
4
+
5
+ if [ ! -x "$(command -v fzf)" ];
6
+ then
7
+ cat<<NO_FZF
8
+
9
+ `color r ***Error:` Missing fzf fuzzy matcher => `color g "brew install fzf"`
10
+
11
+ NO_FZF
12
+ exit 1
13
+ fi
14
+
3
15
  cmd=${@:-"bash"}
4
16
  ns="default"
5
17
 
6
- [ "$cmd" = "redis" ] || [ "$cmd" = "redis-cli" ] && FZFQ="--query=redis" && cmd='redis-cli'
18
+ case "$cmd" in
19
+ "bash")
20
+ # invoked simply as k8x
21
+ ;;
22
+
23
+ "cnpg")
24
+ ns="cnpg-operands" && cmd="bash"
25
+ ;;
26
+
27
+ "es8"|"elastic8")
28
+ ns="elastic" && cmd="bash"
29
+ ;;
30
+
31
+ "psql"|"pgsql")
32
+ FZFQ="--query=postgresql" && cmd='psql -U postgres'
33
+ ;;
34
+
35
+ "redis"|"redis-cli")
36
+ FZFQ="--query=redis" && cmd='redis-cli'
37
+ ;;
38
+
39
+ "help"|*)
40
+ if [ "$cmd" != "help" ];
41
+ then
42
+ cat<<BAD_K8X
43
+
44
+ `color r ***Error:` unrecognized k8x target => `color y "$cmd"`
45
+ BAD_K8X
46
+ k8x.sh help
47
+ exit 1
48
+ fi
7
49
 
8
- [ "$cmd" = "pgsql" ] && FZFQ="--query=postgresql" && cmd='psql -U postgres'
50
+ cat<<K8X_HELP
51
+
52
+ Usage: `color g 'k8x <target>'` where target can be:
9
53
 
10
- [ "$cmd" = "cnpg" ] && ns="cnpg-operands" && cmd="bash"
54
+ `color g cnpg` - run bash on a cloudnative-pg cluster node
55
+ `color g es8` - run bash on an elasticsearch8 node
56
+ `color g psql` - run psql on a legacy database node
57
+ `color g redis` - run redis-cli on a redis master/replica
58
+ `color g help` - this right here
11
59
 
12
- [ -f overwhelm.yaml ] && [ -f package.json ] && npm run ahoy
60
+ K8X_HELP
61
+ exit 0
62
+ ;;
63
+ esac
13
64
 
14
- [ ! -x "$(command -v fzf)" ] && printf "\n***ERROR: Missing fzf fuzzy matcher => brew install fzf\n\n" && exit 1
65
+ [ -f overwhelm.yaml ] && [ -f package.json ] && overwhelm
15
66
 
16
67
  pod=$(kubectl -n $ns get pods -owide | fzf $FZFQ | awk '{print $1}')
17
68
 
18
69
  kubecmd="kubectl exec -n $ns -it $pod -- $cmd"
19
- echo " run=[${kubecmd}]"
70
+ printf "\n`color y 'Running =>'` `color g \"${kubecmd}\"`\n\n"
20
71
 
21
72
  eval ${kubecmd}