Skip to content

Commit

Permalink
Merge branch 'add-config-option' of github.com:agyoungs/rocker into i…
Browse files Browse the repository at this point in the history
…ntegration
  • Loading branch information
agyoungs committed Oct 31, 2024
2 parents 7d4ed95 + 4182cf4 commit 701f67c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'pexpect',
'packaging',
'urllib3',
'pyyaml',
]

# docker API used to be in a package called `docker-py` before the 2.0 release
Expand Down
11 changes: 11 additions & 0 deletions src/rocker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import argparse
import os
import sys
import yaml

from .core import DockerImageGenerator
from .core import get_rocker_version
Expand All @@ -32,6 +33,10 @@ def main():
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('image')
parser.add_argument('command', nargs='*', default='')
parser.add_argument('--config', help='''Optional yaml file to handle command line arguments
(except positional args) as a config file. This config will override any other command line
arguments of the same name as the yaml keys (e.g. "--user-override-name" would have the key
"user_override_name" in the config file)''')
parser.add_argument('--noexecute', action='store_true', help='Deprecated')
parser.add_argument('--nocache', action='store_true')
parser.add_argument('--nocleanup', action='store_true', help='do not remove the docker container when stopped')
Expand All @@ -50,6 +55,12 @@ def main():
args = parser.parse_args()
args_dict = vars(args)

# Load config file if provided
if args.config:
with open(args.config, 'r') as f:
config = yaml.safe_load(f)
args_dict.update(config)

if args.noexecute:
from .core import OPERATIONS_DRY_RUN
args_dict['mode'] = OPERATIONS_DRY_RUN
Expand Down

0 comments on commit 701f67c

Please sign in to comment.