Skip to content

Commit

Permalink
Why different 2?
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
  • Loading branch information
kke committed Aug 28, 2024
1 parent b3855d0 commit e2dfc3e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,19 @@ func (h *Host) FlagsChanged() bool {
log.Debugf("%s: no installFlags", h)
return false
}
flags = flags[3:] // discard the first 3 elements
log.Debugf("%s: installFlags: %v", h, flags)

// format the flags the same way as spf13/cobra does in k0s
for _, flag := range flags[3:] {
for _, flag := range flags {
var key string
var value string
match := flagParseRe.FindStringSubmatch(flag)
if len(match) > 1 {
key = match[1]
if len(match) < 2 {
log.Warnf("%s: could not parse flag: %s", h, flag)
continue
}
key = match[1]

if key == "force" || key == "f" {
// --force is stripped by k0s so it does not end up in status.Args
Expand All @@ -622,7 +626,7 @@ func (h *Host) FlagsChanged() bool {

k0sArgs := h.Metadata.K0sStatusArgs
if len(k0sArgs) != len(formattedFlags) {
log.Debugf("%s: installFlags seem to have changed because of different length: %d [%v] vs %d [%v]", h, len(k0sArgs), k0sArgs, len(formattedFlags), formattedFlags)
log.Debugf("%s: installFlags seem to have changed because of different length: %d %v vs %d %v", h, len(k0sArgs), k0sArgs, len(formattedFlags), formattedFlags)
return true
}
sort.Strings(formattedFlags)
Expand Down

0 comments on commit e2dfc3e

Please sign in to comment.