extractNestedMap walks a path of keys through a nested map structure and returns the map at that path. Returns nil, false if any key is missing or if any intermediate value is not a map.
(m map[string]interface{}, path ...string)
| 47 | // returns the map at that path. Returns nil, false if any key is missing or |
| 48 | // if any intermediate value is not a map. |
| 49 | func extractNestedMap(m map[string]interface{}, path ...string) (map[string]interface{}, bool) { |
| 50 | current := m |
| 51 | for _, key := range path { |
| 52 | v, ok := current[key] |
| 53 | if !ok { |
| 54 | return nil, false |
| 55 | } |
| 56 | current, ok = asMap(v) |
| 57 | if !ok { |
| 58 | return nil, false |
| 59 | } |
| 60 | } |
| 61 | return current, true |
| 62 | } |
| 63 | |
| 64 | type migrateConfigCmd struct { |
| 65 | ConfigFile string `arg:"" help:"Path to the 2.x config file"` |
no test coverage detected