Skip to content

Commit 2a2c132

Browse files
committed
pkg/cli/admin/upgrade/recommend: Add a blank line after --version conditional risk
When I added the: Update to 4.18.6 Recommended=False: ... block in c1ef328 (pkg/cli/admin/upgrade/recommend: Add --version option for specific releases, 2024-10-14, #1897), there was no subsequent output in this "--version has conditional risks" case, so the earlier lack-of-blank-line made sense. But then 2d7e004 (pkg/cli/admin/upgrade/recommend: New, feature-gated --accept, 2025-05-06, #2023) gave the option for a subsequent: error: issues that apply to this cluster but which were not included in --accept: ... or: Update to %s has no known issues relevant... This commit adds a new line to standard output, to offset those summaries from the possibly-long Message: ... Update to 4.18.6 Recommended=False: Image: quay.io/openshift-release-dev/ocp-release@sha256:61fdad894f035a8b192647c224faf565279518255bdbf60a91db4ee0479adaa6 Release URL: https://access.redhat.com/errata/RHSA-2025:3066 Reason: CRIOLayerCompressionPulls Message: The CRI-O container runtime may fail to pull images with certain layer compression characteristics https://issues.redhat.com/browse/OCPNODE-3074 error: issues that apply to this cluster but which were not included in --accept: ConditionalUpdateRisk,KubeContainerWaiting instead of cramming that 'error: ...' or '... has no known issues...' right onto the end of the output. Although the error is getting written to standard error instead of the standard output, so in that case, the newline will only matter for terminal users and others who are flattening those two streams together. And now that we have the additional newline handling in recommend.go, I can drop the newline I'd been manually injecting in examples_test.go to make the test fixtures more readable. I should have noticed that test-specific injection as a sign that the better recommend.go newline handling was useful. Oh well, better late than never.
1 parent 9b2ae28 commit 2a2c132

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestExamples(t *testing.T) {
9797
opts.ErrOut = &stderr
9898

9999
if err := opts.Run(context.Background()); err != nil {
100-
compareWithFixture(t, bytes.Join([][]byte{stdout.Bytes(), []byte("\nerror: "), []byte(err.Error()), []byte("\n")}, []byte{}), cv, variant.outputSuffix)
100+
compareWithFixture(t, bytes.Join([][]byte{stdout.Bytes(), []byte("error: "), []byte(err.Error()), []byte("\n")}, []byte{}), cv, variant.outputSuffix)
101101
} else {
102102
compareWithFixture(t, stdout.Bytes(), cv, variant.outputSuffix)
103103
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,12 @@ func (o *options) Run(ctx context.Context) error {
343343
}
344344
unaccepted := issues.Difference(accept)
345345
if unaccepted.Len() > 0 {
346+
if !o.quiet {
347+
fmt.Fprintln(o.Out)
348+
}
346349
return fmt.Errorf("issues that apply to this cluster but which were not included in --accept: %s", strings.Join(sets.List(unaccepted), ","))
347350
} else if issues.Len() > 0 && !o.quiet {
348-
fmt.Fprintf(o.Out, "Update to %s has no known issues relevant to this cluster other than the accepted %s.\n", update.Release.Version, strings.Join(sets.List(issues), ","))
351+
fmt.Fprintf(o.Out, "\nUpdate to %s has no known issues relevant to this cluster other than the accepted %s.\n", update.Release.Version, strings.Join(sets.List(issues), ","))
349352
}
350353
return nil
351354
}

0 commit comments

Comments
 (0)