Skip to content

Commit

Permalink
core: make rook version more readable
Browse files Browse the repository at this point in the history
during pre-validation check, rook version was
printed in multiple lines with golang version
which was making it difficult to read. Now, it
prints in one single like with the golang version.

Signed-off-by: subhamkrai <srai@redhat.com>
  • Loading branch information
subhamkrai committed Jun 14, 2023
1 parent f8e0464 commit d696d1f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package command
import (
"context"
"fmt"
"regexp"
"strings"

"github.com/rook/kubectl-rook-ceph/pkg/exec"
Expand Down Expand Up @@ -106,7 +107,11 @@ func PreValidationCheck(ctx context.Context, k8sclientset *k8sutil.Clientsets, o
}

rookVersion := exec.RunCommandInOperatorPod(ctx, k8sclientset, "rook", []string{"version"}, operatorNamespace, cephClusterNamespace, true, false)
re := regexp.MustCompile("(?m)[\r\n]+^.*go: go.*$") // remove the go version from the output
rookVersion = re.ReplaceAllString(rookVersion, "")
rookVersion = strings.TrimSpace(rookVersion) // remove any trailing newlines
if strings.Contains(rookVersion, "alpha") || strings.Contains(rookVersion, "beta") {
logging.Warning("rook version '%s' is running a pre-release version of Rook.", rookVersion)
fmt.Println()
}
}

0 comments on commit d696d1f

Please sign in to comment.