-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add ShellExecutioner #8
Conversation
// Command is required and must be a string | ||
if command, ok := cfgMap["command"].(string); ok { | ||
if command == "" { | ||
return nil, fmt.Errorf("command must not be empty") | ||
} | ||
cfg.Command = command | ||
} else if cfgMap["command"] != nil { | ||
return nil, fmt.Errorf("command must be a string") | ||
} else { | ||
return nil, fmt.Errorf("command is required") | ||
} | ||
|
||
// If shell is set, it should be a string | ||
if cfgMap["shell"] != nil { | ||
if shell, ok := cfgMap["shell"].(string); ok { | ||
if shell == "" { | ||
return nil, fmt.Errorf("shell must not be empty") | ||
} | ||
cfg.Shell = shell | ||
} else if cfgMap["shell"] != nil { | ||
return nil, fmt.Errorf("shell must be a string") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the near future I'm planning to generalize the config parsing into a utility package we can re-use.
DataEnvVarName = "GOVERSEER_DATA" | ||
|
||
// DefaultShell is the default shell to use when executing a command | ||
DefaultShell = "/bin/sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how we're going to deprive people of bash if they don't pass it in 😂
INF-5526
This PR adds a new Shell Executioner
This executioner will run the configured command in a shell.
The data that triggered the change is written to a temporary work directory that the command can access, should it need the data in it's logic. The path to this file is stored in the
GOVERSEER_DATA
environment variable, which is added to the command's environment. I chose to write this data to disk as the size of the data could easily exceed what we can store in an environment variable.