Skip to content

Commit

Permalink
use array instead of map for supported resources
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenkndinh authored and saurav-agarwalla committed May 11, 2022
1 parent 151d4f9 commit e48b6a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/controllers/options/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const (
Instance string = "instance"
)

var SupportedResources = map[string]string{
"instance": Instance,
var SupportedResources = []string{
Instance,
}
14 changes: 9 additions & 5 deletions pkg/controllers/options/tagging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ func (o *TaggingControllerOptions) Validate() error {
}

for _, r := range o.Resources {
if _, ok := SupportedResources[r]; !ok {
resources := []string{}
for r, _ := range SupportedResources {
resources = append(resources, r)
found := false

for _, resource := range SupportedResources {
if r == resource {
found = true
}
return fmt.Errorf("%s is not a supported resource. Current supported resources %v", r, resources)
}

if !found {
return fmt.Errorf("%s is not a supported resource. Current supported resources %v", r, SupportedResources)
}
}

Expand Down

0 comments on commit e48b6a2

Please sign in to comment.