-
Notifications
You must be signed in to change notification settings - Fork 5
/
apply_f.go
61 lines (53 loc) · 1.55 KB
/
apply_f.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"context"
"fmt"
"log"
"github.com/forbearing/k8s"
)
func Apply() {
filename := "../../testdata/examples/all.yaml"
//if err := k8s.ApplyF(context.TODO(), kubeconfig, filename, namespace); err != nil {
// log.Fatal(err)
//}
////time.Sleep(time.Second * 120)
//if err := k8s.DeleteF(context.TODO(), kubeconfig, filename, namespace); err != nil {
// log.Fatal(err)
//}
fmt.Println()
log.Println("first apply")
if err := k8s.ApplyF(context.TODO(), kubeconfig, filename, namespace); err != nil {
log.Fatal(err)
}
fmt.Println()
log.Println(`second apply, will output "invalid" error message`)
// update the pod will return "Invalid" error
if err := k8s.ApplyF(context.TODO(), kubeconfig, filename, namespace); err != nil {
log.Fatal(err)
}
fmt.Println()
log.Println("third apply, no error")
// ignore the "Invalid" error
if err := k8s.ApplyF(context.TODO(), kubeconfig, filename, namespace, k8s.IgnoreInvalid); err != nil {
log.Fatal(err)
}
//
//
fmt.Println()
log.Println("first delete")
if err := k8s.DeleteF(context.TODO(), kubeconfig, filename, namespace); err != nil {
log.Fatal(err)
}
fmt.Println()
log.Println(`second delete, will output "not found" error message`)
// output the "not found" error message
if err := k8s.DeleteF(context.TODO(), kubeconfig, filename, namespace); err != nil {
log.Fatal(err)
}
fmt.Println()
log.Println("third delete, no error")
// no error
if err := k8s.DeleteF(context.TODO(), kubeconfig, filename, namespace, k8s.IgnoreNotFound); err != nil {
log.Fatal(err)
}
}