MCPcopy
hub / github.com/kubernetes-sigs/controller-runtime / NewDynamicRESTMapper

Function NewDynamicRESTMapper

pkg/client/apiutil/restmapper.go:35–51  ·  view source on GitHub ↗

NewDynamicRESTMapper returns a dynamic RESTMapper for cfg. The dynamic RESTMapper dynamically discovers resource types at runtime.

(cfg *rest.Config, httpClient *http.Client)

Source from the content-addressed store, hash-verified

33// NewDynamicRESTMapper returns a dynamic RESTMapper for cfg. The dynamic
34// RESTMapper dynamically discovers resource types at runtime.
35func NewDynamicRESTMapper(cfg *rest.Config, httpClient *http.Client) (meta.RESTMapper, error) {
36 if httpClient == nil {
37 return nil, fmt.Errorf("httpClient must not be nil, consider using rest.HTTPClientFor(c) to create a client")
38 }
39
40 client, err := discovery.NewDiscoveryClientForConfigAndClient(cfg, httpClient)
41 if err != nil {
42 return nil, err
43 }
44
45 return &mapper{
46 mapper: restmapper.NewDiscoveryRESTMapper([]*restmapper.APIGroupResources{}),
47 client: client,
48 knownGroups: map[string]*restmapper.APIGroupResources{},
49 apiGroups: map[string]*metav1.APIGroup{},
50 }, nil
51}
52
53// mapper is a RESTMapper that will lazily query the provided
54// client for discovery information to do REST mappings.

Callers 6

defaultOptsFunction · 0.92
newClientFunction · 0.92
TestApiMachineryFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestApiMachineryFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…