-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
62 lines (51 loc) · 1.31 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
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
parseArgs()
initLog(args.Verbose)
validKC := validateKubeconfig(args.Kubeconfig || args.Apply)
if args.Kubeconfig || (!validKC && args.Apply) {
return
}
cfgs := LoadInput()
if len(cfgs) == 0 || args.Help {
fmt.Println("Usage: sk8 [option(s)] {file(s)}")
fmt.Println("")
fmt.Println("Options: -apply Call 'kubectl' to update Kubernetes")
fmt.Println(" -kubeconfig | -kc Show the current server according to the KUBECONFIG-file")
fmt.Println(" -verbose | -v Show verbose output")
fmt.Println(" -{template-tag} Applies the template indicated by the {template-tag} key (i.e is prefixed with)")
fmt.Println(" -all Applies all templates that are specified")
return
}
if (args.AllTemplates || len(args.Templates) > 0) && !args.Debug {
if !SendOutput(cfgs) {
os.Exit(1)
}
} else {
for _, o := range cfgs {
dump(o)
}
}
}
func readStuff(scanner *bufio.Scanner, stop chan bool, isErr bool) {
format := "kubectl> %s"
for scanner.Scan() {
txt := scanner.Text()
if isErr {
if strings.HasPrefix(txt, "W") {
log.Warningf(format, txt)
} else {
log.Errorf(format, txt)
}
} else {
log.Noticef(format, txt)
}
}
stop <- true
}