Skip to content

Commit

Permalink
Add support for multiple --env-file
Browse files Browse the repository at this point in the history
  • Loading branch information
RazRegev authored and eranco74 committed Mar 13, 2021
1 parent 9bad2b6 commit f65801e
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 39 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Skipper can serve as your primary tool for your daily development tasks:
--build-container-image Image to use as build container
--build-container-tag Tag of the build container
--build-container-net Network to connect the build container (default: net=host)
--env-file Environment variables file to pass to the container
--env-file Environment variables file/s to pass to the container
--help Show this message and exit.
```

Expand Down Expand Up @@ -193,7 +193,7 @@ env:
VAR: value
````

You can add an environment variables file using `--env-file`.
You can add an environment variables file (or multiple files) using `--env-file`.
This file should use the syntax <key>=value (which sets the variable to the given value) or <key>
(which takes the value from the local environment), and # for comments.
The variables defined in this file will be exported to the container.
Expand All @@ -209,7 +209,9 @@ KEY3

Skipper configuration file can include the environment variables file:
````
env_file: /path/to/env_file.env
env_file:
- /path/to/env_file1.env
- /path/to/env_file2.env
````


Expand Down
2 changes: 1 addition & 1 deletion skipper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _validate_port_out_of_range(port):
@click.option('--build-container-image', help='Image to use as build container')
@click.option('--build-container-tag', help='Tag of the build container')
@click.option('--build-container-net', help='Network to connect the build container')
@click.option('--env-file', help='Environment variable file to load')
@click.option('--env-file', multiple=True, help='Environment variable file(s) to load')
@click.pass_context
def cli(ctx, registry, build_container_image, build_container_tag, build_container_net, verbose, env_file):
"""
Expand Down
6 changes: 3 additions & 3 deletions skipper/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_default_net():

# pylint: disable=too-many-arguments
def run(command, fqdn_image=None, environment=None, interactive=False, name=None, net=None, publish=(), volumes=None,
workdir=None, use_cache=False, workspace=None, env_file=None):
workdir=None, use_cache=False, workspace=None, env_file=()):

if not net:
net = get_default_net()
Expand Down Expand Up @@ -64,8 +64,8 @@ def _run_nested(fqdn_image, environment, command, interactive, name, net, publis

cmd = handle_networking(cmd, publish, net)

if env_file:
cmd += ['--env-file', env_file]
for _file in env_file:
cmd += ['--env-file', _file]

environment = environment or []
for env in environment:
Expand Down
Loading

0 comments on commit f65801e

Please sign in to comment.