move Restart and Templating to config options
and run gofmt Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -6,8 +6,6 @@ type Source struct {
|
||||
Token string `json:"token"`
|
||||
ConsulToken string `json:"consul_token"`
|
||||
VaultToken string `json:"vault_token"`
|
||||
Templating bool `json:"templating"`
|
||||
Restart bool `json:"restart"`
|
||||
}
|
||||
|
||||
type JobVersion struct {
|
||||
|
||||
14
out/main.go
14
out/main.go
@@ -19,6 +19,8 @@ type Params struct {
|
||||
JobPath string `json:"job_path"`
|
||||
Vars map[string]string `json:"vars"`
|
||||
VarFiles map[string]string `json:"var_files"`
|
||||
Templating bool `json:"templating"`
|
||||
Restart bool `json:"restart"`
|
||||
}
|
||||
|
||||
type OutConfig struct {
|
||||
@@ -45,7 +47,7 @@ func main() {
|
||||
templPath := filepath.Join(sourceDir, config.Params.JobPath)
|
||||
templFile, err := ioutil.ReadFile(templPath)
|
||||
common.Check(err, "Could not read input file "+templPath)
|
||||
if ( config.Source.Templating != false ) {
|
||||
if config.Params.Templating != false {
|
||||
tmpl, err := template.New("job").Parse(string(templFile))
|
||||
common.Check(err, "Error parsing template")
|
||||
|
||||
@@ -68,7 +70,7 @@ func main() {
|
||||
common.Check(err, "Error writing output file")
|
||||
}
|
||||
|
||||
if ( config.Source.Restart != false ) {
|
||||
if config.Params.Restart != false {
|
||||
cmd := exec.Command(
|
||||
"nomad",
|
||||
"job",
|
||||
@@ -81,12 +83,8 @@ func main() {
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &out
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error executing nomad: %s\n", err)
|
||||
fmt.Fprint(os.Stderr, out.String())
|
||||
os.Exit(1)
|
||||
}
|
||||
_ = cmd.Run()
|
||||
//Ignore even if the job fails to purge
|
||||
}
|
||||
cmd := exec.Command(
|
||||
"nomad",
|
||||
|
||||
Reference in New Issue
Block a user