mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Example of unversioned pkg uses correct Config struct
This commit is contained in:
parent
c5e3b79f32
commit
41ffa9a254
@ -23,32 +23,33 @@ Most consumers should use the Config object to create a Client:
|
||||
|
||||
import (
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
"k8s.io/kubernetes/pkg/client/restclient"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
[...]
|
||||
|
||||
config := &client.Config{
|
||||
config := &restclient.Config{
|
||||
Host: "http://localhost:8080",
|
||||
Username: "test",
|
||||
Password: "password",
|
||||
}
|
||||
client, err := client.New(config)
|
||||
c, err := client.New(config)
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
pods, err := client.Pods(api.NamespaceDefault).List(api.ListOptions{})
|
||||
pods, err := c.Pods(api.NamespaceDefault).List(api.ListOptions{})
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
More advanced consumers may wish to provide their own transport via a http.RoundTripper:
|
||||
|
||||
config := &client.Config{
|
||||
config := &restclient.Config{
|
||||
Host: "https://localhost:8080",
|
||||
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`)
|
||||
for a given API path and is intended for use by consumers implementing their own Kubernetes
|
||||
|
Loading…
Reference in New Issue
Block a user