(cfg interface{})
| 156 | } |
| 157 | |
| 158 | func countFields(cfg interface{}) (fields int) { |
| 159 | rField := reflect.ValueOf(cfg) |
| 160 | if rField.Kind() == reflect.Ptr { |
| 161 | rField = rField.Elem() |
| 162 | } |
| 163 | if rField.Kind() != reflect.Struct { |
| 164 | return 1 |
| 165 | } |
| 166 | for i := 0; i < rField.NumField(); i++ { |
| 167 | jsonTag := reflect.TypeOf(rField.Interface()).Field(i).Tag.Get("json") |
| 168 | if !strings.HasPrefix(jsonTag, "-") { // could be -,omitempty therefore prefix check |
| 169 | fields += countFields(rField.Field(i).Interface()) |
| 170 | } |
| 171 | } |
| 172 | return fields |
| 173 | } |
| 174 | |
| 175 | // TestDisabledFlagsErrorAndDoNotMutateConfig ensures disabled flags error and values are not wired into StartupConfig. |
| 176 | func TestDisabledFlagsErrorAndDoNotMutateConfig(t *testing.T) { |
no test coverage detected