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

Function DescribeAPIByName

pkg/operator/resources/realtimeapi/api.go:245–282  ·  view source on GitHub ↗
(deployedResource *operator.DeployedResource)

Source from the content-addressed store, hash-verified

243}
244
245func DescribeAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
246 deployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name))
247 if err != nil {
248 return nil, err
249 }
250
251 if deployment == nil {
252 return nil, errors.ErrorUnexpected("unable to find deployment", deployedResource.Name)
253 }
254
255 apiStatus := status.FromDeployment(deployment)
256 apiMetadata, err := spec.MetadataFromDeployment(deployment)
257 if err != nil {
258 return nil, errors.ErrorUnexpected("unable to obtain metadata", deployedResource.Name)
259 }
260
261 pods, err := config.K8s.ListPodsByLabel("apiName", deployment.Labels["apiName"])
262 if err != nil {
263 return nil, err
264 }
265 apiStatus.ReplicaCounts = GetReplicaCounts(deployment, pods)
266
267 apiEndpoint, err := operator.APIEndpointFromResource(deployedResource)
268 if err != nil {
269 return nil, err
270 }
271
272 dashboardURL := pointer.String(getDashboardURL(deployedResource.Name))
273
274 return []schema.APIResponse{
275 {
276 Metadata: apiMetadata,
277 Status: apiStatus,
278 Endpoint: &apiEndpoint,
279 DashboardURL: dashboardURL,
280 },
281 }, nil
282}
283
284func getK8sResources(apiName string) (*kapps.Deployment, *kcore.Service, *istioclientnetworking.VirtualService, error) {
285 var deployment *kapps.Deployment

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
ListPodsByLabelMethod · 0.80
GetReplicaCountsFunction · 0.70
getDashboardURLFunction · 0.70

Tested by

no test coverage detected