Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inventory commands to recognize top-level env vars #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion cmd/sup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func parseArgs(conf *sup.Supfile) (*sup.Network, []*sup.Command, error) {
network.Env.Set(env[:i], env[i+1:])
}

hosts, err := network.ParseInventory()
hosts, err := network.ParseInventory(conf)
if err != nil {
return nil, nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion supfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,14 @@ func NewSupfile(data []byte) (*Supfile, error) {

// ParseInventory runs the inventory command, if provided, and appends
// the command's output lines to the manually defined list of hosts.
func (n Network) ParseInventory() ([]string, error) {
func (n Network) ParseInventory(conf *Supfile) ([]string, error) {
if n.Inventory == "" {
return nil, nil
}

cmd := exec.Command("/bin/sh", "-c", n.Inventory)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, conf.Env.Slice()...)
cmd.Env = append(cmd.Env, n.Env.Slice()...)
cmd.Stderr = os.Stderr
output, err := cmd.Output()
Expand Down