MCPcopy Create free account
hub / github.com/VersusControl/devops-ai-guidelines / New

Function New

02-mcp-for-devops/code/07/pkg/crd/dynamic.go:29–40  ·  view source on GitHub ↗

New constructs a Client from a rest.Config.

(cfg *rest.Config)

Source from the content-addressed store, hash-verified

27
28// New constructs a Client from a rest.Config.
29func New(cfg *rest.Config) (*Client, error) {
30 dyn, err := dynamic.NewForConfig(cfg)
31 if err != nil {
32 return nil, fmt.Errorf("dynamic client: %w", err)
33 }
34 disc, err := discovery.NewDiscoveryClientForConfig(cfg)
35 if err != nil {
36 return nil, fmt.Errorf("discovery client: %w", err)
37 }
38 mapper := restmapper.NewDeferredDiscoveryRESTMapper(memory.NewMemCacheClient(disc))
39 return &Client{dyn: dyn, mapper: mapper}, nil
40}
41
42// List returns the items of a Kind+Group, optionally scoped to a namespace.
43func (c *Client) List(ctx context.Context, group, kind, namespace string) ([]unstructured.Unstructured, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected