On Wed, Oct 12, 2016 at 4:04 PM, Dan Mace <dm...@redhat.com> wrote:
> Try instantiating a client like this:
>
> import "github.com/openshift/origin/pkg/cmd/util/clientcmd"
> config, err := clientcmd.DefaultClientConfig(pflag.NewFlagSet("empty",
> pflag.ContinueOnError)).ClientConfig()
> client, err := osclient.New(config)
>
> This method will honor KUBECONFIG if present, and is also capable of
> creating a client using whatever oc client context is currently in use
> within the program’s environment. This is very useful for testing as you can
> `oc login` in the shell, run your program, and your program will use the
> context established by `oc login`.
>
> If your program ever needs to run inside a pod in a container in OpenShift
> connecting via a service account, you can use this to create the client:
>
> import (
>   “k8s.io/kubernetes/pkg/client/restclient"
>   “github.com/openshift/origin/pkg/cmd/util/clientcmd"
> )
> config, err = restclient.InClusterConfig()
> client, err = osclient.New(config)
>
> Hope this helps.


That is great, thank you. It helped a lot.

_______________________________________________
dev mailing list
dev@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/dev

Reply via email to