//GetDefinitionList returns a list of backend definitions func (BackendDef) GetDefinitionList(kvs kvstore.KVStore, resp http.ResponseWriter, req *http.Request) (interface{}, error) { log.Info("backend GetDefinitionList service called") backends, err := config.ListBackendConfigs(kvs) if err != nil { resp.WriteHeader(http.StatusInternalServerError) return nil, err } if backends == nil { backends = make([]*config.BackendConfig, 0) } return backends, nil }
//Run executes the BackendList command with the supplied args func (sl *BackendList) Run(args []string) int { backends, err := config.ListBackendConfigs(sl.KVStore) if err != nil { sl.UI.Error(err.Error()) return 1 } jsonRep, err := json.Marshal(backends) if err != nil { sl.UI.Error(err.Error()) return 1 } if bytes.Equal(jsonRep, config.NullJSON) { sl.UI.Output("[]") } else { sl.UI.Output(string(jsonRep)) } return 0 }