@leverege/build-tools 2.98.0 → 2.98.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.
@@ -18,6 +18,16 @@
18
18
  },
19
19
  "outputCapture": "std"
20
20
  },
21
+ {
22
+ "name": "push-my-chart rsrc-srvr",
23
+ "type": "node",
24
+ "request": "launch",
25
+ "program": "${workspaceFolder}/src/push-my-chart.mjs",
26
+ "args": [],
27
+ "cwd": "/Users/john/Work/leverege/cicd/@plt/resource-server",
28
+ "runtimeExecutable": "node",
29
+ "console": "integratedTerminal"
30
+ },
21
31
  {
22
32
  "name": "ingestor in monorepo",
23
33
  "type": "node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.98.0",
3
+ "version": "2.98.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -21,7 +21,6 @@
21
21
  "build-tools": "src/build-tools.mjs",
22
22
  "change-up": "src/change-up.sh",
23
23
  "chart-compass": "src/chart-compass.mjs",
24
- "chart-to-museum": "src/chart-to-museum.mjs",
25
24
  "chart-to-registry": "src/chart-to-registry.mjs",
26
25
  "circleate": "src/circleate.sh",
27
26
  "clone-cnpg-from-snapshot": "src/clone-cnpg-from-snapshot.mjs",
@@ -104,7 +103,7 @@
104
103
  "readline-sync": "^1.4.10",
105
104
  "semver": "^7.7.4",
106
105
  "shell-quote": "^1.8.3",
107
- "simple-git": "^3.32.3",
106
+ "simple-git": "^3.33.0",
108
107
  "sloc": "^0.3.2",
109
108
  "superstruct": "^2.0.2",
110
109
  "tmp": "^0.2.5",
@@ -116,6 +115,6 @@
116
115
  "@leverege/eslint-config-leverege": "^5.1.2",
117
116
  "chai": "^6.2.2",
118
117
  "mocha": "^11.7.5",
119
- "npm": "^11.11.0"
118
+ "npm": "^11.11.1"
120
119
  }
121
120
  }
package/src/Utils.mjs CHANGED
@@ -10,6 +10,7 @@ import { glob } from 'glob'
10
10
  import { packageUp } from 'package-up'
11
11
  import { parse } from 'shell-quote'
12
12
  import toml from 'toml'
13
+ import semver from 'semver'
13
14
  import YAML from 'js-yaml'
14
15
 
15
16
  // __dirname goes away with ESM so we take this approach instead and
@@ -544,15 +545,14 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
544
545
  let depsOutOfSync = hasDependencies // assume unsynced if dependencies
545
546
  if ( chartFiles.includes( 'Chart.lock' ) ) {
546
547
  const chartLock = YAML.load( fs.readFileSync( `${helmroot}/Chart.lock`, 'utf8' ) )
547
- // Using Object.fromEntries will be able to handle multiple dependencies if ever needed
548
- const chartDeps = Object.fromEntries(
549
- chartYaml.dependencies.map( d => [ d.name, d.version ] )
550
- )
548
+
551
549
  const lockDeps = Object.fromEntries(
552
550
  chartLock.dependencies.map( d => [ d.name, d.version ] )
553
551
  )
554
- const mismatches = Object.entries( chartDeps ).filter( ( [ name, version ] ) => {
555
- return lockDeps[name] !== version
552
+
553
+ const mismatches = chartYaml.dependencies.filter( ( { name, version } ) => {
554
+ const lockedVersion = lockDeps[name]
555
+ return !lockedVersion || !semver.satisfies( lockedVersion, version )
556
556
  } )
557
557
 
558
558
  depsOutOfSync = mismatches.length > 0
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
-
2
+ // *** DEPRECATED: this goes away when we move away from the chart museum and
3
+ // push-my-chart already handles this a artifact pushes
4
+ //
3
5
  import chalk from 'chalk'
4
6
  import commandLineArgs from 'command-line-args'
5
7
  import commandLineUsage from 'command-line-usage'
@@ -8,7 +8,7 @@ showInstalling "The Prometheus Operator (kube-prometheus-stack)"
8
8
 
9
9
  # https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack
10
10
  OCI_CHART="oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack"
11
- [ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="82.9.0"
11
+ [ -z "$PROMETHEUS_STACK_CHART_VERSION" ] && PROMETHEUS_STACK_CHART_VERSION="82.10.3"
12
12
  helm upgrade $NS --install prometheus-stack $OCI_CHART \
13
13
  --values prom-operator/prometheus-stack.yaml \
14
14
  --version $PROMETHEUS_STACK_CHART_VERSION $HELM_WHAT
@@ -146,7 +146,7 @@ extraManifests:
146
146
  - websecure
147
147
  routes:
148
148
  - kind: Rule
149
- match: Host(`${PROJECT_ID}-prometheus.${HOST}.com`)
149
+ match: Host(`${PROJECT_NAME}-prometheus.${HOST}.com`)
150
150
  middlewares:
151
151
  - name: basic-auth
152
152
  services:
@@ -224,7 +224,7 @@ alertmanager:
224
224
  slack_configs:
225
225
  - channel: "${SLACK_CHANNEL}"
226
226
  api_url: "${SLACK_HOOK_URL}"
227
- username: "${PROJECT_ID}"
227
+ username: "${PROJECT_NAME}"
228
228
  send_resolved: true
229
229
  title: '{{ .CommonLabels.alertname }} alert'
230
230
  title_link: '#'
@@ -261,7 +261,7 @@ alertmanager:
261
261
  {{- end }}
262
262
 
263
263
  {{- if .Labels.pod }}
264
- *Pod Link:* *<https://console.cloud.google.com/kubernetes/pod/${GCE_REGION}/${CLUSTER_NAME}/{{ .Labels.namespace }}/{{ .Labels.pod }}?project=${PROJECT_ID}|`{{ .Labels.pod }}`>*
264
+ *Pod Link:* *<https://console.cloud.google.com/kubernetes/pod/${GCE_REGION}/${CLUSTER_NAME}/{{ .Labels.namespace }}/{{ .Labels.pod }}?project=${PROJECT_NAME}|`{{ .Labels.pod }}`>*
265
265
  {{- end }}
266
266
 
267
267
  *Status:* `{{ .Status }}` | *Severity:* `{{ .Labels.severity }}` {{- if .Labels.container }} *Container:* `{{ .Labels.container }}` {{- end }}
@@ -5,7 +5,7 @@
5
5
  fullnameOverride: "prometheus-stack-stackdriver-metrics"
6
6
 
7
7
  stackdriver:
8
- projectId: "${PROJECT_NAME}"
8
+ projectId: "${PROJECT_ID}"
9
9
  metrics:
10
10
  typePrefixes: >
11
11
  agent.googleapis.com/cpu/utilization,
@@ -18,7 +18,7 @@ primary:
18
18
  replicaCount: 1
19
19
 
20
20
  # https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_resources.tpl#L15
21
- resourcesPreset: "small"
21
+ resourcesPreset: "medium"
22
22
  # resources:
23
23
  # requests:
24
24
  # cpu: 250m
@@ -54,7 +54,7 @@ replica:
54
54
  replicaCount: 1
55
55
 
56
56
  # https://github.com/bitnami/charts/blob/main/bitnami/common/templates/_resources.tpl#L15
57
- resourcesPreset: "micro"
57
+ resourcesPreset: "medium"
58
58
  # resources:
59
59
  # requests:
60
60
  # cpu: 250m
@@ -5,8 +5,8 @@ showInstalling "Velero Backup System"
5
5
  # We use a specific version for the velero chart because we need to control
6
6
  # the version of the locally installed velero client application.
7
7
  #
8
- VELERO_CHART_VERSION="11.3.2"
9
- EXPECTED_CLIENT_VERSION="v1.17.2"
8
+ VELERO_CHART_VERSION="11.4.0"
9
+ EXPECTED_CLIENT_VERSION="v1.18.0"
10
10
 
11
11
  addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
12
12
 
package/src/helmup.sh CHANGED
@@ -522,7 +522,6 @@ function getServiceAndChartInfo() {
522
522
  CHARTVER="$(jq -r --arg svc "$SERVICE" '.[$svc].chart // empty' "$versions_file")"
523
523
  [[ -n "$CHARTVER" ]] && FROM_VERSIONS=1
524
524
  fi
525
-
526
525
  return 0
527
526
  }
528
527
 
@@ -687,6 +686,7 @@ REBOOTSTRAP
687
686
  transponder-*)
688
687
  # transponders use the same chart but different deployment name
689
688
  [ ! -d $SERVICE ] && bootstrapLocalSetup $SERVICE
689
+ CHARTLOC="oci://us-docker.pkg.dev/leverege-registry/stack/charts/transponder" # always use art-reg
690
690
  HELMUP="helm upgrade --install $SERVICE $CHARTLOC --values $SERVICE/values.yaml $CHARTVER $HELM_WHAT"
691
691
  doHelmup "$HELMUP"
692
692
  ;;
@@ -31,9 +31,16 @@ const PRESERVE_SECTIONS = new Set( [
31
31
  ] )
32
32
 
33
33
  // Helper functions
34
- const warnDeprecatedSections = ( doc, sections ) => {
34
+ const OBSOLETE_SECTIONS = [
35
+ 'ingressRoute',
36
+ 'loadbalancer',
37
+ 'udploadbalancer',
38
+ 'podAnnotations',
39
+ 'workloadIdentity'
40
+ ]
41
+ const warnDeprecatedSections = ( doc ) => {
35
42
  let deprecationWarningShown = false
36
- for ( const key of sections ) {
43
+ for ( const key of OBSOLETE_SECTIONS ) {
37
44
  if ( !doc.has( key ) ) continue
38
45
  Utils.log( `${chalk.yellow.bold( '⚠️ WARNING:' )} Deprecated values.yaml section detected => ${chalk.red.bold( key )}` )
39
46
  deprecationWarningShown = true
@@ -138,10 +145,10 @@ export class Chartwright {
138
145
  // Now we need to smart merge the values.yaml template while preserving existing sections
139
146
  const baseValuesDoc = YAML.parseDocument( this.templates.Values )
140
147
  const existingValuesDoc = YAML.parseDocument( ValuesText )
141
- // prune obsolete sections and write the merged values.yaml back to disk, preserving formatting and comments
142
- const OBSOLETE_SECTIONS = [ 'ingressRoute', 'loadbalancer', 'udploadbalancer' ]
143
- warnDeprecatedSections( existingValuesDoc, OBSOLETE_SECTIONS )
144
-
148
+ // warn about obsolete sections
149
+ warnDeprecatedSections( existingValuesDoc )
150
+
151
+ // Merge legacy values.yaml with new base, preserving formatting and comments
145
152
  this.mergeTopLevelAddMissing( baseValuesDoc, existingValuesDoc )
146
153
  this.applyPreserveSections( baseValuesDoc, existingValuesDoc )
147
154
 
@@ -104,7 +104,3 @@ affinity: {}
104
104
  tolerations: []
105
105
 
106
106
  nodeSelector: {}
107
-
108
- podAnnotations: {}
109
-
110
- workloadIdentity: {}
@@ -3,9 +3,14 @@
3
3
  import chalk from 'chalk'
4
4
  import commandLineArgs from 'command-line-args'
5
5
  import commandLineUsage from 'command-line-usage'
6
- import { lt as semverLt } from 'semver'
7
6
 
8
- import { debug, log, shellCmd } from './Utils.mjs'
7
+ import {
8
+ debug,
9
+ errorExit,
10
+ log,
11
+ parseHelmChart,
12
+ shellCmd
13
+ } from './Utils.mjs'
9
14
 
10
15
  const commandLineOptions = [
11
16
  {
@@ -48,34 +53,46 @@ if ( args.help ) {
48
53
  process.exit( 0 )
49
54
  }
50
55
 
51
- const pushItGood = async () => {
52
- const version = await shellCmd( 'helm version --short' )
53
- const pusher = ( semverLt( version, '3.7.0' ) ? 'push' : 'cm-push' )
56
+ const {
57
+ chartName,
58
+ chartVersion,
59
+ depsOutOfSync,
60
+ } = await parseHelmChart( args.chart )
54
61
 
55
- let museumStatus = 0
62
+ log( chalk.green( `Chart => ${chalk.bold.yellow( chartName )}` ) )
63
+ log( chalk.green( `Version => ${chalk.bold.yellow( chartVersion )}` ) )
64
+
65
+ if ( depsOutOfSync ) {
56
66
  try {
57
- log( chalk.green( 'Pushing chart to the Chartmuseum\n' ) )
58
- const museum = await shellCmd( `helm ${pusher} ${args.chart} leverege` )
59
- debug( { museum }, '<==output from helm push' )
60
- } catch ( ex ) {
61
- log( ex.stderr )
62
- museumStatus = 1
67
+ log( chalk.yellow.bold( '\nChart dependedencies are out of sync - updating...\n' ) )
68
+ await shellCmd( 'helm dependency update ./helm', { stdio : 'inherit' } )
69
+ } catch ( error ) {
70
+ errorExit( error )
63
71
  }
72
+ }
64
73
 
65
- if ( args.noRegistry ) {
66
- log( `${chalk.bold.yellow( '\nskipping the chart push to the artifact registry' )}` )
67
- process.exit( museumStatus )
68
- }
74
+ let museumStatus = 0
75
+ try {
76
+ log( chalk.green( ' ... pushing to the Museum' ) )
77
+ const museum = await shellCmd( `helm cm-push ${args.chart} leverege` )
78
+ debug( { museum }, '<==output from helm push' )
79
+ } catch ( ex ) {
80
+ // log( ex.stderr )
81
+ log( ex.message )
82
+ museumStatus = 1
83
+ }
69
84
 
70
- try {
71
- log( chalk.green( 'Pushing chart to the Artifact Registry\n' ) )
72
- const registry = await shellCmd( `chart-to-registry --chart ${args.chart}` )
73
- debug( { registry }, '<==chart-to-registry' )
74
- process.exit( museumStatus )
75
- } catch ( ex ) {
76
- log( ex.stderr )
77
- process.exit( museumStatus + 1 )
78
- }
85
+ if ( args.noRegistry ) {
86
+ log( `${chalk.bold.yellow( '\nskipping the chart push to the artifact registry' )}` )
87
+ process.exit( museumStatus )
79
88
  }
80
89
 
81
- pushItGood()
90
+ try {
91
+ log( chalk.green( ' ... pushing to the Artifact Registry' ) )
92
+ const registry = await shellCmd( `chart-to-registry --chart ${args.chart}` )
93
+ debug( { registry }, '<==chart-to-registry' )
94
+ process.exit( museumStatus )
95
+ } catch ( ex ) {
96
+ log( ex.stderr )
97
+ process.exit( museumStatus + 1 )
98
+ }