Skip to content

Commit

Permalink
implemented preconf
Browse files Browse the repository at this point in the history
  • Loading branch information
kazubu committed Jun 30, 2024
1 parent 23b05fa commit 6476704
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions command_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ func CmdConf(c *cli.Context) error {
nodeinfo[node.Name] = node.Type
}

if len(tnconfig.PreConf) != 0 {
for _, preConf := range tnconfig.PreConf {
preConfCmds := shell.ExecCmd(preConf.Cmds)
utils.PrintCmds(os.Stdout, preConfCmds, verbose)
}
}

for _, nodeConfig := range tnconfig.NodeConfigs {
execConfCmds := nodeConfig.ExecConf(nodeinfo[nodeConfig.Name])
for _, execConfCmd := range execConfCmds {
Expand Down
3 changes: 3 additions & 0 deletions configs/spec_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ precmd:
- cmds:
- cmd: ""
preinit:
- cmds:
- cmd: ""
preconf:
- cmds:
- cmd: ""
postinit:
Expand Down
14 changes: 14 additions & 0 deletions internal/pkg/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var log = l.New()
type Tn struct {
PreCmd []PreCmd `yaml:"precmd"`
PreInit []PreInit `yaml:"preinit"`
PreConf []PreConf `yaml:"preconf"`
PostInit []PostInit `yaml:"postinit"`
PostFini []PostFini `yaml:"postfini"`
Nodes []Node `yaml:"nodes" mapstructure:"nodes"`
Expand All @@ -38,6 +39,11 @@ type PreInit struct {
Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

// PreConf
type PreConf struct {
Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
}

// PostInit
type PostInit struct {
Cmds []Cmd `yaml:"cmds" mapstructure:"cmds"`
Expand Down Expand Up @@ -232,6 +238,13 @@ func GenerateFile() (genContent string, err error) {
},
},
}
preconf := PreConf{
Cmds: []Cmd{
Cmd{
Cmd: "",
},
},
}
postinit := PostInit{
Cmds: []Cmd{
Cmd{
Expand Down Expand Up @@ -341,6 +354,7 @@ func GenerateFile() (genContent string, err error) {
tnconfig := &Tn{
PreCmd: []PreCmd{precmd},
PreInit: []PreInit{preinit},
PreConf: []PreConf{preconf},
PostInit: []PostInit{postinit},
PostFini: []PostFini{postfini},
Nodes: []Node{nodes},
Expand Down

0 comments on commit 6476704

Please sign in to comment.