GetStringMapString returns a config value as a string to string map.
(ns, key string)
| 457 | |
| 458 | // GetStringMapString returns a config value as a string to string map. |
| 459 | func (c *LiveConfig) GetStringMapString(ns, key string) (map[string]string, error) { |
| 460 | nskey := nskey(ns, key) |
| 461 | |
| 462 | if isRequired(nskey) && !c.IsSet(key) { |
| 463 | return nil, NewMissingArgsErr(nskey) |
| 464 | } |
| 465 | |
| 466 | // We cannot call viper.GetStringMapString because it does not handle |
| 467 | // pflag's StringToStringP properly: |
| 468 | // https://github.com/spf13/viper/issues/608 |
| 469 | // Re-implement the necessary pieces on our own instead. |
| 470 | |
| 471 | vals := map[string]string{} |
| 472 | items := viper.GetStringSlice(nskey) |
| 473 | for _, item := range items { |
| 474 | parts := strings.SplitN(item, "=", 2) |
| 475 | if len(parts) < 2 { |
| 476 | return nil, fmt.Errorf("item %q does not adhere to form: key=value", item) |
| 477 | } |
| 478 | labelKey := parts[0] |
| 479 | labelValue := parts[1] |
| 480 | vals[labelKey] = labelValue |
| 481 | } |
| 482 | |
| 483 | return vals, nil |
| 484 | } |
| 485 | |
| 486 | // GetDuration returns a config value as a duration. |
| 487 | func (c *LiveConfig) GetDuration(ns, key string) (time.Duration, error) { |
nothing calls this directly
no test coverage detected