Skip to content

Commit

Permalink
catch error if type is missing (#1234)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Gouin <andrew@gouin.io>
  • Loading branch information
murataniloener and agouin committed Jul 25, 2023
1 parent 73d338a commit 7ae1596
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package cmd
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -393,7 +394,11 @@ func UnmarshalJSONProviderConfig(data []byte, customTypes map[string]reflect.Typ
return nil, err
}

typeName := m["type"].(string)
typeName, ok := m["type"].(string)
if !ok {
return nil, errors.New("cannot find type");
}

var provCfg provider.ProviderConfig
if ty, found := customTypes[typeName]; found {
provCfg = reflect.New(ty).Interface().(provider.ProviderConfig)
Expand Down

0 comments on commit 7ae1596

Please sign in to comment.