Skip to content

Commit cb28d27

Browse files
committed
pkg/cli/admin/upgrade/recommend: Drop obsolete precheckEnabled knob
Since 8bdac16 (pkg/cli/admin/upgrade/recommend: Enable precheck and accept gates, 2025-09-03, #2088), this knob has always been enabled. Save ourselves a no longer necessary level of indentation by removing it completely.
1 parent fa1bc38 commit cb28d27

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

pkg/cli/admin/upgrade/recommend/examples_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func TestExamples(t *testing.T) {
9191
if err := opts.Complete(nil, nil, nil); err != nil {
9292
t.Fatalf("Error when completing options: %v", err)
9393
}
94-
opts.precheckEnabled = true
9594

9695
var stdout, stderr bytes.Buffer
9796
opts.Out = &stdout

pkg/cli/admin/upgrade/recommend/recommend.go

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ type options struct {
7676

7777
mockData mockData
7878
showOutdatedReleases bool
79-
precheckEnabled bool
8079

8180
// quiet configures the verbosity of output. When 'quiet' is true and 'version' is set, only print unaccepted issue names.
8281
quiet bool
@@ -134,8 +133,6 @@ func (o *options) Complete(f kcmdutil.Factory, cmd *cobra.Command, args []string
134133
}
135134
}
136135

137-
o.precheckEnabled = true
138-
139136
return nil
140137
}
141138

@@ -188,47 +185,45 @@ func (o *options) Run(ctx context.Context) error {
188185
issues.Insert(string(configv1.OperatorProgressing))
189186
}
190187

191-
if o.precheckEnabled {
192-
conditions, err := o.precheck(ctx)
193-
if err != nil {
194-
if !o.quiet {
195-
fmt.Fprintf(o.Out, "Failed to check for at least some preconditions: %v\n", err)
196-
}
197-
issues.Insert("FailedToCompletePrecheck")
198-
}
199-
var happyConditions []string
200-
var acceptedConditions []string
201-
var unhappyConditions []string
202-
for _, condition := range conditions {
203-
if condition.Status == metav1.ConditionTrue {
204-
happyConditions = append(happyConditions, fmt.Sprintf("%s (%s)", condition.Type, condition.Reason))
188+
conditions, err := o.precheck(ctx)
189+
if err != nil {
190+
if !o.quiet {
191+
fmt.Fprintf(o.Out, "Failed to check for at least some preconditions: %v\n", err)
192+
}
193+
issues.Insert("FailedToCompletePrecheck")
194+
}
195+
var happyConditions []string
196+
var acceptedConditions []string
197+
var unhappyConditions []string
198+
for _, condition := range conditions {
199+
if condition.Status == metav1.ConditionTrue {
200+
happyConditions = append(happyConditions, fmt.Sprintf("%s (%s)", condition.Type, condition.Reason))
201+
} else {
202+
issues.Insert(condition.acceptanceName)
203+
if accept.Has(condition.acceptanceName) {
204+
acceptedConditions = append(acceptedConditions, condition.Type)
205205
} else {
206-
issues.Insert(condition.acceptanceName)
207-
if accept.Has(condition.acceptanceName) {
208-
acceptedConditions = append(acceptedConditions, condition.Type)
209-
} else {
210-
unhappyConditions = append(unhappyConditions, condition.Type)
211-
}
206+
unhappyConditions = append(unhappyConditions, condition.Type)
212207
}
213208
}
209+
}
214210

215-
if !o.quiet {
216-
if len(happyConditions) > 0 {
217-
sort.Strings(happyConditions)
218-
fmt.Fprintf(o.Out, "The following conditions found no cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(happyConditions, ", "))
219-
}
220-
if len(acceptedConditions) > 0 {
221-
sort.Strings(acceptedConditions)
222-
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases, but were explicitly accepted via --accept: %s\n\n", strings.Join(acceptedConditions, ", "))
223-
}
224-
if len(unhappyConditions) > 0 {
225-
sort.Strings(unhappyConditions)
226-
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(unhappyConditions, ", "))
211+
if !o.quiet {
212+
if len(happyConditions) > 0 {
213+
sort.Strings(happyConditions)
214+
fmt.Fprintf(o.Out, "The following conditions found no cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(happyConditions, ", "))
215+
}
216+
if len(acceptedConditions) > 0 {
217+
sort.Strings(acceptedConditions)
218+
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases, but were explicitly accepted via --accept: %s\n\n", strings.Join(acceptedConditions, ", "))
219+
}
220+
if len(unhappyConditions) > 0 {
221+
sort.Strings(unhappyConditions)
222+
fmt.Fprintf(o.Out, "The following conditions found cause for concern in updating this cluster to later releases: %s\n\n", strings.Join(unhappyConditions, ", "))
227223

228-
for _, c := range conditions {
229-
if c.Status != metav1.ConditionTrue {
230-
fmt.Fprintf(o.Out, "%s=%s:\n\n Reason: %s\n Message: %s\n\n", c.Type, c.Status, c.Reason, strings.ReplaceAll(c.Message, "\n", "\n "))
231-
}
224+
for _, c := range conditions {
225+
if c.Status != metav1.ConditionTrue {
226+
fmt.Fprintf(o.Out, "%s=%s:\n\n Reason: %s\n Message: %s\n\n", c.Type, c.Status, c.Reason, strings.ReplaceAll(c.Message, "\n", "\n "))
232227
}
233228
}
234229
}

0 commit comments

Comments
 (0)