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

Function GetAllAPIs

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

GetAllAPIs returns a list of metadata, in the form of schema.APIResponse, about all the created traffic splitter APIs

(virtualServices []istioclientnetworking.VirtualService)

Source from the content-addressed store, hash-verified

133
134// GetAllAPIs returns a list of metadata, in the form of schema.APIResponse, about all the created traffic splitter APIs
135func GetAllAPIs(virtualServices []istioclientnetworking.VirtualService) ([]schema.APIResponse, error) {
136 var trafficSplitters []schema.APIResponse
137 for i := range virtualServices {
138 apiName := virtualServices[i].Labels["apiName"]
139
140 metadata, err := spec.MetadataFromVirtualService(&virtualServices[i])
141 if err != nil {
142 return nil, errors.Wrap(err, fmt.Sprintf("api %s", apiName))
143 }
144
145 if metadata.Kind != userconfig.TrafficSplitterKind {
146 continue
147 }
148
149 targets, err := userconfig.TrafficSplitterTargetsFromAnnotations(&virtualServices[i])
150 if err != nil {
151 return nil, errors.Wrap(err, fmt.Sprintf("api %s", apiName))
152 }
153
154 trafficSplitters = append(trafficSplitters, schema.APIResponse{
155 Metadata: metadata,
156 NumTrafficSplitterTargets: pointer.Int32(targets),
157 })
158 }
159
160 return trafficSplitters, nil
161}
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) {

Callers 1

GetAPIsFunction · 0.92

Calls 4

WrapFunction · 0.92
Int32Function · 0.92

Tested by

no test coverage detected