Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Option --url is not mandatory #62

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions cmd/uhc/login/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ var Cmd = &cobra.Command{
}

func init() {
var err error

flags := Cmd.Flags()
flags.StringVar(
&args.tokenURL,
Expand Down Expand Up @@ -110,11 +108,6 @@ func init() {
client.DefaultURL,
"URL of the API gateway.",
)
err = Cmd.MarkFlagRequired("url")
if err != nil {
fmt.Fprintf(os.Stderr, "Can't mark flag as required: %v\n", err)
os.Exit(1)
}
flags.StringVar(
&args.token,
"token",
Expand Down Expand Up @@ -154,6 +147,11 @@ func init() {
func run(cmd *cobra.Command, argv []string) error {
var err error

// Check mandatory options:
if args.url == "" {
return fmt.Errorf("Option '--url' is mandatory")
}

// Check that we have some kind of credentials:
havePassword := args.user != "" && args.password != ""
haveSecret := args.clientID != "" && args.clientSecret != ""
Expand Down