Skip to content

Commit

Permalink
Merge pull request #97 from venkataanil/fix_ocm_options
Browse files Browse the repository at this point in the history
fix broken cli option
  • Loading branch information
venkataanil authored Dec 7, 2022
2 parents d59fe06 + 0ca40dd commit 0806969
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/ocm-load-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func run(cmd *cobra.Command, args []string) error {
os.Exit(1)
}

if viper.Sub("ocm") == nil {
logger.Fatal(cmd.Context(), "ocm is a necessary configuration")
if viper.Sub("ocm") == nil && viper.GetString("ocm-token") == "" {
logger.Fatal(cmd.Context(), "ocm section or ocm-token is necessary configuration")
}
err = helpers.CreateFolder(cmd.Context(), viper.GetString("output-path"), logger)
if err != nil {
Expand Down
13 changes: 12 additions & 1 deletion pkg/ocm/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ func BuildConnection(gateway, clientID, clientSecret, token string, logger loggi

func BuildConnections(ctx context.Context, logger logging.Logger) ([]*sdk.Connection, error) {
connections := make([]*sdk.Connection, 0)
auths := viper.GetStringMap("ocm")["auths"].([]interface{})

var auths []interface{}
if viper.Sub("ocm") != nil {
auths = viper.GetStringMap("ocm")["auths"].([]interface{})
} else if viper.GetString("ocm-token") != "" {
auth := map[string]interface{}{
"token": viper.GetString("ocm-token"),
"client-id": viper.GetString("client.id"),
"client-secret": viper.GetString("client.secret"),
}
auths = append(auths, auth)
}
for _, a := range auths {
m := a.(map[string]interface{})
token, ok := m["token"]
Expand Down

0 comments on commit 0806969

Please sign in to comment.