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

Function GetAllAPIs

pkg/operator/resources/asyncapi/api.go:246–271  ·  view source on GitHub ↗
(deployments []kapps.Deployment)

Source from the content-addressed store, hash-verified

244}
245
246func GetAllAPIs(deployments []kapps.Deployment) ([]schema.APIResponse, error) {
247 asyncAPIs := make([]schema.APIResponse, 0)
248 mappedAsyncAPIs := make(map[string]schema.APIResponse, 0)
249 apiNames := make([]string, 0)
250
251 for i := range deployments {
252 apiName := deployments[i].Labels["apiName"]
253 apiNames = append(apiNames, apiName)
254
255 metadata, err := spec.MetadataFromDeployment(&deployments[i])
256 if err != nil {
257 return nil, errors.Wrap(err, fmt.Sprintf("api %s", apiName))
258 }
259 mappedAsyncAPIs[apiName] = schema.APIResponse{
260 Status: status.FromDeployment(&deployments[i]),
261 Metadata: metadata,
262 }
263 }
264
265 sort.Strings(apiNames)
266 for _, apiName := range apiNames {
267 asyncAPIs = append(asyncAPIs, mappedAsyncAPIs[apiName])
268 }
269
270 return asyncAPIs, nil
271}
272
273func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
274 apiDeployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))

Callers 1

GetAPIsFunction · 0.92

Calls 3

MetadataFromDeploymentFunction · 0.92
WrapFunction · 0.92
FromDeploymentFunction · 0.92

Tested by

no test coverage detected