Skip to content

Commit 7d208b7

Browse files
authored
Merge pull request #4996 from kubernetes-sigs/revert-4992-fix-makefile-target-warning
🌱 Revert "🐛 (alpha commands): alpha update command with `--force` now runs post-merge fixes in best-effort mode raising warnings instead of errors to allow properly automation with this option"
2 parents 720feed + d867592 commit 7d208b7

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

pkg/cli/alpha/internal/update/update.go

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,13 @@ func cleanupBranch() error {
210210
return nil
211211
}
212212

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) {
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() {
216216
targets := []string{"manifests", "generate", "fmt", "vet", "lint-fix"}
217-
218217
for _, target := range targets {
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 {
218+
err := util.RunCmd(fmt.Sprintf("Running make %s", target), "make", target)
219+
if err != nil {
232220
log.Warn("make target failed", "target", target, "error", err)
233221
}
234222
}
@@ -270,8 +258,8 @@ func runAlphaGenerate(tempDir, version string) error {
270258
// It was added because the alpha generate command in versions prior to v4.7.0 does
271259
// not run those commands automatically which will not allow we properly ensure
272260
// that all manifests, code generation, formatting, and linting are applied to
273-
// properly do the 3-way merge. We use true to ignore errors and do our best effort
274-
runMakeTargets(false)
261+
// properly do the 3-way merge.
262+
runMakeTargets()
275263
return nil
276264
}
277265

@@ -367,8 +355,8 @@ func (opts *Update) mergeOriginalToUpgrade() error {
367355
log.Info("Merge happened without conflicts.")
368356
}
369357

370-
// When the --force flag is used has the best effort to run the make targets
371-
runMakeTargets(opts.Force)
358+
// Best effort to run make targets to ensure the project is in a good state
359+
runMakeTargets()
372360

373361
// Step 4: Stage and commit
374362
if err := exec.Command("git", "add", "--all").Run(); err != nil {

pkg/cli/alpha/internal/update/update_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ var _ = Describe("Prepare for internal update", func() {
281281
err = mockBinResponse(fakeBinScript, mockMake)
282282
Expect(err).ToNot(HaveOccurred())
283283

284-
runMakeTargets(true)
284+
runMakeTargets()
285285
})
286286
})
287287

0 commit comments

Comments
 (0)