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

Function GetAPIByName

pkg/operator/resources/trafficsplitter/api.go:164–187  ·  view source on GitHub ↗

GetAPIByName retrieves the metadata, in the form of schema.APIResponse, of a single traffic splitter API

(deployedResource *operator.DeployedResource)

Source from the content-addressed store, hash-verified

162
163// GetAPIByName retrieves the metadata, in the form of schema.APIResponse, of a single traffic splitter API
164func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) {
165 metadata, err := spec.MetadataFromVirtualService(deployedResource.VirtualService)
166 if err != nil {
167 return nil, err
168 }
169
170 api, err := operator.DownloadAPISpec(deployedResource.Name, metadata.APIID)
171 if err != nil {
172 return nil, err
173 }
174
175 endpoint, err := operator.APIEndpoint(api)
176 if err != nil {
177 return nil, err
178 }
179
180 return []schema.APIResponse{
181 {
182 Spec: api,
183 Metadata: metadata,
184 Endpoint: &endpoint,
185 },
186 }, nil
187}
188
189func deleteK8sResources(apiName string) error {
190 _, err := config.K8s.DeleteVirtualService(workloads.K8sName(apiName))

Callers 1

GetAPIFunction · 0.92

Calls 3

DownloadAPISpecFunction · 0.92
APIEndpointFunction · 0.92

Tested by

no test coverage detected