@leverege/build-tools 2.85.0-beta.9 → 2.86.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.85.0-beta.9",
3
+ "version": "2.86.0-beta.1",
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
@@ -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 deploymentTarget = closestPackageJson?.leverege.deploymentTarget || rootPyProjectToml?.leverege['deployment-target'] || [ '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
+ deploymentTarget,
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
+ deploymentTarget,
105
94
  packageVersion,
106
95
  containerName,
107
96
  imagePlatform,
@@ -112,6 +101,22 @@ const {
112
101
  isPythonProject,
113
102
  } = repoDescr
114
103
 
104
+ const deploymentTargetIncludesK8s = deploymentTarget.includes( 'k8s' )
105
+
106
+ if ( deploymentTargetIncludesK8s ) {
107
+ if ( !fs.existsSync( './helm' ) ) {
108
+ log( `
109
+ ${chalk.red.bold( '***Error: docker-to-registry requires a helm chart directory' )}
110
+
111
+ The docker-to-registry script expects to run in the root directory of a k8s
112
+ service, which requires a helm chart directory. It also expects a docker
113
+ directory but will build that if it does not exist.
114
+
115
+ ` )
116
+ process.exit( 1 )
117
+ }
118
+ }
119
+
115
120
  const leveregeStanza = isNodeJsProject ? repoDescr.closestPackageJson.leverege : repoDescr.rootPyProjectToml.leverege
116
121
 
117
122
  const dockerfileOptions = {
@@ -136,6 +141,8 @@ if ( generateDockerfile ) {
136
141
  dockerInfo = { ...dockerfileOptions }
137
142
  }
138
143
 
144
+ const projectFilename = isPythonProject ? 'pyproject.toml' : 'package.json'
145
+
139
146
  if ( giveGuidance ) {
140
147
  await docker.validateCloudBuildBucket( artifactProject )
141
148
  }
@@ -197,37 +204,37 @@ if ( giveGuidance ) {
197
204
 
198
205
  // do chart checks too
199
206
  let chart
200
- if ( options?.helmChecks !== 'false' ) {
207
+ if ( deploymentTargetIncludesK8s && options?.helmChecks !== 'false' ) {
201
208
  chart = helmChart?.yaml['Chart.yaml']
202
209
  const values = helmChart?.yaml['values.yaml']
203
210
  const expectedChartRegistry = `${artifactRegistry}/images`
204
211
 
205
212
  if ( expectedChartRegistry !== values.image?.registry ) {
206
213
  log( `
207
- ${chalk.red.bold( '***Error: mismatched package.json registry and helm/values.yaml' )}
214
+ ${chalk.red.bold( `***Error: mismatched ${projectFilename} registry and helm/values.yaml` )}
208
215
 
209
- The registry specified in the package.json leverege stanza does not line up
210
- with the image registry in helm/values.yaml. The naming convention expects
211
- the '/images' suffix to be added to the package.json registry string and then
212
- stored as the image.registry in the helm/values.yaml file.
216
+ The registry specified in the ${projectFilename} leverege stanza does not line up
217
+ with the image registry in helm/values.yaml. The naming convention expects
218
+ the '/images' suffix to be added to the ${projectFilename} registry string and then
219
+ stored as the image.registry in the helm/values.yaml file.
213
220
 
214
- Current settings:
215
- package.json registry => ${chalk.yellow.bold( artifactRegistry )}
216
- values.yaml registry => ${chalk.red.bold( values.image?.registry )}
221
+ Current settings:
222
+ ${projectFilename} registry => ${chalk.yellow.bold( artifactRegistry )}
223
+ values.yaml registry => ${chalk.red.bold( values.image?.registry )}
217
224
 
218
- Expected settings:
219
- values.yaml registry => ${chalk.green.bold( expectedChartRegistry )}
220
- ` )
225
+ Expected settings:
226
+ values.yaml registry => ${chalk.green.bold( expectedChartRegistry )}
227
+ ` )
221
228
 
222
229
  if ( !values.image ) {
223
230
  log( `
224
- ${chalk.yellow.bold( '***DEPRECATED: legacy helm charts detected' )}
231
+ ${chalk.yellow.bold( '***DEPRECATED: legacy helm charts detected' )}
225
232
 
226
- The helm chart structure appears to be based on the pre-ignition helm chart
227
- layouts. The charts must be upgraded before docker-to-registry can complete
228
- its job.
233
+ The helm chart structure appears to be based on the pre-ignition helm chart
234
+ layouts. The charts must be upgraded before docker-to-registry can complete
235
+ its job.
229
236
 
230
- ` )
237
+ ` )
231
238
  }
232
239
 
233
240
  process.exit( 1 )
@@ -269,11 +276,12 @@ if ( isPythonProject ) {
269
276
  }
270
277
 
271
278
  if ( imageVersion !== packageVersion ) {
279
+
272
280
  log( `
273
- ${chalk.yellow.bold( '***WARNING: specified version does not match package.json version' )}
274
- package.json => ${chalk.green.bold( packageVersion )}
275
- specified => ${chalk.red.bold( imageVersion )}
276
- ` )
281
+ ${chalk.yellow.bold( `***WARNING: specified version does not match ${projectFilename} version` )}
282
+ ${projectFilename} => ${chalk.green.bold( packageVersion )}
283
+ specified => ${chalk.red.bold( imageVersion )}
284
+ ` )
277
285
 
278
286
  if ( willGitTag ) {
279
287
  log( chalk.red.bold( '... and you are attempting to release so NOPE!\n' ) )
@@ -303,13 +311,16 @@ if ( willGitTag && !repoInfo.upstream ) {
303
311
  }
304
312
 
305
313
  if ( willGitTag ) {
306
- if ( chart.appVersion !== imageVersion ) {
307
- log( `
308
- ${chalk.yellow.bold( '***WARNING: the helm/Chart.yaml appVersion does not align with the build version' )}
309
- chart appVersion => ${chalk.yellow.bold( chart.appVersion )}
310
- build version => ${chalk.green.bold( imageVersion )}
311
- ` )
314
+ if ( deploymentTargetIncludesK8s ) {
315
+ if ( chart.appVersion !== imageVersion ) {
316
+ log( `
317
+ ${chalk.yellow.bold( '***WARNING: the helm/Chart.yaml appVersion does not align with the build version' )}
318
+ chart appVersion => ${chalk.yellow.bold( chart.appVersion )}
319
+ build version => ${chalk.green.bold( imageVersion )}
320
+ ` )
321
+ }
312
322
  }
323
+
313
324
  }
314
325
 
315
326
  if ( process.env.DRY_RUN !== '1' ) {