MCPcopy Index your code
hub / github.com/helm/helm / getDynamicClientOnKind

Function getDynamicClientOnKind

pkg/engine/lookup_func.go:97–120  ·  view source on GitHub ↗

getDynamicClientOnKind returns a dynamic client on an Unstructured type. This client can be further namespaced.

(apiversion string, kind string, config *rest.Config)

Source from the content-addressed store, hash-verified

95
96// getDynamicClientOnKind returns a dynamic client on an Unstructured type. This client can be further namespaced.
97func getDynamicClientOnKind(apiversion string, kind string, config *rest.Config) (dynamic.NamespaceableResourceInterface, bool, error) {
98 gvk := schema.FromAPIVersionAndKind(apiversion, kind)
99 apiRes, err := getAPIResourceForGVK(gvk, config)
100 if err != nil {
101 slog.Error(
102 "unable to get apiresource",
103 slog.String("groupVersionKind", gvk.String()),
104 slog.Any("error", err),
105 )
106 return nil, false, fmt.Errorf("unable to get apiresource from unstructured: %s: %w", gvk.String(), err)
107 }
108 gvr := schema.GroupVersionResource{
109 Group: apiRes.Group,
110 Version: apiRes.Version,
111 Resource: apiRes.Name,
112 }
113 intf, err := dynamic.NewForConfig(config)
114 if err != nil {
115 slog.Error("unable to get dynamic client", slog.Any("error", err))
116 return nil, false, err
117 }
118 res := intf.Resource(gvr)
119 return res, apiRes.Namespaced, nil
120}
121
122func getAPIResourceForGVK(gvk schema.GroupVersionKind, config *rest.Config) (metav1.APIResource, error) {
123 res := metav1.APIResource{}

Callers 1

GetClientForMethod · 0.85

Calls 3

getAPIResourceForGVKFunction · 0.85
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…