Skip to content

Commit

Permalink
fix:remove requirement for server config on package create commands (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 authored Feb 12, 2024
1 parent 408f193 commit f755841
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/octopus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
_ "embed"
"fmt"
"github.com/OctopusDeploy/cli/pkg/util"
"os"
"strings"
"time"
Expand Down Expand Up @@ -35,10 +36,6 @@ func main() {
os.Exit(3)
}
arg := os.Args[1:]
cmdToRun := ""
if len(arg) > 0 {
cmdToRun = arg[0]
}

// initialize our wrapper around survey, which is also used as a flag for whether
// we are in interactive mode or automation mode
Expand All @@ -54,7 +51,7 @@ func main() {
clientFactory, err := apiclient.NewClientFactoryFromConfig(askProvider)
if err != nil {
// a small subset of commands can function even if the app doesn't have valid configuration information
if cmdToRun == "config" || cmdToRun == "version" || cmdToRun == "help" || cmdToRun == "login" || cmdToRun == "logout" {
if commandDoesNotRequireClient(arg) {
clientFactory = apiclient.NewStubClientFactory()
} else {
// can't possibly work
Expand Down Expand Up @@ -87,3 +84,8 @@ func main() {
os.Exit(1)
}
}

func commandDoesNotRequireClient(args []string) bool {
cmdToRun := args[0]
return cmdToRun == "config" || cmdToRun == "version" || cmdToRun == "help" || cmdToRun == "login" || cmdToRun == "logout" || (cmdToRun == "package" && util.SliceContains(args, "create"))
}

0 comments on commit f755841

Please sign in to comment.