Example of unversioned pkg uses correct Config struct

This commit is contained in:
Aliaksandr Pliutau 2016-08-19 10:57:55 +07:00
parent c5e3b79f32
commit 41ffa9a254

View File

@ -23,32 +23,33 @@ Most consumers should use the Config object to create a Client:
import ( import (
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
) )
[...] [...]
config := &client.Config{ config := &restclient.Config{
Host: "http://localhost:8080", Host: "http://localhost:8080",
Username: "test", Username: "test",
Password: "password", Password: "password",
} }
client, err := client.New(config) c, err := client.New(config)
if err != nil { if err != nil {
// handle error // handle error
} }
pods, err := client.Pods(api.NamespaceDefault).List(api.ListOptions{}) pods, err := c.Pods(api.NamespaceDefault).List(api.ListOptions{})
if err != nil { if err != nil {
// handle error // handle error
} }
More advanced consumers may wish to provide their own transport via a http.RoundTripper: More advanced consumers may wish to provide their own transport via a http.RoundTripper:
config := &client.Config{ config := &restclient.Config{
Host: "https://localhost:8080", Host: "https://localhost:8080",
Transport: oauthclient.Transport(), Transport: oauthclient.Transport(),
} }
client, err := client.New(config) c, err := client.New(config)
The RESTClient type implements the Kubernetes API conventions (see `docs/devel/api-conventions.md`) The RESTClient type implements the Kubernetes API conventions (see `docs/devel/api-conventions.md`)
for a given API path and is intended for use by consumers implementing their own Kubernetes for a given API path and is intended for use by consumers implementing their own Kubernetes