mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-14 21:27:11 +00:00
* 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
20 lines
433 B
Go
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
|
|
}
|