mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
pkg/client/doc.go: update example to make it compile
The client example does not compile (double pointer to config, missing import, List() returning two values); fix it.
This commit is contained in:
parent
8cbe9c997a
commit
fbbc49df30
@ -22,20 +22,27 @@ and deleting pods, replication controllers, services, and minions.
|
|||||||
Most consumers should use the Config object to create a Client:
|
Most consumers should use the Config object to create a Client:
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
config := &client.Config{
|
config := &client.Config{
|
||||||
Host: "http://localhost:8080",
|
Host: "http://localhost:8080",
|
||||||
Username: "test",
|
Username: "test",
|
||||||
Password: "password",
|
Password: "password",
|
||||||
}
|
}
|
||||||
client, err := client.New(&config)
|
client, err := client.New(config)
|
||||||
|
if err != nil {
|
||||||
|
// handle error
|
||||||
|
}
|
||||||
|
pods, err := client.Pods(api.NamespaceDefault).List(labels.Everything(), fields.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// handle error
|
// handle error
|
||||||
}
|
}
|
||||||
client.Pods(api.NamespaceDefault).List(labels.Everything(), fields.Everything())
|
|
||||||
|
|
||||||
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:
|
||||||
|
|
||||||
@ -43,7 +50,7 @@ More advanced consumers may wish to provide their own transport via a http.Round
|
|||||||
Host: "https://localhost:8080",
|
Host: "https://localhost:8080",
|
||||||
Transport: oauthclient.Transport(),
|
Transport: oauthclient.Transport(),
|
||||||
}
|
}
|
||||||
client, err := client.New(&config)
|
client, err := client.New(config)
|
||||||
|
|
||||||
The RESTClient type implements the Kubernetes API conventions (see `docs/api-conventions.md`)
|
The RESTClient type implements the Kubernetes API conventions (see `docs/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
|
||||||
|
Loading…
Reference in New Issue
Block a user