Skip to content

Commit 08f46e4

Browse files
authored
Merge pull request kubernetes#82932 from ashish-billore/mybranch2
Corrected the pod reporting and messages
2 parents 05588f7 + 31e427b commit 08f46e4

File tree

1 file changed

+5
-3
lines changed
  • staging/src/k8s.io/client-go/examples/in-cluster-client-configuration

1 file changed

+5
-3
lines changed

staging/src/k8s.io/client-go/examples/in-cluster-client-configuration/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,26 @@ func main() {
4848
panic(err.Error())
4949
}
5050
for {
51+
// get pods in all the namespaces by omitting namespace
52+
// Or specify namespace to get pods in particular namespace
5153
pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{})
5254
if err != nil {
5355
panic(err.Error())
5456
}
5557
fmt.Printf("There are %d pods in the cluster\n", len(pods.Items))
5658

5759
// Examples for error handling:
58-
// - Use helper functions like e.g. errors.IsNotFound()
60+
// - Use helper functions e.g. errors.IsNotFound()
5961
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
6062
_, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{})
6163
if errors.IsNotFound(err) {
62-
fmt.Printf("Pod not found\n")
64+
fmt.Printf("Pod example-xxxxx not found in default namespace\n")
6365
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
6466
fmt.Printf("Error getting pod %v\n", statusError.ErrStatus.Message)
6567
} else if err != nil {
6668
panic(err.Error())
6769
} else {
68-
fmt.Printf("Found pod\n")
70+
fmt.Printf("Found example-xxxxx pod in default namespace\n")
6971
}
7072

7173
time.Sleep(10 * time.Second)

0 commit comments

Comments
 (0)