GetAllAPIs returns a list of metadata, in the form of schema.APIResponse, about all the created traffic splitter APIs
(virtualServices []istioclientnetworking.VirtualService)
| 133 | |
| 134 | // GetAllAPIs returns a list of metadata, in the form of schema.APIResponse, about all the created traffic splitter APIs |
| 135 | func 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 |
| 164 | func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) { |
no test coverage detected