Files
polaris/pkg/config/ids.go
Robert Brennan 2b15f11d57 Add exemptions to config (#204)
* first pass at adding exemptions

* Update config.yaml

* make config_test more reliable

* add flag to disallow exemptions in dashboard

* add disallow-exemptions flag to CLI

* add comments

* fix exemptions flag

* fix alert on dashboard

* minor style changes
2019-10-23 17:14:03 -04:00

20 lines
433 B
Go

package config
import (
"reflect"
)
// GetIDFromField returns the JSON key associated with a particular field, which serves as the check ID.
func GetIDFromField(config interface{}, name string) string {
t := reflect.TypeOf(config)
field, ok := t.FieldByName(name)
if !ok {
panic("No JSON annotation for field " + name)
}
id, ok := field.Tag.Lookup("json")
if !ok {
panic("No JSON tag for field " + name)
}
return id
}