(d map[string]interface{})
| 150 | } |
| 151 | |
| 152 | func (t *cmdAdmin) dumpConfigV3(d map[string]interface{}) { |
| 153 | store := t.newTopomStore(d) |
| 154 | defer store.Close() |
| 155 | |
| 156 | group, err := store.ListGroup() |
| 157 | if err != nil { |
| 158 | log.PanicErrorf(err, "list group failed") |
| 159 | } |
| 160 | proxy, err := store.ListProxy() |
| 161 | if err != nil { |
| 162 | log.PanicErrorf(err, "list proxy failed") |
| 163 | } |
| 164 | |
| 165 | if len(group) == 0 && len(proxy) == 0 { |
| 166 | log.Panicf("cann't find product = %s [v3]", t.product) |
| 167 | } |
| 168 | |
| 169 | slots, err := store.SlotMappings() |
| 170 | if err != nil { |
| 171 | log.PanicErrorf(err, "list slots failed") |
| 172 | } |
| 173 | |
| 174 | config := &ConfigV3{ |
| 175 | Slots: slots, |
| 176 | Group: models.SortGroup(group), |
| 177 | Proxy: models.SortProxy(proxy), |
| 178 | } |
| 179 | |
| 180 | b, err := json.MarshalIndent(config, "", " ") |
| 181 | if err != nil { |
| 182 | log.PanicErrorf(err, "json marshal failed") |
| 183 | } |
| 184 | fmt.Println(string(b)) |
| 185 | } |
| 186 | |
| 187 | func (t *cmdAdmin) loadJsonConfigV1(file string) map[string]interface{} { |
| 188 | b, err := ioutil.ReadFile(file) |
no test coverage detected