-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
65 lines (56 loc) · 1.4 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 (
"fmt"
"os"
"github.com/harvester/addons/pkg/render"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
const (
templateSource = "./pkg/templates"
)
func main() {
var generateAddons, generateTemplates bool
var path string
app := &cli.App{
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "generateAddons",
Value: false,
Usage: "generate disabled addon yaml manifests",
Destination: &generateAddons,
},
&cli.BoolFlag{
Name: "generateTemplates",
Value: false,
Usage: "generate template manifests",
Destination: &generateTemplates,
},
&cli.StringFlag{
Name: "path",
Value: ".",
Usage: "destination for output files",
Destination: &path,
},
},
Action: func(ctx *cli.Context) error {
if !generateAddons && !generateTemplates {
return fmt.Errorf("generateAddons or generateTemplates need to be specified")
}
if generateAddons {
if err := render.Addon(templateSource, path, "version_info"); err != nil {
return fmt.Errorf("error during rendering addons: %v", err)
}
}
if generateTemplates {
if err := render.Template(templateSource, path, "version_info"); err != nil {
return fmt.Errorf("error during rendering template: %v", err)
}
}
return nil
},
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}