def create(ctx, image, verify):
"""Creates a new application for image IMAGE."""
# Verify if `image` is an existing docker image
# in this machine
if verify:
msg = ('{error}. You may consider skipping verifying '
'image name against docker with --no-verify.')
try:
client = get_docker_client()
client.inspect_image(image)
except Exception as exception:
raise click.BadParameter(msg.format(error=str(exception)),
ctx=ctx)
session = ctx.obj.session
try:
with orm.transaction(session):
orm_app = orm.Application(image=image)
session.add(orm_app)
except sqlalchemy.exc.IntegrityError:
print_error("Application for image {} already exists".format(image))
else:
print(orm_app.id)
评论列表
文章目录