@leverege/build-tools 2.48.2 → 2.48.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 +1 -1
- package/src/Utils.mjs +1 -1
- package/src/chart-to-registry.mjs +34 -19
- package/src/chart-compass.mjs +0 -81
package/package.json
CHANGED
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
|
-
|
|
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,29 @@ 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
|
+
// -p is frowned upon but using a pipe | is problematic with shellCmd (execa)
|
|
129
|
+
const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
|
|
130
|
+
|
|
131
|
+
const loginResult = await shellCmd( `${registryLoginCommand} https://${registryLocation}` )
|
|
132
|
+
debug( { loginResult }, '<==registryLogin' )
|
|
133
|
+
} catch ( error ) {
|
|
134
|
+
errorExit( error )
|
|
135
|
+
}
|
|
136
|
+
|
|
127
137
|
try {
|
|
128
138
|
await shellCmd( 'helm package helm' )
|
|
129
139
|
const { chartPackage } = helmChart
|
|
@@ -132,7 +142,12 @@ try {
|
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
log( `\nPushing ${chalk.green.bold( chartPackage )} => ${chalk.green.bold( ociPushEndpoint )}` )
|
|
135
|
-
|
|
145
|
+
const pushItRealGood = `helm push ${chartPackage} ${ociPushEndpoint}`
|
|
146
|
+
if ( !args.dryRun ) {
|
|
147
|
+
await shellCmd( pushItRealGood )
|
|
148
|
+
} else {
|
|
149
|
+
log( `\nDry run => ${chalk.green.bold( pushItRealGood )}` )
|
|
150
|
+
}
|
|
136
151
|
rmSync( chartPackage )
|
|
137
152
|
} catch ( err ) {
|
|
138
153
|
errorExit( err )
|
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
|
-
|