Skip to content

Conversation

@cjonesy
Copy link
Contributor

@cjonesy cjonesy commented Sep 11, 2024

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.

@cjonesy cjonesy requested a review from a team as a code owner September 11, 2024 21:50
Comment on lines +46 to +68
// 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")
}
}
Copy link
Contributor Author

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"
Copy link
Member

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 😂

@cjonesy cjonesy merged commit abf6f3f into main Sep 12, 2024
@cjonesy cjonesy deleted the add-shell-executioner branch September 12, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants