Skip to content

Commit

Permalink
docs: improve docs about process options
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Nov 17, 2023
1 parent 9d92e69 commit d2c0612
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/features/common_functional_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Testcontainers exposes the `WithStartupCommand(e ...Executable)` option to run a
It also exports an `Executable` interface, defining the following methods:

- `AsCommand()`, which returns a slice of strings to represent the command and positional arguments to be executed in the container;
- `Options()` to set the command options, such as the working directory, environment variables, user executing the command, etc. It returns a slice of functional options to configure the command.
- `Options()`, which returns the slice of functional options with the Docker's ExecConfigs used to create the command in the container (the working directory, environment variables, user executing the command, etc) and the possible output format (Multiplexed).

You could use this feature to run a custom script, or to run a command that is not supported by the module right after the container is started.

Expand Down
7 changes: 5 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ func WithNetwork(networkName string, alias string) CustomizeRequestOption {
}
}

// Executable represents an executable command to be sent to a container
// as part of the PostStart lifecycle hook.
// Executable represents an executable command to be sent to a container, including options,
// as part of the different lifecycle hooks.
type Executable interface {
AsCommand() []string
// Options can container two different types of options:
// - Docker's ExecConfigs (WithUser, WithWorkingDir, WithEnv, etc.)
// - testcontainers' ProcessOptions (i.e. Multiplexed response)
Options() []tcexec.ProcessOption
}

Expand Down

0 comments on commit d2c0612

Please sign in to comment.