Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update external data key to be string #147

Merged
merged 2 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
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
14 changes: 0 additions & 14 deletions constraint/pkg/client/drivers/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,6 @@ func (d *driver) Init(ctx context.Context) error {
if err := ast.As(regorequest.Value, &regoReq); err != nil {
return nil, err
}
// only primitive types are allowed for keys
for _, key := range regoReq.Keys {
switch v := key.(type) {
case int:
case int32:
case int64:
case string:
case float64:
case float32:
break
default:
return externaldata.HandleError(http.StatusBadRequest, fmt.Errorf("type %v is not supported in external_data", v))
}
}

provider, err := d.providerCache.Get(regoReq.ProviderName)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions constraint/pkg/externaldata/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type RegoRequest struct {
// ProviderName is the name of the external data provider.
ProviderName string `json:"provider"`
// Keys is the list of keys to send to the external data provider.
Keys []interface{} `json:"keys"`
Keys []string `json:"keys"`
}

// ProviderRequest is the API request for the external data provider.
Expand All @@ -21,11 +21,11 @@ type ProviderRequest struct {
// Request is the struct that contains the keys to query.
type Request struct {
// Keys is the list of keys to send to the external data provider.
Keys []interface{} `json:"keys,omitempty"`
Keys []string `json:"keys,omitempty"`
}

// NewRequest creates a new request for the external data provider.
func NewProviderRequest(keys []interface{}) *ProviderRequest {
func NewProviderRequest(keys []string) *ProviderRequest {
return &ProviderRequest{
APIVersion: "externaldata.gatekeeper.sh/v1alpha1",
Kind: "ProviderRequest",
Expand Down
2 changes: 1 addition & 1 deletion constraint/pkg/externaldata/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Response struct {
// Items is the struct that contains the key, value or error from a provider response.
type Item struct {
// Key is the request from the provider.
Key interface{} `json:"key,omitempty"`
Key string `json:"key,omitempty"`
// Value is the response from the provider.
Value interface{} `json:"value,omitempty"`
// Error is the error from the provider.
Expand Down