MCPcopy Create free account
hub / github.com/conforma/cli / NewClient

Function NewClient

internal/kubernetes/client.go:59–74  ·  view source on GitHub ↗

NewClient constructs a new kubernetes with the default "live" client

(ctx context.Context)

Source from the content-addressed store, hash-verified

57
58// NewClient constructs a new kubernetes with the default "live" client
59func NewClient(ctx context.Context) (Client, error) {
60 client, ok := ctx.Value(clientContextKey).(Client)
61 if ok && client != nil {
62 return client, nil
63 }
64
65 c, err := createK8SClient()
66 if err != nil {
67 log.Debug("Failed to create k8s client!")
68 return nil, err
69 }
70
71 return &kubernetesClient{
72 client: c,
73 }, nil
74}
75
76func createK8SClient() (client dynamic.Interface, err error) {
77 rules := clientcmd.NewDefaultClientConfigLoadingRules()

Callers 2

loadPolicyMethod · 0.92
DetermineInputSpecFunction · 0.92

Calls 1

createK8SClientFunction · 0.85

Tested by

no test coverage detected