in chalice/cli/__init__.py [0:0]
def package(ctx, single_file, stage, merge_template,
out, pkg_format, template_format, profile):
# type: (click.Context, bool, str, str, str, str, str, str) -> None
factory = ctx.obj['factory'] # type: CLIFactory
factory.profile = profile
config = factory.create_config_obj(stage)
options = factory.create_package_options()
packager = factory.create_app_packager(config, options,
pkg_format,
template_format,
merge_template)
if pkg_format == 'terraform' and (merge_template or
single_file or
template_format != 'json'):
# I don't see any reason we couldn't support --single-file for
# terraform if we wanted to.
click.echo((
"Terraform format does not support "
"--merge-template, --single-file, or --template-format"))
raise click.Abort()
if single_file:
dirname = tempfile.mkdtemp()
try:
packager.package_app(config, dirname, stage)
create_zip_file(source_dir=dirname, outfile=out)
finally:
shutil.rmtree(dirname)
else:
packager.package_app(config, out, stage)