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

Function GetAllAPIs

pkg/operator/resources/realtimeapi/api.go:179–204  ·  view source on GitHub ↗
(deployments []kapps.Deployment)

Source from the content-addressed store, hash-verified

177}
178
179func GetAllAPIs(deployments []kapps.Deployment) ([]schema.APIResponse, error) {
180 realtimeAPIs := make([]schema.APIResponse, len(deployments))
181 mappedRealtimeAPIs := make(map[string]schema.APIResponse, len(deployments))
182 apiNames := make([]string, len(deployments))
183
184 for i := range deployments {
185 apiName := deployments[i].Labels["apiName"]
186 apiNames[i] = apiName
187
188 metadata, err := spec.MetadataFromDeployment(&deployments[i])
189 if err != nil {
190 return nil, errors.Wrap(err, fmt.Sprintf("api %s", apiName))
191 }
192 mappedRealtimeAPIs[apiName] = schema.APIResponse{
193 Status: status.FromDeployment(&deployments[i]),
194 Metadata: metadata,
195 }
196 }
197
198 sort.Strings(apiNames)
199 for i := range apiNames {
200 realtimeAPIs[i] = mappedRealtimeAPIs[apiNames[i]]
201 }
202
203 return realtimeAPIs, nil
204}
205
206func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
207 deployment, 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