~charles/bem

1f424074d3b9923011be2420d33e7f32066568f4 — Charles Daniels 4 years ago e1e2ff8
add ability to bind volumes
4 files changed, 28 insertions(+), 6 deletions(-)

M BEMfile
M README.md
M bem/bem_config.py
M bem/bem_engine.py
M BEMfile => BEMfile +0 -6
@@ 1,8 1,2 @@
[BEM]
minimum_version = 0.0.1

[environment]
TERM = XTERM

[indirectenvironment]
BEM_VERSION = {version}

M README.md => README.md +9 -0
@@ 166,3 166,12 @@ be set even if `noenvtamper` or `noenvpassthrough` are asserted. Values placed
in `[indirectenvironment]` will be expanded using the substitution syntax used
for config values. If the same name exists in both `[environment]` and
`[indirectenvironment]`, the latter takes precedence.

### Volmes

Any sections prefixed with `volume_` must specify the following keys, and will
be used to create bound volumes. These values do not support indirection (yet).

* `host_path` -- path on the host system
* `container_path` -- path in the container
* `mode` -- `ro` or `rw`

M bem/bem_config.py => bem/bem_config.py +14 -0
@@ 135,6 135,20 @@ def load_config(inifile, args, ini_dir):
            logging.debug("loading key {} from indirect environment: {}".format(
                key, inifile["indirectenvironment"][key]))

    # setup volumes
    config["#volumes"] = {}
    for section in inifile:
        try:
            if section.startswith("volume_"):
                config["#volumes"][inifile[section]["host_path"]] = {
                        "bind": inifile[section]["container_path"],
                        "mode": inifile[section]["mode"],
                    }
        except Exception as e:
            raise Exception("Failed processing section '{}': {}"
                .format(section, e))


    logging.debug("resolved config... ")
    bem_util.log_pretty(logging.debug, config)


M bem/bem_engine.py => bem/bem_engine.py +5 -0
@@ 138,6 138,11 @@ def execute_command(config, command):
    else:
        raise Exception("unknown squashmethod: {}".format(config["squashmethod"]))

    # copy in overidden volumes
    for key in config["#volumes"]:
        volumes[key] = config["#volumes"][key]


    logging.debug("volumes: {}".format(volumes))

    # TODO: if getcwd does not exist inside of the container (not a child of