chore: fix CLI docs generation stability

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>
This commit is contained in:
Andrey Smirnov 2023-07-05 19:01:01 +04:00
parent 2fec8388fc
commit a4289e8703
No known key found for this signature in database
GPG Key ID: 7B26396447AB6DFD

View File

@ -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"
@ -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")