Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/run/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ var Cmd = &cobra.Command{
func init() {
flags := Cmd.Flags()
flags.BoolVarP(&verbose, "verbose", "v", verbose, "Verbose logging")
flags.StringToStringVarP(&cmdInputs, "inputs", "i", cmdInputs, "Input variables")
flags.StringVarP(&inputFile, "inputfile", "f", inputFile, "Input variables file")
flags.StringToStringVarP(&cmdInputs, "config", "c", cmdInputs, "Config variable")
flags.StringVarP(&inputFile, "configFile", "f", inputFile, "Config file")
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import "strings"

type Config map[string]string
type Config map[string]*string

type Type string

Expand Down
21 changes: 17 additions & 4 deletions playbook/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package playbook
import (
"fmt"
"path/filepath"
"strings"

"github.com/bmeg/flame"
"github.com/bmeg/sifter/logger"
Expand All @@ -22,6 +23,7 @@ func fileExists(filename string) bool {

func (pb *Playbook) PrepConfig(inputs map[string]string, workdir string) (map[string]string, error) {
workdir, _ = filepath.Abs(workdir)
missing := map[string]bool{}
out := map[string]string{}
for _, v := range pb.GetConfigFields() {
if val, ok := inputs[v.Name]; ok {
Expand All @@ -32,16 +34,27 @@ func (pb *Playbook) PrepConfig(inputs map[string]string, workdir string) (map[st
out[v.Name] = val
}
} else if val, ok := pb.Config[v.Name]; ok {
if v.IsFile() || v.IsDir() {
defaultPath := filepath.Join(filepath.Dir(pb.path), val)
out[v.Name], _ = filepath.Abs(defaultPath)
if val != nil {
if v.IsFile() || v.IsDir() {
defaultPath := filepath.Join(filepath.Dir(pb.path), *val)
out[v.Name], _ = filepath.Abs(defaultPath)
} else {
out[v.Name] = *val
}
} else {
out[v.Name] = val
missing[v.Name] = true
}
} else {
return nil, fmt.Errorf("config %s not defined", v.Name)
}
}
if len(missing) > 0 {
o := []string{}
for k := range missing {
o = append(o, k)
}
return nil, fmt.Errorf("missing inputs: %s", strings.Join(o, ","))
}
return out, nil
}

Expand Down
Loading