package circuitbreaker import ( "forge.cadoles.com/cadoles/bouncer/internal/store" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" ) type LayerOptions struct { MatchURLs []string `mapstructure:"matchURLs"` AuthorizedCIDRs []string `mapstructure:"authorizedCIDRs"` TemplateBlock string `mapstructure:"templateBlock"` } func fromStoreOptions(storeOptions store.LayerOptions) (*LayerOptions, error) { layerOptions := LayerOptions{ MatchURLs: []string{"*"}, AuthorizedCIDRs: []string{}, TemplateBlock: "default", } config := mapstructure.DecoderConfig{ Result: &layerOptions, } decoder, err := mapstructure.NewDecoder(&config) if err != nil { return nil, err } if err := decoder.Decode(storeOptions); err != nil { return nil, errors.WithStack(err) } return &layerOptions, nil }