Merge "Align the style with Docker on commit"
This commit is contained in:
commit
7e23e33f40
@ -132,6 +132,18 @@ def check_restart_policy(policy):
|
||||
return restart_policy
|
||||
|
||||
|
||||
def check_commit_container_args(commit_args):
|
||||
opts = {}
|
||||
if commit_args.repository is not None:
|
||||
if ':' in commit_args.repository:
|
||||
args_list = commit_args.repository.split(':')
|
||||
opts['repository'] = args_list[0]
|
||||
opts['tag'] = args_list[1]
|
||||
else:
|
||||
opts['repository'] = commit_args.repository
|
||||
return opts
|
||||
|
||||
|
||||
def remove_null_parms(**kwargs):
|
||||
new = {}
|
||||
for (key, value) in kwargs.items():
|
||||
|
@ -923,22 +923,15 @@ class CommitContainer(command.Command):
|
||||
metavar='<container>',
|
||||
help='ID or name of the (container)s to commit.')
|
||||
parser.add_argument(
|
||||
'--repository',
|
||||
required=True,
|
||||
metavar='<repository>',
|
||||
help='Repository of the new image.')
|
||||
parser.add_argument(
|
||||
'--tag',
|
||||
metavar='<tag>',
|
||||
help='Tag of the new iamge')
|
||||
'repository',
|
||||
metavar='<repository>[:<tag>]',
|
||||
help='Repository and tag of the new image.')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = _get_client(self, parsed_args)
|
||||
container = parsed_args.container
|
||||
opts = {}
|
||||
opts['repository'] = parsed_args.repository
|
||||
opts['tag'] = parsed_args.tag
|
||||
opts = zun_utils.check_commit_container_args(parsed_args)
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
try:
|
||||
image = client.containers.commit(container, **opts)
|
||||
|
@ -654,20 +654,13 @@ def do_stats(cs, args):
|
||||
@utils.arg('container',
|
||||
metavar='<container>',
|
||||
help='ID or name of the container to commit.')
|
||||
@utils.arg('--repository',
|
||||
metavar='<repository>',
|
||||
required=True,
|
||||
help='The repository of the image.')
|
||||
@utils.arg('--tag',
|
||||
metavar='<tag>',
|
||||
help='The tag of the image')
|
||||
@utils.arg('repository',
|
||||
metavar='<repository>[:<tag>]',
|
||||
help='The repository and tag of the image.')
|
||||
def do_commit(cs, args):
|
||||
"""Create a new image from a container's changes."""
|
||||
opts = {}
|
||||
if args.repository is not None:
|
||||
opts['repository'] = args.repository
|
||||
if args.tag is not None:
|
||||
opts['tag'] = args.tag
|
||||
opts = zun_utils.check_commit_container_args(args)
|
||||
opts = zun_utils.remove_null_parms(**opts)
|
||||
try:
|
||||
image = cs.containers.commit(args.container, **opts)
|
||||
print("Request to commit container %s has been accepted. "
|
||||
|
Loading…
x
Reference in New Issue
Block a user