-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
65 lines (55 loc) · 1.62 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
package main
import (
"os"
"path"
flag "github.com/spf13/pflag"
"github.com/steffakasid/kusto-me/internal"
)
var (
overlay bool
name, folder string
overlayDir, defaultLabels []string
)
var defaultOverlays = []string{"development", "production"}
func init() {
flag.BoolVarP(&overlay, "overlay", "o", false, "Defines if overlay structure should be created or just a simple project")
flag.StringVarP(&name, "name", "n", "", "Set the projectname. If not set the current directoryname is used")
flag.StringVarP(&folder, "folder", "f", "", "Set the folder to create kustomize project. If not set current dir is used.")
flag.StringArrayVarP(&overlayDir, "dir", "d", []string{}, "Define overlay directories to be used.")
flag.StringArrayVarP(&defaultLabels, "label", "l", []string{}, "Add default labels to kustomization.yml. Format: <key>:<value>")
flag.Parse()
}
func main() {
var (
pwd string
err error
)
if folder != "" {
if _, err := os.Stat(folder); err != nil {
panic(err)
}
pwd = folder
} else {
pwd, err = os.Getwd()
if err != nil {
panic(err)
}
}
appName := path.Base(pwd)
if name != "" {
appName = name
}
kustoMe := internal.KustoMe{
ApplicationName: appName,
ApplicationRootFolder: pwd,
ApplicationBaseFolder: path.Join(pwd, internal.KustomizationBase),
ApplicationOverlayFolder: path.Join(pwd, internal.KustomizationOverlays),
ApplicationFiles: internal.GetFiles(pwd),
}
if len(overlayDir) > 0 {
kustoMe.ApplicationOverlays = overlayDir
} else {
kustoMe.ApplicationOverlays = defaultOverlays
}
kustoMe.KustomizeMe(overlay)
}