@@ -210,13 +210,25 @@ func cleanupBranch() error {
210
210
return nil
211
211
}
212
212
213
- // runMakeTargets is a helper function to run make with the targets necessary
214
- // to ensure all the necessary components are generated, formatted and linted .
215
- func runMakeTargets () {
213
+ // runMakeTargets runs the specified make targets to ensure the project is in a good state.
214
+ // If force is true, do not run target with || true to move forward when failures are faced .
215
+ func runMakeTargets (force bool ) {
216
216
targets := []string {"manifests" , "generate" , "fmt" , "vet" , "lint-fix" }
217
+
217
218
for _ , target := range targets {
218
- err := util .RunCmd (fmt .Sprintf ("Running make %s" , target ), "make" , target )
219
- if err != nil {
219
+ var cmd []string
220
+ var msg string
221
+
222
+ if force {
223
+ msg = fmt .Sprintf ("Running make %s (with --force)" , target )
224
+ shellCmd := fmt .Sprintf ("make %s || true" , target )
225
+ cmd = []string {"sh" , "-c" , shellCmd }
226
+ } else {
227
+ msg = fmt .Sprintf ("Running make %s" , target )
228
+ cmd = []string {"make" , target }
229
+ }
230
+
231
+ if err := util .RunCmd (msg , cmd [0 ], cmd [1 :]... ); err != nil {
220
232
log .Warn ("make target failed" , "target" , target , "error" , err )
221
233
}
222
234
}
@@ -258,8 +270,8 @@ func runAlphaGenerate(tempDir, version string) error {
258
270
// It was added because the alpha generate command in versions prior to v4.7.0 does
259
271
// not run those commands automatically which will not allow we properly ensure
260
272
// that all manifests, code generation, formatting, and linting are applied to
261
- // properly do the 3-way merge.
262
- runMakeTargets ()
273
+ // properly do the 3-way merge. We use true to ignore errors and do our best effort
274
+ runMakeTargets (false )
263
275
return nil
264
276
}
265
277
@@ -355,8 +367,8 @@ func (opts *Update) mergeOriginalToUpgrade() error {
355
367
log .Info ("Merge happened without conflicts." )
356
368
}
357
369
358
- // Best effort to run make targets to ensure the project is in a good state
359
- runMakeTargets ()
370
+ // When the --force flag is used has the best effort to run the make targets
371
+ runMakeTargets (opts . Force )
360
372
361
373
// Step 4: Stage and commit
362
374
if err := exec .Command ("git" , "add" , "--all" ).Run (); err != nil {
0 commit comments