-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.go
77 lines (60 loc) · 1.63 KB
/
main.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"os"
flags "github.com/jessevdk/go-flags"
"k8s.io/client-go/kubernetes"
"github.com/IBM/ubiquity-k8s/helm_chart/hookexecutor"
utilsk8s "github.com/IBM/ubiquity-k8s/utils/kubernetes"
)
//PostInstallCommand
type PostInstallCommand struct {
PostInstall func() `short:"i" long:"postinstall" description:"post install"`
}
func (c *PostInstallCommand) Execute(args []string) error {
client := getClientset()
return hookexecutor.PostInstallExecutor(client).Execute()
}
//PreDeleteCommand
type PreDeleteCommand struct {
PreDelete func() `short:"d" long:"predelete" description:"pre delete"`
}
func (c *PreDeleteCommand) Execute(args []string) error {
client := getClientset()
return hookexecutor.PreDeleteExecutor(client).Execute()
}
//SanityCommand
type SanityCommand struct {
Sanity func() `short:"s" long:"sanity" description:"sanity"`
}
func (c *SanityCommand) Execute(args []string) error {
client := getClientset()
return hookexecutor.SanityExecutor(client).Execute()
}
type Options struct{}
func main() {
var postInstallCommand PostInstallCommand
var preDeleteCommand PreDeleteCommand
var sanityCommand SanityCommand
var options Options
var parser = flags.NewParser(&options, flags.Default)
parser.AddCommand("postinstall",
"post install",
"post install",
&postInstallCommand)
parser.AddCommand("predelete",
"pre delete",
"pre delete",
&preDeleteCommand)
parser.AddCommand("sanity",
"sanity",
"sanity",
&sanityCommand)
_, err := parser.Parse()
if err != nil {
panic(err)
os.Exit(1)
}
}
func getClientset() kubernetes.Interface {
return utilsk8s.GetClientset("Ubiquity helm utils")
}