MCPcopy Index your code
hub / github.com/cortexlabs/cortex / DescribeAPIByName

Function DescribeAPIByName

pkg/operator/resources/asyncapi/api.go:312–353  ·  view source on GitHub ↗
(deployedResource *operator.DeployedResource)

Source from the content-addressed store, hash-verified

310}
311
312func DescribeAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
313 var apiDeployment *kapps.Deployment
314
315 apiDeployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))
316 if err != nil {
317 return nil, err
318 }
319
320 if apiDeployment == nil {
321 return nil, errors.ErrorUnexpected("unable to find api deployment", deployedResource.Name)
322 }
323
324 apiStatus := status.FromDeployment(apiDeployment)
325 apiMetadata, err := spec.MetadataFromDeployment(apiDeployment)
326 if err != nil {
327 return nil, errors.ErrorUnexpected("unable to obtain metadata", deployedResource.Name)
328 }
329
330 apiPods, err := config.K8s.ListPodsByLabels(map[string]string{
331 "apiName": apiDeployment.Labels["apiName"],
332 })
333 if err != nil {
334 return nil, err
335 }
336 apiStatus.ReplicaCounts = GetReplicaCounts(apiDeployment, apiPods)
337
338 apiEndpoint, err := operator.APIEndpointFromResource(deployedResource)
339 if err != nil {
340 return nil, err
341 }
342
343 dashboardURL := pointer.String(getDashboardURL(deployedResource.Name))
344
345 return []schema.APIResponse{
346 {
347 Metadata: apiMetadata,
348 Status: apiStatus,
349 Endpoint: &apiEndpoint,
350 DashboardURL: dashboardURL,
351 },
352 }, nil
353}
354
355func UpdateAPIMetricsCron(apiDeployment *kapps.Deployment) error {
356 apiName := apiDeployment.Labels["apiName"]

Callers 1

DescribeAPIFunction · 0.92

Calls 10

K8sNameFunction · 0.92
ErrorUnexpectedFunction · 0.92
FromDeploymentFunction · 0.92
MetadataFromDeploymentFunction · 0.92
APIEndpointFromResourceFunction · 0.92
StringFunction · 0.92
GetDeploymentMethod · 0.80
ListPodsByLabelsMethod · 0.80
GetReplicaCountsFunction · 0.70
getDashboardURLFunction · 0.70

Tested by

no test coverage detected