@leverege/build-tools 2.48.3 → 2.48.5
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 +1 -1
- package/src/Utils.mjs +6 -2
- package/src/chart-to-registry.mjs +27 -8
- package/src/chart-compass.mjs +0 -81
package/package.json
CHANGED
package/src/Utils.mjs
CHANGED
|
@@ -317,7 +317,7 @@ https://console.cloud.google.com/artifacts/browse/leverege-registry?project=leve
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
// DEPRECATED: old museum reference to push-my-chart instead of chart-to-registry
|
|
320
|
-
if ( museum.match( 'push-my-chart' ) ) {
|
|
320
|
+
if ( museum.match( 'DISABLED-push-my-chart' ) ) {
|
|
321
321
|
const deprecationError = `
|
|
322
322
|
|
|
323
323
|
Update the npm museum script to use chart-to-registry instead of the deprecated
|
|
@@ -341,13 +341,17 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
|
|
|
341
341
|
if ( !existsSync( helmroot ) ) { return undefined }
|
|
342
342
|
const chartFiles = readdirSync( helmroot, { encoding : 'utf8', recursive : true } )
|
|
343
343
|
const chartYaml = YAML.load( readFileSync( `${helmroot}/Chart.yaml`, 'utf8' ) )
|
|
344
|
-
const
|
|
344
|
+
const chartName = chartYaml.name
|
|
345
|
+
const chartVersion = chartYaml.version
|
|
346
|
+
const chartPackage = `${chartName}-${chartVersion}.tgz`
|
|
345
347
|
const valuesYaml = YAML.load( readFileSync( `${helmroot}/values.yaml`, 'utf8' ) )
|
|
346
348
|
const imageRegistry = valuesYaml.image?.registry
|
|
347
349
|
const registryComponents = imageRegistry.split( '/' )
|
|
348
350
|
/* eslint-enable security/detect-non-literal-fs-filename */
|
|
349
351
|
return ( {
|
|
352
|
+
chartName,
|
|
350
353
|
chartPackage,
|
|
354
|
+
chartVersion,
|
|
351
355
|
imageRegistry,
|
|
352
356
|
registryLocation : registryComponents[0],
|
|
353
357
|
registryProject : registryComponents[1],
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
debug,
|
|
14
14
|
errorExit,
|
|
15
15
|
log,
|
|
16
|
+
warning,
|
|
16
17
|
getGitRootDirectory,
|
|
17
18
|
parsePackageJson,
|
|
18
19
|
parseHelmChart,
|
|
@@ -20,11 +21,6 @@ import {
|
|
|
20
21
|
|
|
21
22
|
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
22
23
|
/* eslint-disable max-len */
|
|
23
|
-
{
|
|
24
|
-
name : 'dry-run',
|
|
25
|
-
type : Boolean,
|
|
26
|
-
description : '{green perform everything except the actuall chart push}',
|
|
27
|
-
},
|
|
28
24
|
{
|
|
29
25
|
name : 'location',
|
|
30
26
|
type : String,
|
|
@@ -40,6 +36,16 @@ const commandLineOptions = [ // Use commandLineOptions to tie into the Usage sta
|
|
|
40
36
|
type : String,
|
|
41
37
|
description : '{green the target repository to receive the pushed chart}',
|
|
42
38
|
},
|
|
39
|
+
{
|
|
40
|
+
name : 'dry-run',
|
|
41
|
+
type : Boolean,
|
|
42
|
+
description : '{yellow perform everything except the actual chart push}',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name : 'force',
|
|
46
|
+
type : Boolean,
|
|
47
|
+
description : '{yellow push the chart even if it already exists in the registry}',
|
|
48
|
+
},
|
|
43
49
|
{
|
|
44
50
|
name : 'help',
|
|
45
51
|
type : Boolean,
|
|
@@ -125,17 +131,30 @@ debug( {
|
|
|
125
131
|
// Get the current access token and use it to login to the registry with helm.
|
|
126
132
|
try {
|
|
127
133
|
const accessToken = await shellCmd( 'gcloud auth print-access-token' )
|
|
128
|
-
|
|
134
|
+
// -p is frowned upon but using a pipe | is problematic with shellCmd (execa)
|
|
135
|
+
const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
|
|
129
136
|
|
|
130
|
-
const loginResult = await shellCmd( `${registryLoginCommand} https://${registryLocation}` )
|
|
137
|
+
const loginResult = await shellCmd( `${registryLoginCommand} https://${registryLocation}` )
|
|
131
138
|
debug( { loginResult }, '<==registryLogin' )
|
|
132
139
|
} catch ( error ) {
|
|
133
140
|
errorExit( error )
|
|
134
141
|
}
|
|
135
142
|
|
|
143
|
+
const { chartName, chartPackage, chartVersion } = helmChart
|
|
144
|
+
try {
|
|
145
|
+
await shellCmd( `helm pull ${ociPushEndpoint}/${chartName} --version ${chartVersion}` )
|
|
146
|
+
rmSync( chartPackage )
|
|
147
|
+
if ( args.force ) {
|
|
148
|
+
warning( `chart ${chartName} version ${chartVersion} exists - force pushing` )
|
|
149
|
+
} else {
|
|
150
|
+
errorExit( `Error: chart ${chartName} version ${chartVersion} already exists` )
|
|
151
|
+
}
|
|
152
|
+
} catch ( error ) {
|
|
153
|
+
debug( `Chart ${chartName} version ${chartVersion} does not exist - proceeding` )
|
|
154
|
+
}
|
|
155
|
+
|
|
136
156
|
try {
|
|
137
157
|
await shellCmd( 'helm package helm' )
|
|
138
|
-
const { chartPackage } = helmChart
|
|
139
158
|
if ( !existsSync( chartPackage ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
|
|
140
159
|
errorExit( `Error: expected helm package to produce ${chartPackage}` )
|
|
141
160
|
}
|
package/src/chart-compass.mjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*
|
|
3
|
-
* chart-to-registry will...
|
|
4
|
-
*/
|
|
5
|
-
import { existsSync, rmSync } from 'node:fs'
|
|
6
|
-
|
|
7
|
-
import chalk from 'chalk'
|
|
8
|
-
import commandLineArgs from 'command-line-args'
|
|
9
|
-
import commandLineUsage from 'command-line-usage'
|
|
10
|
-
import { lt as semverLt } from 'semver'
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
debug,
|
|
14
|
-
errorExit,
|
|
15
|
-
log,
|
|
16
|
-
getGitRootDirectory,
|
|
17
|
-
parsePackageJson,
|
|
18
|
-
parseHelmChart,
|
|
19
|
-
shellCmd } from './Utils.mjs'
|
|
20
|
-
|
|
21
|
-
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
22
|
-
/* eslint-disable max-len */
|
|
23
|
-
{
|
|
24
|
-
name : 'location',
|
|
25
|
-
type : String,
|
|
26
|
-
defaultValue : 'us-docker.pkg.dev',
|
|
27
|
-
description : '{green the location of the artifact registry the chart will be pushed to (default us-docker.pkg.dev)}',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name : 'project',
|
|
31
|
-
type : String,
|
|
32
|
-
defaultValue : process.env.HELM_CHART_REGISTRY || 'leverege-registry',
|
|
33
|
-
description : '{green the name of the google project containing the npmrc and slack config secrets (default leverege-registry)}',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name : 'repository',
|
|
37
|
-
type : String,
|
|
38
|
-
description : '{green the target repository to receive the pushed chart}',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name : 'help',
|
|
42
|
-
type : Boolean,
|
|
43
|
-
description : '{green display this help screen}',
|
|
44
|
-
},
|
|
45
|
-
/* eslint-enable max-len */
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
const sections = [
|
|
49
|
-
{
|
|
50
|
-
header : 'Leverege Helm Chart Location Tool',
|
|
51
|
-
content : `{green A tool for locating helm charts in registries. It was created to allow
|
|
52
|
-
the helmup.sh bash script to easily locate charts, which may be in the
|
|
53
|
-
chart museum, La everge artifact-registry project or a 3rd party
|
|
54
|
-
developer\'s artifact-registry.}`
|
|
55
|
-
},
|
|
56
|
-
{ header : 'Options',
|
|
57
|
-
optionList : commandLineOptions,
|
|
58
|
-
},
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
const args = commandLineArgs( commandLineOptions, { camelCase : true, partial : true } )
|
|
62
|
-
const usage = commandLineUsage( sections )
|
|
63
|
-
|
|
64
|
-
if ( args.help ) {
|
|
65
|
-
log( usage )
|
|
66
|
-
process.exit( 0 )
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* eslint-disable no-underscore-dangle */
|
|
70
|
-
if ( args._unknown ) {
|
|
71
|
-
log( usage )
|
|
72
|
-
log( `\nUnrecognized argument [${chalk.bold.red( args._unknown )}]\n` )
|
|
73
|
-
process.exit( 1 )
|
|
74
|
-
}
|
|
75
|
-
/* eslint-enable no-underscore-dangle */
|
|
76
|
-
|
|
77
|
-
const minNodejsVersion = '18.0.0'
|
|
78
|
-
if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
79
|
-
errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
|
|
80
|
-
}
|
|
81
|
-
|