Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ def get_local_lambda_images_location(mapping, runtime):
return os.path.join(_lambda_images_templates, runtime, dir_name + "-lambda-image")


SUPPORTED_DEP_MANAGERS: List[str] = list(
set(
{
c.get("dependency_manager") # type: ignore
for c in list(itertools.chain(*(RUNTIME_DEP_TEMPLATE_MAPPING.values())))
if c.get("dependency_manager")
}
SUPPORTED_DEP_MANAGERS: List[str] = sorted(
list(
set(
{
c.get("dependency_manager") # type: ignore
for c in list(itertools.chain(*(RUNTIME_DEP_TEMPLATE_MAPPING.values())))
if c.get("dependency_manager")
}
)
)
)

Expand Down Expand Up @@ -145,7 +147,7 @@ def get_local_lambda_images_location(mapping, runtime):
"ruby2.7": "amazon/ruby2.7-base",
}

LAMBDA_IMAGES_RUNTIMES: List = list(set(LAMBDA_IMAGES_RUNTIMES_MAP.values()))
LAMBDA_IMAGES_RUNTIMES: List = sorted(list(set(LAMBDA_IMAGES_RUNTIMES_MAP.values())))

# Schemas Code lang is a MINIMUM supported version
# - this is why later Lambda runtimes can be mapped to earlier Schemas Code Languages
Expand Down
148 changes: 144 additions & 4 deletions schema/samcli.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,149 @@
"properties": {
"parameters": {
"title": "Parameters for the init command",
"description": "Available parameters for the init command:\n",
"description": "Available parameters for the init command:\n* no_interactive:\nDisable interactive prompting for init parameters. (fail if any required values are missing)\n* architecture:\nArchitectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7\n* package_type:\nLambda deployment package type.\n\nPackage Types: Zip, Image\n* base_image:\nLambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip\n* output_dir:\nDirectory to initialize AWS SAM application.\n* name:\nName of AWS SAM Application.\n* app_template:\nIdentifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow.\n* no_input:\nDisable Cookiecutter prompting and accept default values defined in the cookiecutter config.\n* extra_context:\nOverride custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}\n* tracing:\nEnable AWS X-Ray tracing for application.\n* application_insights:\nEnable CloudWatch Application Insights monitoring for application.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.",
"type": "object",
"properties": {}
"properties": {
"no_interactive": {
"title": "no_interactive",
"type": "boolean",
"description": "Disable interactive prompting for init parameters. (fail if any required values are missing)"
},
"architecture": {
"title": "architecture",
"type": "string",
"description": "Architectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']",
"enum": [
"arm64",
"x86_64"
]
},
"location": {
"title": "location",
"type": "string",
"description": "Template location (git, mercurial, http(s), zip, path)."
},
"runtime": {
"title": "runtime",
"type": "string",
"description": "Lambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7",
"enum": [
"dotnet6",
"go1.x",
"java11",
"java17",
"java8",
"java8.al2",
"nodejs12.x",
"nodejs14.x",
"nodejs16.x",
"nodejs18.x",
"provided",
"provided.al2",
"python3.10",
"python3.11",
"python3.7",
"python3.8",
"python3.9",
"ruby2.7",
"ruby3.2"
]
},
"package_type": {
"title": "package_type",
"type": "string",
"description": "Lambda deployment package type.\n\nPackage Types: Zip, Image",
"enum": [
"Image",
"Zip"
]
},
"base_image": {
"title": "base_image",
"type": "string",
"description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base",
"enum": [
"amazon/dotnet6-base",
"amazon/go-provided.al2-base",
"amazon/go1.x-base",
"amazon/java11-base",
"amazon/java17-base",
"amazon/java8-base",
"amazon/java8.al2-base",
"amazon/nodejs12.x-base",
"amazon/nodejs14.x-base",
"amazon/nodejs16.x-base",
"amazon/nodejs18.x-base",
"amazon/python3.10-base",
"amazon/python3.11-base",
"amazon/python3.7-base",
"amazon/python3.8-base",
"amazon/python3.9-base",
"amazon/ruby2.7-base",
"amazon/ruby3.2-base"
]
},
"dependency_manager": {
"title": "dependency_manager",
"type": "string",
"description": "Dependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip",
"enum": [
"bundler",
"cli-package",
"gradle",
"maven",
"mod",
"npm",
"pip"
]
},
"output_dir": {
"title": "output_dir",
"type": "string",
"description": "Directory to initialize AWS SAM application.",
"default": "."
},
"name": {
"title": "name",
"type": "string",
"description": "Name of AWS SAM Application."
},
"app_template": {
"title": "app_template",
"type": "string",
"description": "Identifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow."
},
"no_input": {
"title": "no_input",
"type": "boolean",
"description": "Disable Cookiecutter prompting and accept default values defined in the cookiecutter config."
},
"extra_context": {
"title": "extra_context",
"type": "string",
"description": "Override custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}"
},
"tracing": {
"title": "tracing",
"type": "boolean",
"description": "Enable AWS X-Ray tracing for application."
},
"application_insights": {
"title": "application_insights",
"type": "boolean",
"description": "Enable CloudWatch Application Insights monitoring for application."
},
"beta_features": {
"title": "beta_features",
"type": "boolean",
"description": "Enable/Disable beta features."
},
"debug": {
"title": "debug",
"type": "boolean",
"description": "Turn on debug logging to print debug message generated by AWS SAM CLI and display timestamps."
}
}
}
},
"required": [
Expand Down Expand Up @@ -848,9 +988,9 @@
"description": "Provide an action to determine what will happen when a stack fails to create. Three actions are available:\n\n- ROLLBACK: This will rollback a stack to a previous known good state.\n\n- DELETE: The stack will rollback to a previous state if one exists, otherwise the stack will be deleted.\n\n- DO_NOTHING: The stack will not rollback or delete, this is the same as disabling rollback.\n\nDefault behaviour is ROLLBACK.\n\n\n\nThis option is mutually exclusive with --disable-rollback/--no-disable-rollback. You can provide\n--on-failure or --disable-rollback/--no-disable-rollback but not both at the same time.",
"default": "ROLLBACK",
"enum": [
"ROLLBACK",
"DELETE",
"DO_NOTHING"
"DO_NOTHING",
"ROLLBACK"
]
},
"stack_name": {
Expand Down
11 changes: 10 additions & 1 deletion schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
PARAMS_TO_OMIT_DEFAULT_FIELD = [
"layer_cache_basedir" # sets default to root directory to that of machine the schema is generated on
]
CHARS_TO_CLEAN = [
"\b", # backspaces
"\u001b[0m", # ANSI start bold
"\u001b[1m", # ANSI end bold
]


class SchemaKeys(Enum):
Expand Down Expand Up @@ -52,6 +57,8 @@ def to_schema(self) -> Dict[str, Any]:
if self.items:
param.update({"items": {"type": self.items}})
if self.choices:
if isinstance(self.choices, list):
self.choices.sort()
param.update({"enum": self.choices})
return param

Expand Down Expand Up @@ -120,7 +127,9 @@ def clean_text(text: str) -> str:
"""Clean up a string of text to be formatted for the JSON schema."""
if not text:
return ""
return text.replace("\b", "").strip("\n").strip()
for char_to_delete in CHARS_TO_CLEAN:
text = text.replace(char_to_delete, "")
return text.strip("\n").strip()


def format_param(param: click.core.Option) -> SamCliParameterSchema:
Expand Down