From 6fb5b93ad76a39e562fdb36c0f53bc696999abc4 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 21:00:14 -0400 Subject: [PATCH] [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 --- content/zh/docs/tasks/administer-cluster/access-cluster-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md index 35d7cc2a20..fc25f2645c 100644 --- a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md @@ -280,6 +280,7 @@ Go 客户端可以使用与 kubectl 命令行工具相同的 package main import ( + "context" "fmt" "k8s.io/client-go/1.4/kubernetes" "k8s.io/client-go/1.4/pkg/api/v1" @@ -293,7 +294,7 @@ func main() { // creates the clientset clientset, _ := kubernetes.NewForConfig(config) // 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)) } ```