Skip to content

Commit 5f13021

Browse files
committed
fix(upgrade): say where the install image actually comes from
The --image flag is inherited from upstream, whose help advertises a factory image as the default. That default only applies to a bare `talm upgrade`: with -f and no explicit --image the target is values.yaml::image at the project root. The flag list and the synopsis above it disagreed, and the flag list is what an operator reads first. Signed-off-by: Aleksei Sviridkin <[email protected]> Assisted-by: LLM
1 parent 7fb8fb8 commit 5f13021

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎docs/reference/upgrade.md‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright Cozystack Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package commands
16+
17+
import (
18+
"strings"
19+
"testing"
20+
21+
"github.com/spf13/cobra"
22+
)
23+
24+
// The --image flag comes from upstream, whose help names a factory image as
25+
// the default. talm resolves the target from values.yaml whenever -f is given
26+
// without an explicit --image, so the inherited text describes a default that
27+
// the documented flow never reaches.
28+
func TestContract_UpgradeImageFlagHelpNamesTheResolution(t *testing.T) {
29+
cmd := &cobra.Command{Use: "upgrade"}
30+
cmd.Flags().StringP("image", "i", "factory.talos.dev/metal-installer/abc:v1.14.0",
31+
"the container image to use for performing the install")
32+
33+
wrapUpgradeCommand(cmd, nil)
34+
35+
usage := cmd.Flags().Lookup("image").Usage
36+
if !strings.Contains(usage, "values.yaml") {
37+
t.Errorf("--image help does not mention where the target actually comes from:\n%s", usage)
38+
}
39+
}

‎pkg/commands/upgrade_handler.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ Post-upgrade sync (when the upgrade succeeds):
107107
intentionally leaves the body untouched, so it still reflects
108108
what the node actually runs.`
109109

110+
// Upstream's --image help advertises a factory image as the default, which
111+
// only applies to a bare `talm upgrade`. With -f and no explicit --image the
112+
// target comes from values.yaml, so the inherited text describes a default
113+
// the documented flow never reaches. Rewrite it rather than let the flag
114+
// list contradict the synopsis above.
115+
if imageFlag := wrappedCmd.Flags().Lookup("image"); imageFlag != nil {
116+
imageFlag.Usage = "the container image to use for performing the install; " +
117+
"with -f and no explicit --image the target is values.yaml::image at the project root, " +
118+
"and the default shown here does not apply"
119+
}
120+
110121
wrappedCmd.Flags().BoolVar(&upgradeCmdFlags.skipPostUpgradeVerify, "skip-post-upgrade-verify", false,
111122
"skip the post-upgrade check that compares running Talos version against the target image's tag (detects silent A/B rollback after the RPC acks success)")
112123

0 commit comments

Comments
 (0)