devops_utils.install module¶
Implements installation process for the devops-utils image.
The main function here is install()
which implements the
installation process.
The Replacer
, used from within install()
,
implements a lightweight preprocessing/templating process, thanks to
which the external runner can be used as-is when installed as well as
directly from source.
-
devops_utils.install.
install
(args)[source]¶ Install a runner and shortcuts to all supported programs.
The runner will be installed as
devops-utils
script in a directory from host mounted at/target
. The links to all included programs will be created in the same directory, pointing todevops-utils
.The runner will execute the command it’s run as (or passed as first parameter if executed as
devops-utils
) via docker run.Parameters: args (list) – command line arguments
-
class
devops_utils.install.
Replacer
(input, context)[source]¶ Bases:
object
Used to insert/replace chunks of code in a stream of lines.
This is used to embed some values into the runner script (as it doesn’t have access to them from outside a container) when installing it on the host system.
Iterating through the object will yield lines from the input with lines containing a special marker replaced. The marker format is
##INIT:OPERATOR[:PARAM]##
and should be followed by a newline.- The
OPERATOR
can be: MODULE
: thenPARAM
specifies a python module whose contents should be inserted instead of the original linePLUGINS
: thenPARAM
specifies type of plugins to be included instead of the original lineSUPPRESS
: supresses the line from output (no parameter)VAR
: thenPARAM
specifies name of variable to look up and place it’s definition in output instead of the original line
Typical usage:
src = StringIO('FOO = 1 ##INIT:VAR:FOO##\n') for line in Replacer(src, {'FOO': 2}): assert line == 'FOO = 2\n'
Parameters: - input (iter) – iterator for input lines
- context (dict) – look up variables to be replaced in this dict
-
RE_MARKER
= <_sre.SRE_Pattern object>¶
- The