pathAndVersionFor returns the appropriate base path and the associated full GroupVersionResource for the given GroupResource
(resource schema.GroupResource)
| 78 | // pathAndVersionFor returns the appropriate base path and the associated full GroupVersionResource |
| 79 | // for the given GroupResource |
| 80 | func (c *scaleClient) pathAndVersionFor(resource schema.GroupResource) (string, schema.GroupVersionResource, error) { |
| 81 | gvr, err := c.mapper.ResourceFor(resource.WithVersion("")) |
| 82 | if err != nil { |
| 83 | return "", gvr, fmt.Errorf("unable to get full preferred group-version-resource for %s: %v", resource.String(), err) |
| 84 | } |
| 85 | |
| 86 | groupVer := gvr.GroupVersion() |
| 87 | |
| 88 | // we need to set the API path based on GroupVersion (defaulting to the legacy path if none is set) |
| 89 | // TODO: we "cheat" here since the API path really only depends on group ATM, but this should |
| 90 | // *probably* take GroupVersionResource and not GroupVersionKind. |
| 91 | apiPath := c.apiPathResolverFunc(groupVer.WithKind("")) |
| 92 | if apiPath == "" { |
| 93 | apiPath = "/api" |
| 94 | } |
| 95 | |
| 96 | path := restclient.DefaultVersionedAPIPath(apiPath, groupVer) |
| 97 | |
| 98 | return path, gvr, nil |
| 99 | } |
| 100 | |
| 101 | // namespacedScaleClient is an ScaleInterface for fetching |
| 102 | // Scales in a given namespace. |
no test coverage detected