(deployments []kapps.Deployment)
| 177 | } |
| 178 | |
| 179 | func GetAllAPIs(deployments []kapps.Deployment) ([]schema.APIResponse, error) { |
| 180 | realtimeAPIs := make([]schema.APIResponse, len(deployments)) |
| 181 | mappedRealtimeAPIs := make(map[string]schema.APIResponse, len(deployments)) |
| 182 | apiNames := make([]string, len(deployments)) |
| 183 | |
| 184 | for i := range deployments { |
| 185 | apiName := deployments[i].Labels["apiName"] |
| 186 | apiNames[i] = apiName |
| 187 | |
| 188 | metadata, err := spec.MetadataFromDeployment(&deployments[i]) |
| 189 | if err != nil { |
| 190 | return nil, errors.Wrap(err, fmt.Sprintf("api %s", apiName)) |
| 191 | } |
| 192 | mappedRealtimeAPIs[apiName] = schema.APIResponse{ |
| 193 | Status: status.FromDeployment(&deployments[i]), |
| 194 | Metadata: metadata, |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | sort.Strings(apiNames) |
| 199 | for i := range apiNames { |
| 200 | realtimeAPIs[i] = mappedRealtimeAPIs[apiNames[i]] |
| 201 | } |
| 202 | |
| 203 | return realtimeAPIs, nil |
| 204 | } |
| 205 | |
| 206 | func GetAPIByName(deployedResource *operator.DeployedResource) ([]schema.APIResponse, error) { |
| 207 | deployment, err := config.K8s.GetDeployment(workloads.K8sName(deployedResource.Name)) |
no test coverage detected