in samcli/commands/_utils/options.py [0:0]
def artifact_callback(ctx, param, provided_value, artifact):
"""
Provide an error if there are zip/image artifact based resources,
and an destination export destination is not specified.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, it would be the value provided by the user.
:param artifact: artifact format that is to be compared against, eg: zip, image.
:return: Actual value to be used in the CLI
"""
# NOTE(sriram-mv): Both params and default_map need to be checked, as the option can be either be
# passed in directly or through configuration file.
# If passed in through configuration file, default_map is loaded with those values.
template_file = (
ctx.params.get("t", False) or ctx.params.get("template_file", False) or ctx.params.get("template", False)
)
resolve_s3 = ctx.params.get("resolve_s3", False) or ctx.default_map.get("resolve_s3", False)
required = any(
[
_template_artifact == artifact
for _template_artifact in get_template_artifacts_format(template_file=template_file)
]
)
# NOTE(sriram-mv): Explicit check for param name being s3_bucket
# If that is the case, check for another option called resolve_s3 to be defined.
# resolve_s3 option resolves for the s3 bucket automatically.
if param.name == "s3_bucket" and resolve_s3:
pass
elif required and not provided_value and param.name == "s3_bucket":
raise click.BadOptionUsage(option_name=param.name, ctx=ctx, message=f"Missing option '{param.opts[0]}'")
return provided_value