external_runner module¶
The external runner for the devops-utils image.
Essentially wraps docker run -it --rm devops-utils
, providing
options to make the usage more convenient.
The main()
here is the entrypoint of the devops-utils image
runner program. It parses the arguments and executes docker run
with appropriate arguments.
argparse_builder()
is a decorator that registers a function to
be executed before argument parsing and can be used to add/modify
options, change default values, etc.
docker_run_builder()
is a decorator that registers a function
to be executed after argument parsing to modify the final command that
will be run.
DockerRunCommand
is a helper object encapsulating various
arguments which can be modified by the functions decorated with
docker_run_builder()
.
-
class
external_runner.
DockerRunCommand
(prog, prog_args, docker_args=None)[source]¶ Bases:
object
Encapsulates components of a docker run command.
The components (exposed as corresponding instance attributes) are:
-
docker_args
¶ -
(list) arguments for ``docker run``
-
prog
¶ -
(str) program to run inside the container
-
prog_args
¶ -
(list) arguments to the above program
All of the above are also accepted as constructor parameters. All of them can also be modified directly to affect the final command.
Exposes a property
cmd()
which returns a fully assembled list of docker command and arguments.-
cmd
¶ Return a fully assembled list of docker run command and arguments.
Returns: docker run command and arguments; list suitable for passing to subprocess.Popen
Return type: list
-
-
external_runner.
argparse_builder
()¶ Register decorated function as
ArgumentParser
instance builder.These builders are executed before argument parsing and can be used to add/modify options, change default values, etc.
The function signature should be:
-
external_runner.
func
(parser : argparse.ArgumentParser) → None¶ Parameters: parser (argparse.ArgumentParser) – parser to modify
-
-
external_runner.
docker_run_builder
()¶ Register decorated function as
docker run
command builder.These builders are executed after argument parsing to modify the final command that will be run (either
docker run
or the program inside the container).The function signature should be:
-
external_runner.
func
(args : argparse.Namespace, docker_run : DockerRunCommand) → None The function can modify
docker_run
object directly to affect the final command that will be executed.Parameters: - args (argparse.Namespace) – arguments and options passed to the runner itself
- docker_run (DockerRunCommand) – object encapsulating arguments to
docker_run
and the command to run inside the container
-