Skip to content

Commit

Permalink
chore: fix CLI docs generation stability
Browse files Browse the repository at this point in the history
The problem first spotted by Artem, leads to spurious dirty checks.

The sort order was checking wrong (lowered) keys, so the order was
actually random.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Jul 5, 2023
1 parent 2fec838 commit a4289e8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/talosctl/cmd/talos/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/peer"
Expand Down Expand Up @@ -146,11 +147,13 @@ func upgradeGetActorID(ctx context.Context, c *client.Client, opts []client.Upgr
}

func init() {
rebootModes := maps.KeysFunc(machine.UpgradeRequest_RebootMode_value, strings.ToLower)
rebootModes := maps.Keys(machine.UpgradeRequest_RebootMode_value)
sort.Slice(rebootModes, func(i, j int) bool {
return machine.UpgradeRequest_RebootMode_value[rebootModes[i]] > machine.UpgradeRequest_RebootMode_value[rebootModes[j]]
return machine.UpgradeRequest_RebootMode_value[rebootModes[i]] < machine.UpgradeRequest_RebootMode_value[rebootModes[j]]
})

rebootModes = slices.Map(rebootModes, strings.ToLower)

upgradeCmd.Flags().StringVarP(&upgradeCmdFlags.upgradeImage, "image", "i",
fmt.Sprintf("%s/%s/installer:%s", images.Registry, images.Username, version.Trim(version.Tag)),
"the container image to use for performing the install")
Expand Down

0 comments on commit a4289e8

Please sign in to comment.