From ed8ffbda4c012d0bf453f173616cab9939db8f52 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 20:56:13 -0400 Subject: [PATCH 1/7] [en]: Add package main to client-go example The package main is missing from the example. Signed-off-by: Douglas Schilling Landgraf --- content/en/docs/tasks/administer-cluster/access-cluster-api.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/en/docs/tasks/administer-cluster/access-cluster-api.md b/content/en/docs/tasks/administer-cluster/access-cluster-api.md index 5c94dceffc..a99b6fe984 100644 --- a/content/en/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/en/docs/tasks/administer-cluster/access-cluster-api.md @@ -171,6 +171,8 @@ The Go client can use the same [kubeconfig file](/docs/concepts/configuration/or as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go): ```golang +package main + import ( "fmt" "k8s.io/apimachinery/pkg/apis/meta/v1" From d3f537f2c6b7fad27c2cfe3d67646c7366d18291 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 20:57:24 -0400 Subject: [PATCH 2/7] [ko]: Add package main to client-go example The package main is missing from the example. Signed-off-by: Douglas Schilling Landgraf --- content/ko/docs/tasks/administer-cluster/access-cluster-api.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/ko/docs/tasks/administer-cluster/access-cluster-api.md b/content/ko/docs/tasks/administer-cluster/access-cluster-api.md index 1b92c1283a..8ee76377de 100644 --- a/content/ko/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/ko/docs/tasks/administer-cluster/access-cluster-api.md @@ -174,6 +174,8 @@ Go 클라이언트는 kubectl CLI가 API 서버를 찾아 인증하기 위해 사용할 수 있다. 이 [예제](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go)를 참고한다. ```golang +package main + import ( "fmt" "k8s.io/apimachinery/pkg/apis/meta/v1" From ee17ef17a50fa923e34d54e2bd6d01e18b0576de Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 20:58:16 -0400 Subject: [PATCH 3/7] [zh]: Add package main to client-go example The package main is missing from the example. Signed-off-by: Douglas Schilling Landgraf --- content/zh/docs/tasks/administer-cluster/access-cluster-api.md | 2 ++ 1 file changed, 2 insertions(+) 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 1d2bed1a0a..35d7cc2a20 100644 --- a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md @@ -277,6 +277,8 @@ Go 客户端可以使用与 kubectl 命令行工具相同的 [例子](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go): ```golang +package main + import ( "fmt" "k8s.io/client-go/1.4/kubernetes" From bdafcf5aa4d16f1ac745628a355afaeee512fec7 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 20:59:00 -0400 Subject: [PATCH 4/7] [en]: 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/en/docs/tasks/administer-cluster/access-cluster-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/en/docs/tasks/administer-cluster/access-cluster-api.md b/content/en/docs/tasks/administer-cluster/access-cluster-api.md index a99b6fe984..d09a29c671 100644 --- a/content/en/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/en/docs/tasks/administer-cluster/access-cluster-api.md @@ -174,6 +174,7 @@ as the kubectl CLI does to locate and authenticate to the API server. See this [ package main import ( + "context" "fmt" "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -187,7 +188,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)) } ``` From eac11ac629d904e992a40fb496d5ee84f1f88b9a Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 20:59:36 -0400 Subject: [PATCH 5/7] [ko]: 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/ko/docs/tasks/administer-cluster/access-cluster-api.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/ko/docs/tasks/administer-cluster/access-cluster-api.md b/content/ko/docs/tasks/administer-cluster/access-cluster-api.md index 8ee76377de..10b97ce630 100644 --- a/content/ko/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/ko/docs/tasks/administer-cluster/access-cluster-api.md @@ -177,6 +177,7 @@ Go 클라이언트는 kubectl CLI가 API 서버를 찾아 인증하기 위해 package main import ( + "context" "fmt" "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -190,7 +191,7 @@ func main() { // clientset을 생성한다 clientset, _ := kubernetes.NewForConfig(config) // 파드를 나열하기 위해 API에 접근한다 - 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)) } ``` From 6fb5b93ad76a39e562fdb36c0f53bc696999abc4 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 21:00:14 -0400 Subject: [PATCH 6/7] [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)) } ``` From a4fc1d7b4f93cd20c8c83bbd7a14e520ee649f7c Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Tue, 8 Sep 2020 21:00:48 -0400 Subject: [PATCH 7/7] [zh] fix import examples for the client-go The import is broken, this patch fix the libraries. Signed-off-by: Douglas Schilling Landgraf --- .../zh/docs/tasks/administer-cluster/access-cluster-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 fc25f2645c..e66ebb3e3a 100644 --- a/content/zh/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/zh/docs/tasks/administer-cluster/access-cluster-api.md @@ -282,9 +282,9 @@ package main import ( "context" "fmt" - "k8s.io/client-go/1.4/kubernetes" - "k8s.io/client-go/1.4/pkg/api/v1" - "k8s.io/client-go/1.4/tools/clientcmd" + "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" ) func main() {