Skip to content

Commit

Permalink
add sudo_user parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Apr 15, 2024
1 parent 23a46bd commit af142fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion provisioner/testinfra.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Config struct {
Processes int `mapstructure:"processes" required:"false"`
PytestPath string `mapstructure:"pytest_path" required:"false"`
Sudo bool `mapstructure:"sudo" required:"false"`
SudoUser string `mapstructure:"sudo_user" required:"false"`
TestFiles []string `mapstructure:"test_files" required:"false"`
Verbose bool `mapstructure:"verbose" required:"false"`

Expand Down Expand Up @@ -145,11 +146,19 @@ func (provisioner *Provisioner) Prepare(raws ...interface{}) error {
log.Printf("executing tests with marker expression: %s", provisioner.config.Marker)
}

// sudo parameter
// sudo and sudo_user parameters
if provisioner.config.Sudo {
log.Print("testinfra will execute with sudo")

if len(provisioner.config.SudoUser) > 0 {
log.Printf("testinfra will execute as user: %s", provisioner.config.SudoUser)
}
} else {
log.Print("testinfra will not execute with sudo")

if len(provisioner.config.SudoUser) > 0 {
log.Print("the 'sudo_user' parameter is ignored when sudo is not enabled")
}
}

// verbose parameter
Expand Down
2 changes: 2 additions & 0 deletions provisioner/testinfra.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af142fa

Please sign in to comment.