@leverege/build-tools 2.85.0 → 2.86.0-beta.2
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 +3 -0
- package/src/docker-to-registry.mjs +48 -39
package/package.json
CHANGED
package/src/Utils.mjs
CHANGED
|
@@ -580,6 +580,8 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
580
580
|
const artifactProject = closestPackageJson?.artifactRegistry.project || rootPyProjectToml?.artifactRegistry.project || 'unknown'
|
|
581
581
|
const packageVersion = `v${closestPackageJson?.version || rootPyProjectToml?.project.version}`
|
|
582
582
|
const generateDockerfile = ( closestPackageJson?.leverege.generateDockerfile || rootPyProjectToml?.leverege['generate-dockerfile'] ) ?? true
|
|
583
|
+
const requiresHelmChart = closestPackageJson?.leverege.requiresHelmChart || rootPyProjectToml?.leverege['requires-helm-chart'] || [ 'k8s' ]
|
|
584
|
+
|
|
583
585
|
const currentDir = process.cwd()
|
|
584
586
|
const closestPkg = await packageUp()
|
|
585
587
|
|
|
@@ -601,6 +603,7 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
601
603
|
artifactProject,
|
|
602
604
|
artifactRegistry,
|
|
603
605
|
buildToolsVersion,
|
|
606
|
+
requiresHelmChart,
|
|
604
607
|
containerName,
|
|
605
608
|
imagePlatform,
|
|
606
609
|
currentDir,
|
|
@@ -78,18 +78,6 @@ if ( willGitTag && repoIsDirty ) {
|
|
|
78
78
|
process.exit( 1 )
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
if ( !fs.existsSync( './helm' ) ) {
|
|
82
|
-
log( `
|
|
83
|
-
${chalk.red.bold( '***Error: docker-to-registry requires a helm chart directory' )}
|
|
84
|
-
|
|
85
|
-
The docker-to-registry script expects to run in the root directory of a k8s
|
|
86
|
-
service, which requires a helm chart directory. It also expects a docker
|
|
87
|
-
directory but will build that if it does not exist.
|
|
88
|
-
|
|
89
|
-
` )
|
|
90
|
-
process.exit( 1 )
|
|
91
|
-
}
|
|
92
|
-
|
|
93
81
|
const repoDescr = await analyzeRepository( giveGuidance )
|
|
94
82
|
debug( { repoDescr }, '<==The Repo Description' )
|
|
95
83
|
|
|
@@ -102,6 +90,7 @@ if ( semver.lt( semver.coerce( repoDescr.buildToolsVersion ), minimumBuildToolsV
|
|
|
102
90
|
const {
|
|
103
91
|
artifactProject,
|
|
104
92
|
artifactRegistry,
|
|
93
|
+
requiresHelmChart,
|
|
105
94
|
packageVersion,
|
|
106
95
|
containerName,
|
|
107
96
|
imagePlatform,
|
|
@@ -112,6 +101,20 @@ const {
|
|
|
112
101
|
isPythonProject,
|
|
113
102
|
} = repoDescr
|
|
114
103
|
|
|
104
|
+
if ( requiresHelmChart ) {
|
|
105
|
+
if ( !fs.existsSync( './helm' ) ) {
|
|
106
|
+
log( `
|
|
107
|
+
${chalk.red.bold( '***Error: docker-to-registry requires a helm chart directory' )}
|
|
108
|
+
|
|
109
|
+
The docker-to-registry script expects to run in the root directory of a k8s
|
|
110
|
+
service, which requires a helm chart directory. It also expects a docker
|
|
111
|
+
directory but will build that if it does not exist.
|
|
112
|
+
|
|
113
|
+
` )
|
|
114
|
+
process.exit( 1 )
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
115
118
|
const leveregeStanza = isNodeJsProject ? repoDescr.closestPackageJson.leverege : repoDescr.rootPyProjectToml.leverege
|
|
116
119
|
|
|
117
120
|
const dockerfileOptions = {
|
|
@@ -136,6 +139,8 @@ if ( generateDockerfile ) {
|
|
|
136
139
|
dockerInfo = { ...dockerfileOptions }
|
|
137
140
|
}
|
|
138
141
|
|
|
142
|
+
const projectFilename = isPythonProject ? 'pyproject.toml' : 'package.json'
|
|
143
|
+
|
|
139
144
|
if ( giveGuidance ) {
|
|
140
145
|
await docker.validateCloudBuildBucket( artifactProject )
|
|
141
146
|
}
|
|
@@ -197,37 +202,37 @@ if ( giveGuidance ) {
|
|
|
197
202
|
|
|
198
203
|
// do chart checks too
|
|
199
204
|
let chart
|
|
200
|
-
if ( options?.helmChecks !== 'false' ) {
|
|
205
|
+
if ( requiresHelmChart && options?.helmChecks !== 'false' ) {
|
|
201
206
|
chart = helmChart?.yaml['Chart.yaml']
|
|
202
207
|
const values = helmChart?.yaml['values.yaml']
|
|
203
208
|
const expectedChartRegistry = `${artifactRegistry}/images`
|
|
204
209
|
|
|
205
210
|
if ( expectedChartRegistry !== values.image?.registry ) {
|
|
206
211
|
log( `
|
|
207
|
-
|
|
212
|
+
${chalk.red.bold( `***Error: mismatched ${projectFilename} registry and helm/values.yaml` )}
|
|
208
213
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
The registry specified in the ${projectFilename} leverege stanza does not line up
|
|
215
|
+
with the image registry in helm/values.yaml. The naming convention expects
|
|
216
|
+
the '/images' suffix to be added to the ${projectFilename} registry string and then
|
|
217
|
+
stored as the image.registry in the helm/values.yaml file.
|
|
213
218
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
219
|
+
Current settings:
|
|
220
|
+
${projectFilename} registry => ${chalk.yellow.bold( artifactRegistry )}
|
|
221
|
+
values.yaml registry => ${chalk.red.bold( values.image?.registry )}
|
|
217
222
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
Expected settings:
|
|
224
|
+
values.yaml registry => ${chalk.green.bold( expectedChartRegistry )}
|
|
225
|
+
` )
|
|
221
226
|
|
|
222
227
|
if ( !values.image ) {
|
|
223
228
|
log( `
|
|
224
|
-
|
|
229
|
+
${chalk.yellow.bold( '***DEPRECATED: legacy helm charts detected' )}
|
|
225
230
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
231
|
+
The helm chart structure appears to be based on the pre-ignition helm chart
|
|
232
|
+
layouts. The charts must be upgraded before docker-to-registry can complete
|
|
233
|
+
its job.
|
|
229
234
|
|
|
230
|
-
|
|
235
|
+
` )
|
|
231
236
|
}
|
|
232
237
|
|
|
233
238
|
process.exit( 1 )
|
|
@@ -269,11 +274,12 @@ if ( isPythonProject ) {
|
|
|
269
274
|
}
|
|
270
275
|
|
|
271
276
|
if ( imageVersion !== packageVersion ) {
|
|
277
|
+
|
|
272
278
|
log( `
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
279
|
+
${chalk.yellow.bold( `***WARNING: specified version does not match ${projectFilename} version` )}
|
|
280
|
+
${projectFilename} => ${chalk.green.bold( packageVersion )}
|
|
281
|
+
specified => ${chalk.red.bold( imageVersion )}
|
|
282
|
+
` )
|
|
277
283
|
|
|
278
284
|
if ( willGitTag ) {
|
|
279
285
|
log( chalk.red.bold( '... and you are attempting to release so NOPE!\n' ) )
|
|
@@ -303,13 +309,16 @@ if ( willGitTag && !repoInfo.upstream ) {
|
|
|
303
309
|
}
|
|
304
310
|
|
|
305
311
|
if ( willGitTag ) {
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
+
if ( requiresHelmChart ) {
|
|
313
|
+
if ( chart.appVersion !== imageVersion ) {
|
|
314
|
+
log( `
|
|
315
|
+
${chalk.yellow.bold( '***WARNING: the helm/Chart.yaml appVersion does not align with the build version' )}
|
|
316
|
+
chart appVersion => ${chalk.yellow.bold( chart.appVersion )}
|
|
317
|
+
build version => ${chalk.green.bold( imageVersion )}
|
|
318
|
+
` )
|
|
319
|
+
}
|
|
312
320
|
}
|
|
321
|
+
|
|
313
322
|
}
|
|
314
323
|
|
|
315
324
|
if ( process.env.DRY_RUN !== '1' ) {
|