Skip to content

Commit

Permalink
verify-oc: Do not error out on invalid version
Browse files Browse the repository at this point in the history
Detecting an invalid or unsupported version of the openshift-clients is
not an error, but the successful output of the 'verify' command. Since
we also call this command from the 'download' command, we need to ensure
that instead of exiting with an error, the command just ends and allows
the rest of 'download' to go through.
  • Loading branch information
vkareh committed Aug 26, 2020
1 parent 03c3f28 commit d3af2c3
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 d3af2c3

Please sign in to comment.