MCPcopy
hub / github.com/cortexlabs/cortex / getAPIsInAllEnvironments

Function getAPIsInAllEnvironments

cli/cmd/get.go:186–335  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184}
185
186func getAPIsInAllEnvironments() (string, error) {
187 cliConfig, err := readCLIConfig()
188 if err != nil {
189 return "", err
190 }
191
192 var allRealtimeAPIs []schema.APIResponse
193 var allRealtimeAPIEnvs []string
194 var allAsyncAPIs []schema.APIResponse
195 var allAsyncAPIEnvs []string
196 var allBatchAPIs []schema.APIResponse
197 var allBatchAPIEnvs []string
198 var allTaskAPIs []schema.APIResponse
199 var allTaskAPIEnvs []string
200 var allTrafficSplitters []schema.APIResponse
201 var allTrafficSplitterEnvs []string
202
203 type getAPIsOutput struct {
204 EnvName string `json:"env_name"`
205 APIs []schema.APIResponse `json:"apis"`
206 Error string `json:"error"`
207 }
208
209 allAPIsOutput := []getAPIsOutput{}
210
211 errorsMap := map[string]error{}
212 // get apis from both environments
213 for _, env := range cliConfig.Environments {
214 apisRes, err := cluster.GetAPIs(MustGetOperatorConfig(env.Name))
215
216 apisOutput := getAPIsOutput{
217 EnvName: env.Name,
218 APIs: apisRes,
219 }
220
221 if err == nil {
222 for _, api := range apisRes {
223 switch api.Metadata.Kind {
224 case userconfig.BatchAPIKind:
225 allBatchAPIEnvs = append(allBatchAPIEnvs, env.Name)
226 allBatchAPIs = append(allBatchAPIs, api)
227 case userconfig.RealtimeAPIKind:
228 allRealtimeAPIEnvs = append(allRealtimeAPIEnvs, env.Name)
229 allRealtimeAPIs = append(allRealtimeAPIs, api)
230 case userconfig.AsyncAPIKind:
231 allAsyncAPIEnvs = append(allAsyncAPIEnvs, env.Name)
232 allAsyncAPIs = append(allAsyncAPIs, api)
233 case userconfig.TaskAPIKind:
234 allTaskAPIEnvs = append(allTaskAPIEnvs, env.Name)
235 allTaskAPIs = append(allTaskAPIs, api)
236 case userconfig.TrafficSplitterKind:
237 allTrafficSplitterEnvs = append(allTrafficSplitterEnvs, env.Name)
238 allTrafficSplitters = append(allTrafficSplitters, api)
239 }
240 }
241 } else {
242 apisOutput.Error = err.Error()
243 errorsMap[env.Name] = err

Callers 1

get.goFile · 0.85

Calls 15

GetAPIsFunction · 0.92
BoldFunction · 0.92
ErrorFunction · 0.92
WrapFunction · 0.92
FirstKeyInErrorMapFunction · 0.92
NonNilErrorMapKeysFunction · 0.92
readCLIConfigFunction · 0.85
MustGetOperatorConfigFunction · 0.85
batchAPIsTableFunction · 0.85
taskAPIsTableFunction · 0.85
realtimeAPIsTableFunction · 0.85
asyncAPIsTableFunction · 0.85

Tested by

no test coverage detected