mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Added namespace and better pod name in client go example
This commit is contained in:
parent
601ab10dbd
commit
a71bb87ec7
@ -48,7 +48,7 @@ func main() {
|
|||||||
// Examples for error handling:
|
// Examples for error handling:
|
||||||
// - Use helper functions like e.g. errors.IsNotFound()
|
// - Use helper functions like e.g. errors.IsNotFound()
|
||||||
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
||||||
_, err = clientset.CoreV1().Pods("").Get("ExamplePodName", metav1.GetOptions{})
|
_, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{})
|
||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
fmt.Printf("Pod not found\n")
|
fmt.Printf("Pod not found\n")
|
||||||
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
||||||
|
@ -62,7 +62,7 @@ func main() {
|
|||||||
// Examples for error handling:
|
// Examples for error handling:
|
||||||
// - Use helper functions like e.g. errors.IsNotFound()
|
// - Use helper functions like e.g. errors.IsNotFound()
|
||||||
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
// - And/or cast to StatusError and use its properties like e.g. ErrStatus.Message
|
||||||
_, err = clientset.CoreV1().Pods("").Get("ExamplePodName", metav1.GetOptions{})
|
_, err = clientset.CoreV1().Pods("default").Get("example-xxxxx", metav1.GetOptions{})
|
||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
fmt.Printf("Pod not found\n")
|
fmt.Printf("Pod not found\n")
|
||||||
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
} else if statusError, isStatus := err.(*errors.StatusError); isStatus {
|
||||||
|
Loading…
Reference in New Issue
Block a user