Skip to content

Commit

Permalink
Name flag is mandatory for minder provider update.
Browse files Browse the repository at this point in the history
The command minder provider update operates on a per-provider basis,
which requires the name to be mandatory.
  • Loading branch information
blkt committed Jun 20, 2024
1 parent 7e374e9 commit 103448c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmd/cli/app/provider/provider_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -129,14 +130,14 @@ func UpdateProviderCommand(
providerName := viper.GetString("name")
if providerName == "" {
return cli.MessageAndError(
"missing mandatory flag",
"invalid option",
errMissingProviderName,
)
}
project := viper.GetString("project")
if project == "" {
return cli.MessageAndError(
"missing mandatory flag",
"invalid option",
errMissingProject,
)
}
Expand All @@ -156,6 +157,12 @@ func UpdateProviderCommand(
if err != nil {
return cli.MessageAndError("Failed to get provider", err)
}
if resp.GetProvider() == nil {
return cli.MessageAndError(
"could not retrieve provider",
errors.New("provider was empty"),
)
}

provider := resp.GetProvider()
bytes, err := provider.GetConfig().MarshalJSON()
Expand Down Expand Up @@ -353,7 +360,7 @@ func recurConfigAttribute(
}
v, err := parserFunc(*attrValue)
if err != nil {
return fmt.Errorf("expected bool, got %s", *attrValue)
return fmt.Errorf("expected %s, got %s", config.Kind(), *attrValue)
}
config.Set(*v)
} else {
Expand Down Expand Up @@ -504,6 +511,10 @@ func init() {
)
updateCmd.Flags().StringSliceP(
"unset-attribute", "u", []string{},
"List of attributes to unset in the config in <name>=<value> format",
"List of attributes to unset in the config in <name> format",
)
if err := updateCmd.MarkFlagRequired("name"); err != nil {
updateCmd.Printf("Error marking flag required: %s", err)
os.Exit(1)
}
}

0 comments on commit 103448c

Please sign in to comment.