MCPcopy Create free account
hub / github.com/encoder-run/operator / defaultClient

Function defaultClient

cmd/repositoryembedder/main.go:639–663  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

637}
638
639func defaultClient() (client.Client, error) {
640 config, err := rest.InClusterConfig()
641 if err != nil {
642 // Load kubeconfig from default location or specified path
643 kubeConfigPath := clientcmd.RecommendedHomeFile
644 config, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
645 &clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeConfigPath},
646 &clientcmd.ConfigOverrides{},
647 ).ClientConfig()
648 if err != nil {
649 return nil, errors.Wrap(err, "failed to load in-cluster configuration")
650 }
651 }
652
653 // Create a new scheme and register the API types
654 scheme := newScheme()
655
656 // Create the controller-runtime client using the impersonated rest.Config
657 c, err := client.New(config, client.Options{Scheme: scheme})
658 if err != nil {
659 return nil, fmt.Errorf("failed to create controller-runtime client: %v", err)
660 }
661
662 return c, nil
663}
664
665// CheckArgs should be used to ensure the right command line arguments are
666// passed before executing an example.

Callers 1

mainFunction · 0.85

Calls 1

newSchemeFunction · 0.85

Tested by

no test coverage detected