/
yml.go
51 lines (42 loc) 路 977 Bytes
/
yml.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
package action
import (
"context"
"github.com/helmwave/helmwave/pkg/template"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
var _ Action = (*Yml)(nil)
// Yml is a struct for running 'yml' command.
type Yml struct {
tpl, file string
templater string
}
// Run is the main function for 'yml' command.
func (i *Yml) Run(ctx context.Context) error {
err := template.Tpl2yml(ctx, i.tpl, i.file, nil, i.templater)
if err != nil {
return err
}
log.WithField(
"build plan with next command",
"helmwave build -f "+i.file,
).Info("馃搫 YML is ready!")
return nil
}
// Cmd returns 'yml' *cli.Command.
func (i *Yml) Cmd() *cli.Command {
return &cli.Command{
Name: "yml",
// Category: Step0,
Usage: "馃搫 render helmwave.yml.tpl -> helmwave.yml",
Flags: i.flags(),
Action: toCtx(i.Run),
}
}
func (i *Yml) flags() []cli.Flag {
return []cli.Flag{
flagTplFile(&i.tpl),
flagYmlFile(&i.file),
flagTemplateEngine(&i.templater),
}
}