Skip to content

Commit

Permalink
Merge pull request #86 from vkareh/SDA-2787/no-error-on-verify-oc
Browse files Browse the repository at this point in the history
verify-oc: Do not error out on invalid version
  • Loading branch information
vkareh authored Aug 26, 2020
2 parents 03c3f28 + d3af2c3 commit aa7933c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cmd/verify/oc/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package oc

import (
"fmt"
"os"
"os/exec"
"regexp"
"strings"
Expand Down Expand Up @@ -49,22 +48,22 @@ func run(_ *cobra.Command, _ []string) {
if err != nil {
reporter.Errorf("OpenShift command-line tool is not installed.\n"+
"Go to %s to download the OpenShift client and add it to your PATH.", ocDownloadURL)
os.Exit(1)
return
}

// Parse the version for the OpenShift Client
version := strings.Replace(strings.Split(string(output), "\n")[0], "\n", "", 1)
isCorrectVersion, err := regexp.Match(`\W4.\d*`, output)
if err != nil {
reporter.Errorf("Failed to parse OpenShift Client version: %v", err)
os.Exit(1)
return
}

if !isCorrectVersion {
reporter.Warnf("Current OpenShift %s", version)
reporter.Warnf("Your version of the OpenShift command-line tool is not supported.")
fmt.Printf("Go to %s to download the latest version.\n", ocDownloadURL)
os.Exit(1)
return
}

reporter.Infof("Current OpenShift %s", version)
Expand Down

0 comments on commit aa7933c

Please sign in to comment.