Skip to content

Commit

Permalink
oc: Generate command line in a single runCommand helper
Browse files Browse the repository at this point in the history
Before running oc, we append a few args to its command line. Rather than
duplicating this in oc.Run() and oc.RunPrivate(), these 2 functions can
use a helper doing that.
  • Loading branch information
cfergeau authored and praveenkumar committed Aug 27, 2020
1 parent 60aad3f commit 3efbf66
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pkg/crc/oc/oc.go
Expand Up @@ -49,24 +49,27 @@ func UseOCWithConfig(machineName string) Config {
}
}

func (oc Config) RunOcCommand(args ...string) (string, string, error) {
func (oc Config) runCommand(isPrivate bool, args ...string) (string, string, error) {
if oc.Context != "" {
args = append(args, "--context", oc.Context)
}
if oc.Cluster != "" {
args = append(args, "--cluster", oc.Cluster)
}

if isPrivate {
return oc.Runner.RunPrivate(args...)
}

return oc.Runner.Run(args...)
}

func (oc Config) RunOcCommand(args ...string) (string, string, error) {
return oc.runCommand(false, args...)
}

func (oc Config) RunOcCommandPrivate(args ...string) (string, string, error) {
if oc.Context != "" {
args = append(args, "--context", oc.Context)
}
if oc.Cluster != "" {
args = append(args, "--cluster", oc.Cluster)
}
return oc.Runner.RunPrivate(args...)
return oc.runCommand(true, args...)
}

type SSHRunner struct {
Expand Down

0 comments on commit 3efbf66

Please sign in to comment.