[zh]: add missing context module for the go example
The client-go example is missing the param context. This patch adds the missing param. Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
This commit is contained in:
parent
eac11ac629
commit
6fb5b93ad7
|
|
@ -280,6 +280,7 @@ Go 客户端可以使用与 kubectl 命令行工具相同的
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"k8s.io/client-go/1.4/kubernetes"
|
"k8s.io/client-go/1.4/kubernetes"
|
||||||
"k8s.io/client-go/1.4/pkg/api/v1"
|
"k8s.io/client-go/1.4/pkg/api/v1"
|
||||||
|
|
@ -293,7 +294,7 @@ func main() {
|
||||||
// creates the clientset
|
// creates the clientset
|
||||||
clientset, _ := kubernetes.NewForConfig(config)
|
clientset, _ := kubernetes.NewForConfig(config)
|
||||||
// access the API to list pods
|
// access the API to list pods
|
||||||
pods, _ := clientset.CoreV1().Pods("").List(v1.ListOptions{})
|
pods, _ := clientset.CoreV1().Pods("").List(context.TODO(), v1.ListOptions{})
|
||||||
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
|
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue