Skip to content

Commit

Permalink
Merge pull request #177 from AlanCoding/default_processing
Browse files Browse the repository at this point in the history
Show all defaults in help text, consolidate some

Reviewed-by: https://github.com/apps/ansible-zuul
  • Loading branch information
ansible-zuul[bot] authored Jan 14, 2021
2 parents fcc0312 + f695495 commit b400121
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions ansible_builder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import sys
import yaml

from . import __version__
from . import __version__, constants

from .colors import MessageColors
from .exceptions import DefinitionError
from .main import AnsibleBuilder
from . import constants
from .introspect import add_introspect_options, process, simple_combine
from .requirements import sanitize_requirements
from .utils import configure_logger
Expand Down Expand Up @@ -77,38 +76,42 @@ def parse_args(args=sys.argv[1:]):

build_command_parser.add_argument('-t', '--tag',
default=constants.default_tag,
help='The name for the container image being built.')
help='The name for the container image being built (default: %(default)s)')

for p in [build_command_parser]:

p.add_argument('-f', '--file',
default=constants.default_file,
dest='filename',
help='The definition of the execution environment.')
help='The definition of the execution environment (default: %(default)s)')

p.add_argument('-c', '--context',
default=constants.default_build_context,
dest='build_context',
help='The directory to use for the build context. Defaults to $PWD/context.')
help='The directory to use for the build context (default: %(default)s)')

p.add_argument('--container-runtime',
choices=list(constants.runtime_files.keys()),
default=constants.default_container_runtime,
help='Specifies which container runtime to use. Defaults to {0}.'.format(constants.default_container_runtime))
help='Specifies which container runtime to use (default: %(default)s)')

p.add_argument('--build-arg',
action=BuildArgAction,
default={},
dest='build_args')
dest='build_args',
help='Build-time variables to pass to any podman or docker calls. '
'Internally ansible-builder makes use of {0}.'.format(
', '.join(constants.build_arg_defaults.keys()))
)

p.add_argument('-v', '--verbosity',
dest='verbosity',
type=int,
choices=[0, 1, 2, 3],
default=2,
default=constants.default_verbosity,
help='Increase the output verbosity, for up to three levels of verbosity '
'(invoked via "--verbosity" or "-v" followed by an integer ranging '
'in value from 0 to 3)')
'in value from 0 to 3) (default: %(default)s)')

introspect_parser = subparsers.add_parser(
'introspect',
Expand Down
1 change: 1 addition & 0 deletions ansible_builder/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
default_file = 'execution-environment.yml'
default_tag = 'ansible-execution-env:latest'
default_build_context = 'context'
default_verbosity = 2
runtime_files={
'podman': 'Containerfile',
'docker': 'Dockerfile'
Expand Down
2 changes: 1 addition & 1 deletion ansible_builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, action=None,
build_context=constants.default_build_context,
tag=constants.default_tag,
container_runtime=constants.default_container_runtime,
verbosity=2):
verbosity=constants.default_verbosity):
self.action = action
self.definition = UserDefinition(filename=filename)

Expand Down

0 comments on commit b400121

Please sign in to comment.