@leverege/build-tools 2.48.2 → 2.48.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.48.2",
3
+ "version": "2.48.3",
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
@@ -349,7 +349,7 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
349
349
  return ( {
350
350
  chartPackage,
351
351
  imageRegistry,
352
- registryRegion : registryComponents[0],
352
+ registryLocation : registryComponents[0],
353
353
  registryProject : registryComponents[1],
354
354
  registryRepository : registryComponents[2],
355
355
  files : chartFiles,
@@ -20,16 +20,19 @@ import {
20
20
 
21
21
  const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
22
22
  /* eslint-disable max-len */
23
+ {
24
+ name : 'dry-run',
25
+ type : Boolean,
26
+ description : '{green perform everything except the actuall chart push}',
27
+ },
23
28
  {
24
29
  name : 'location',
25
30
  type : String,
26
- defaultValue : 'us-docker.pkg.dev',
27
31
  description : '{green the location of the artifact registry the chart will be pushed to (default us-docker.pkg.dev)}',
28
32
  },
29
33
  {
30
34
  name : 'project',
31
35
  type : String,
32
- defaultValue : process.env.HELM_CHART_REGISTRY || 'leverege-registry',
33
36
  description : '{green the name of the google project containing the npmrc and slack config secrets (default leverege-registry)}',
34
37
  },
35
38
  {
@@ -77,20 +80,6 @@ if ( semverLt( process.version, minNodejsVersion ) ) {
77
80
  errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
78
81
  }
79
82
 
80
- // gcloud auth print-access-token | helm registry login -u oauth2accesstoken \
81
- // -p ${password} https://us-docker.pkg.dev
82
- //
83
- // Get the current access token and use it to login to the registry with helm.
84
- try {
85
- const accessToken = await shellCmd( 'gcloud auth print-access-token' )
86
- const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
87
-
88
- const loginResult = await shellCmd( `${registryLoginCommand} https://${args.location}` ) // TODO: cmd line param
89
- debug( { loginResult }, '<==registryLogin' )
90
- } catch ( error ) {
91
- errorExit( error )
92
- }
93
-
94
83
  // First of all, fail if we are not in a git repository
95
84
  let gitRoot
96
85
  try {
@@ -115,8 +104,6 @@ try {
115
104
  errorExit( error )
116
105
  }
117
106
 
118
- debug( { packageJson, helmChart }, '<==Parsed package and chart' )
119
-
120
107
  // helm push helm-package.tgz oci://REGISTRY_LOCATION/REGISTRY_PROJECT/REGISTRY_REPOSITORY/charts
121
108
  //
122
109
  const registryLocation = args.location || helmChart.registryLocation
@@ -124,6 +111,28 @@ const registryProject = args.project || helmChart.registryProject
124
111
  const registryRepository = args.repository || helmChart.registryRepository
125
112
  const ociPushEndpoint = `oci://${registryLocation}/${registryProject}/${registryRepository}/charts`
126
113
 
114
+ debug( {
115
+ packageJson,
116
+ helmChart,
117
+ registryLocation,
118
+ registryProject,
119
+ registryRepository,
120
+ ociPushEndpoint }, '<==Parsed package and chart' )
121
+
122
+ // gcloud auth print-access-token | helm registry login -u oauth2accesstoken \
123
+ // -p ${password} https://us-docker.pkg.dev
124
+ //
125
+ // Get the current access token and use it to login to the registry with helm.
126
+ try {
127
+ const accessToken = await shellCmd( 'gcloud auth print-access-token' )
128
+ const registryLoginCommand = `echo ${accessToken} | helm registry login --username oauth2accesstoken --password-stdin`
129
+
130
+ const loginResult = await shellCmd( `${registryLoginCommand} https://${registryLocation}` ) // TODO: cmd line param
131
+ debug( { loginResult }, '<==registryLogin' )
132
+ } catch ( error ) {
133
+ errorExit( error )
134
+ }
135
+
127
136
  try {
128
137
  await shellCmd( 'helm package helm' )
129
138
  const { chartPackage } = helmChart
@@ -132,7 +141,12 @@ try {
132
141
  }
133
142
 
134
143
  log( `\nPushing ${chalk.green.bold( chartPackage )} => ${chalk.green.bold( ociPushEndpoint )}` )
135
- await shellCmd( `helm push ${chartPackage} ${ociPushEndpoint}` )
144
+ const pushItRealGood = `helm push ${chartPackage} ${ociPushEndpoint}`
145
+ if ( !args.dryRun ) {
146
+ await shellCmd( pushItRealGood )
147
+ } else {
148
+ log( `\nDry run => ${chalk.green.bold( pushItRealGood )}` )
149
+ }
136
150
  rmSync( chartPackage )
137
151
  } catch ( err ) {
138
152
  errorExit( err )