MCPcopy
hub / github.com/kubernetes/client-go / pathAndVersionFor

Method pathAndVersionFor

scale/client.go:80–99  ·  view source on GitHub ↗

pathAndVersionFor returns the appropriate base path and the associated full GroupVersionResource for the given GroupResource

(resource schema.GroupResource)

Source from the content-addressed store, hash-verified

78// pathAndVersionFor returns the appropriate base path and the associated full GroupVersionResource
79// for the given GroupResource
80func (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.

Callers 2

GetMethod · 0.80
UpdateMethod · 0.80

Calls 3

ResourceForMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected