From 01adb70ad0c033043ae9097d2472ff975cd8da87 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Tue, 18 Jul 2023 15:52:40 -0700 Subject: [PATCH 1/9] Generate init schema --- schema/samcli.json | 144 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) diff --git a/schema/samcli.json b/schema/samcli.json index d9076c0d9f..a8d10d6d91 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -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.\u001b[1m\n\nArchitectures: ['arm64', 'x86_64']\u001b[0m\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\u001b[1m\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\u001b[0m\n* package_type:\nLambda deployment package type.\u001b[1m\n\nPackage Types: Zip, Image\u001b[0m\n* base_image:\nLambda base image for deploying IMAGE based package type.\u001b[1m\n\nBase images: amazon/go1.x-base, amazon/go-provided.al2-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.7-base, amazon/ruby3.2-base, amazon/python3.8-base, amazon/python3.10-base, amazon/java17-base, amazon/dotnet6-base, amazon/java8-base, amazon/python3.11-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/ruby2.7-base, amazon/python3.9-base, amazon/java11-base\u001b[0m\n* dependency_manager:\nDependency manager for Lambda runtime.\u001b[1m\n\nDependency managers: bundler, maven, mod, gradle, npm, pip, cli-package\u001b[0m\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.\u001b[1m\n\nArchitectures: ['arm64', 'x86_64']\u001b[0m", + "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.\u001b[1m\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\u001b[0m", + "enum": [ + "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" + ] + }, + "package_type": { + "title": "package_type", + "type": "string", + "description": "Lambda deployment package type.\u001b[1m\n\nPackage Types: Zip, Image\u001b[0m", + "enum": [ + "Zip", + "Image" + ] + }, + "base_image": { + "title": "base_image", + "type": "string", + "description": "Lambda base image for deploying IMAGE based package type.\u001b[1m\n\nBase images: amazon/go1.x-base, amazon/go-provided.al2-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.7-base, amazon/ruby3.2-base, amazon/python3.8-base, amazon/python3.10-base, amazon/java17-base, amazon/dotnet6-base, amazon/java8-base, amazon/python3.11-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/ruby2.7-base, amazon/python3.9-base, amazon/java11-base\u001b[0m", + "enum": [ + "amazon/go1.x-base", + "amazon/go-provided.al2-base", + "amazon/java8.al2-base", + "amazon/nodejs18.x-base", + "amazon/nodejs12.x-base", + "amazon/python3.7-base", + "amazon/ruby3.2-base", + "amazon/python3.8-base", + "amazon/python3.10-base", + "amazon/java17-base", + "amazon/dotnet6-base", + "amazon/java8-base", + "amazon/python3.11-base", + "amazon/nodejs14.x-base", + "amazon/nodejs16.x-base", + "amazon/ruby2.7-base", + "amazon/python3.9-base", + "amazon/java11-base" + ] + }, + "dependency_manager": { + "title": "dependency_manager", + "type": "string", + "description": "Dependency manager for Lambda runtime.\u001b[1m\n\nDependency managers: bundler, maven, mod, gradle, npm, pip, cli-package\u001b[0m", + "enum": [ + "bundler", + "maven", + "mod", + "gradle", + "npm", + "pip", + "cli-package" + ] + }, + "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": [ From 0a09bacdb202f01b63c768e454763b1894a0cf79 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 11:48:24 -0700 Subject: [PATCH 2/9] Format away ANSI characters Also, add sorting to enums for consistency --- schema/samcli.json | 72 +++++++++++++++++++++++----------------------- schema/schema.py | 5 ++++ 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/schema/samcli.json b/schema/samcli.json index a8d10d6d91..9f23008515 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -23,7 +23,7 @@ "properties": { "parameters": { "title": "Parameters for the init command", - "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.\u001b[1m\n\nArchitectures: ['arm64', 'x86_64']\u001b[0m\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\u001b[1m\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\u001b[0m\n* package_type:\nLambda deployment package type.\u001b[1m\n\nPackage Types: Zip, Image\u001b[0m\n* base_image:\nLambda base image for deploying IMAGE based package type.\u001b[1m\n\nBase images: amazon/go1.x-base, amazon/go-provided.al2-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.7-base, amazon/ruby3.2-base, amazon/python3.8-base, amazon/python3.10-base, amazon/java17-base, amazon/dotnet6-base, amazon/java8-base, amazon/python3.11-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/ruby2.7-base, amazon/python3.9-base, amazon/java11-base\u001b[0m\n* dependency_manager:\nDependency manager for Lambda runtime.\u001b[1m\n\nDependency managers: bundler, maven, mod, gradle, npm, pip, cli-package\u001b[0m\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.", + "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/python3.9-base, amazon/nodejs18.x-base, amazon/go-provided.al2-base, amazon/python3.10-base, amazon/java8.al2-base, amazon/ruby2.7-base, amazon/python3.11-base, amazon/dotnet6-base, amazon/python3.7-base, amazon/go1.x-base, amazon/java11-base, amazon/nodejs12.x-base, amazon/java17-base, amazon/java8-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/python3.8-base, amazon/ruby3.2-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: gradle, cli-package, pip, npm, mod, bundler, maven\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": { "no_interactive": { @@ -34,7 +34,7 @@ "architecture": { "title": "architecture", "type": "string", - "description": "Architectures for Lambda functions.\u001b[1m\n\nArchitectures: ['arm64', 'x86_64']\u001b[0m", + "description": "Architectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']", "enum": [ "arm64", "x86_64" @@ -48,75 +48,75 @@ "runtime": { "title": "runtime", "type": "string", - "description": "Lambda runtime for application.\u001b[1m\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\u001b[0m", + "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", - "java17", "java11", - "java8.al2", + "java17", "java8", - "nodejs18.x", - "nodejs16.x", - "nodejs14.x", + "java8.al2", "nodejs12.x", + "nodejs14.x", + "nodejs16.x", + "nodejs18.x", "provided", "provided.al2", - "python3.9", - "python3.8", - "python3.7", - "python3.11", "python3.10", - "ruby3.2", - "ruby2.7" + "python3.11", + "python3.7", + "python3.8", + "python3.9", + "ruby2.7", + "ruby3.2" ] }, "package_type": { "title": "package_type", "type": "string", - "description": "Lambda deployment package type.\u001b[1m\n\nPackage Types: Zip, Image\u001b[0m", + "description": "Lambda deployment package type.\n\nPackage Types: Zip, Image", "enum": [ - "Zip", - "Image" + "Image", + "Zip" ] }, "base_image": { "title": "base_image", "type": "string", - "description": "Lambda base image for deploying IMAGE based package type.\u001b[1m\n\nBase images: amazon/go1.x-base, amazon/go-provided.al2-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.7-base, amazon/ruby3.2-base, amazon/python3.8-base, amazon/python3.10-base, amazon/java17-base, amazon/dotnet6-base, amazon/java8-base, amazon/python3.11-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/ruby2.7-base, amazon/python3.9-base, amazon/java11-base\u001b[0m", + "description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/python3.9-base, amazon/nodejs18.x-base, amazon/go-provided.al2-base, amazon/python3.10-base, amazon/java8.al2-base, amazon/ruby2.7-base, amazon/python3.11-base, amazon/dotnet6-base, amazon/python3.7-base, amazon/go1.x-base, amazon/java11-base, amazon/nodejs12.x-base, amazon/java17-base, amazon/java8-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/python3.8-base, amazon/ruby3.2-base", "enum": [ - "amazon/go1.x-base", + "amazon/dotnet6-base", "amazon/go-provided.al2-base", - "amazon/java8.al2-base", - "amazon/nodejs18.x-base", - "amazon/nodejs12.x-base", - "amazon/python3.7-base", - "amazon/ruby3.2-base", - "amazon/python3.8-base", - "amazon/python3.10-base", + "amazon/go1.x-base", + "amazon/java11-base", "amazon/java17-base", - "amazon/dotnet6-base", "amazon/java8-base", - "amazon/python3.11-base", + "amazon/java8.al2-base", + "amazon/nodejs12.x-base", "amazon/nodejs14.x-base", "amazon/nodejs16.x-base", - "amazon/ruby2.7-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/java11-base" + "amazon/ruby2.7-base", + "amazon/ruby3.2-base" ] }, "dependency_manager": { "title": "dependency_manager", "type": "string", - "description": "Dependency manager for Lambda runtime.\u001b[1m\n\nDependency managers: bundler, maven, mod, gradle, npm, pip, cli-package\u001b[0m", + "description": "Dependency manager for Lambda runtime.\n\nDependency managers: gradle, cli-package, pip, npm, mod, bundler, maven", "enum": [ "bundler", + "cli-package", + "gradle", "maven", "mod", - "gradle", "npm", - "pip", - "cli-package" + "pip" ] }, "output_dir": { @@ -443,9 +443,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": { diff --git a/schema/schema.py b/schema/schema.py index 3472bd8b7a..8109722681 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -5,6 +5,7 @@ import json from dataclasses import dataclass from enum import Enum +import re from typing import Any, Dict, List, Optional import click @@ -44,6 +45,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 @@ -112,6 +115,8 @@ def clean_text(text: str) -> str: """Clean up a string of text to be formatted for the JSON schema.""" if not text: return "" + ansi_regex = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') + text = ansi_regex.sub("", text) return text.replace("\b", "").strip("\n").strip() From a7739206d5865a69b8ad2def655d6346f8cd0f63 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 12:00:54 -0700 Subject: [PATCH 3/9] Sort import block to satisfy linter --- schema/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/schema.py b/schema/schema.py index 8109722681..cbdbdf696d 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -3,9 +3,9 @@ import importlib import json +import re from dataclasses import dataclass from enum import Enum -import re from typing import Any, Dict, List, Optional import click From cd9c85b5a68ce8e9f75c8e8b3b389bfc1f41c575 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 13:25:36 -0700 Subject: [PATCH 4/9] make format --- schema/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/schema.py b/schema/schema.py index cbdbdf696d..be38230ebb 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -115,7 +115,7 @@ def clean_text(text: str) -> str: """Clean up a string of text to be formatted for the JSON schema.""" if not text: return "" - ansi_regex = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') + ansi_regex = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") text = ansi_regex.sub("", text) return text.replace("\b", "").strip("\n").strip() From 68c60eedde254f06adfff9112ea9652b51bd6464 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 13:38:43 -0700 Subject: [PATCH 5/9] Regenerate schema --- schema/samcli.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/schema/samcli.json b/schema/samcli.json index dabf9a5f57..09a49fc0fb 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -23,7 +23,7 @@ "properties": { "parameters": { "title": "Parameters for the init command", - "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/python3.9-base, amazon/nodejs18.x-base, amazon/go-provided.al2-base, amazon/python3.10-base, amazon/java8.al2-base, amazon/ruby2.7-base, amazon/python3.11-base, amazon/dotnet6-base, amazon/python3.7-base, amazon/go1.x-base, amazon/java11-base, amazon/nodejs12.x-base, amazon/java17-base, amazon/java8-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/python3.8-base, amazon/ruby3.2-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: gradle, cli-package, pip, npm, mod, bundler, maven\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.", + "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/go1.x-base, amazon/java8-base, amazon/python3.10-base, amazon/python3.8-base, amazon/java17-base, amazon/java11-base, amazon/python3.7-base, amazon/go-provided.al2-base, amazon/nodejs14.x-base, amazon/dotnet6-base, amazon/ruby2.7-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.11-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/nodejs16.x-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: cli-package, pip, mod, npm, maven, bundler, gradle\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": { "no_interactive": { @@ -83,7 +83,7 @@ "base_image": { "title": "base_image", "type": "string", - "description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/python3.9-base, amazon/nodejs18.x-base, amazon/go-provided.al2-base, amazon/python3.10-base, amazon/java8.al2-base, amazon/ruby2.7-base, amazon/python3.11-base, amazon/dotnet6-base, amazon/python3.7-base, amazon/go1.x-base, amazon/java11-base, amazon/nodejs12.x-base, amazon/java17-base, amazon/java8-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/python3.8-base, amazon/ruby3.2-base", + "description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/go1.x-base, amazon/java8-base, amazon/python3.10-base, amazon/python3.8-base, amazon/java17-base, amazon/java11-base, amazon/python3.7-base, amazon/go-provided.al2-base, amazon/nodejs14.x-base, amazon/dotnet6-base, amazon/ruby2.7-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.11-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/nodejs16.x-base", "enum": [ "amazon/dotnet6-base", "amazon/go-provided.al2-base", @@ -108,7 +108,7 @@ "dependency_manager": { "title": "dependency_manager", "type": "string", - "description": "Dependency manager for Lambda runtime.\n\nDependency managers: gradle, cli-package, pip, npm, mod, bundler, maven", + "description": "Dependency manager for Lambda runtime.\n\nDependency managers: cli-package, pip, mod, npm, maven, bundler, gradle", "enum": [ "bundler", "cli-package", @@ -472,7 +472,7 @@ "properties": { "parameters": { "title": "Parameters for the local start api command", - "description": "Available parameters for the local start api command:\n* hook_name:\nHook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']\n* skip_prepare_infra:\nSkip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name.\n* host:\nLocal hostname or IP address to bind to (default: '127.0.0.1')\n* port:\nLocal port number to listen on (default: '3000')\n* static_dir:\nAny static assets (e.g. CSS/Javascript/HTML) files located in this directory will be presented at /\n* template_file:\nAWS SAM template which references built artifacts for resources in the template. (if applicable)\n* env_vars:\nJSON file containing values for Lambda function's environment variables.\n* parameter_overrides:\nString that contains AWS CloudFormation parameter overrides encoded as key=value pairs.\n* debug_port:\nWhen specified, Lambda function container will start in debug mode and will expose this port on localhost.\n* debugger_path:\nHost path to a debugger that will be mounted into the Lambda container.\n* debug_args:\nAdditional arguments to be passed to the debugger.\n* container_env_vars:\nJSON file containing environment variables to be set within the container environment\n* docker_volume_basedir:\nSpecify the location basedir where the SAM template exists. If Docker is running on a remote machine, Path of the SAM template must be mounted on the Docker machine and modified to match the remote machine.\n* log_file:\nFile to capture output logs.\n* layer_cache_basedir:\nSpecify the location basedir where the lambda layers used by the template will be downloaded to.\n* skip_pull_image:\nSkip pulling down the latest Docker image for Lambda runtime.\n* docker_network:\nName or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network.\n* force_image_build:\nForce rebuilding the image used for invoking functions with layers.\n* warm_containers:\nOptional. Specifies how AWS SAM CLI manages \ncontainers for each function.\nTwo modes are available:\nEAGER: Containers for all functions are \nloaded at startup and persist between \ninvocations.\nLAZY: Containers are only loaded when each \nfunction is first invoked. Those containers \npersist for additional invocations.\n* debug_function:\nOptional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args.\n* shutdown:\nEmulate a shutdown event after invoke completes, to test extension handling of shutdown behavior.\n* container_host:\nHost of locally emulated Lambda container. This option is useful when the container runs on a different host than AWS SAM CLI. For example, if one wants to run AWS SAM CLI in a Docker container on macOS, this option could specify `host.docker.internal`\n* container_host_interface:\nIP address of the host network interface that container ports should bind to. Use 0.0.0.0 to bind to all interfaces.\n* invoke_image:\nContainer image URIs for invoking functions or starting api and function. One can specify the image URI used for the local function invocation (--invoke-image public.ecr.aws/sam/build-nodejs14.x:latest). One can also specify for each individual function with (--invoke-image Function1=public.ecr.aws/sam/build-nodejs14.x:latest). If a function does not have invoke image specified, the default AWS SAM CLI emulation image will be used.\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.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", + "description": "Available parameters for the local start api command:\n* hook_name:\nHook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']\n* skip_prepare_infra:\nSkip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name.\n* host:\nLocal hostname or IP address to bind to (default: '127.0.0.1')\n* port:\nLocal port number to listen on (default: '3000')\n* static_dir:\nAny static assets (e.g. CSS/Javascript/HTML) files located in this directory will be presented at /\n* template_file:\nAWS SAM template which references built artifacts for resources in the template. (if applicable)\n* env_vars:\nJSON file containing values for Lambda function's environment variables.\n* parameter_overrides:\nString that contains AWS CloudFormation parameter overrides encoded as key=value pairs.\n* debug_port:\nWhen specified, Lambda function container will start in debug mode and will expose this port on localhost.\n* debugger_path:\nHost path to a debugger that will be mounted into the Lambda container.\n* debug_args:\nAdditional arguments to be passed to the debugger.\n* container_env_vars:\nJSON file containing environment variables to be set within the container environment\n* docker_volume_basedir:\nSpecify the location basedir where the SAM template exists. If Docker is running on a remote machine, Path of the SAM template must be mounted on the Docker machine and modified to match the remote machine.\n* log_file:\nFile to capture output logs.\n* layer_cache_basedir:\nSpecify the location basedir where the lambda layers used by the template will be downloaded to.\n* skip_pull_image:\nSkip pulling down the latest Docker image for Lambda runtime.\n* docker_network:\nName or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network.\n* force_image_build:\nForce rebuilding the image used for invoking functions with layers.\n* warm_containers:\nOptional. Specifies how AWS SAM CLI manages \ncontainers for each function.\nTwo modes are available:\nEAGER: Containers for all functions are \nloaded at startup and persist between \ninvocations.\nLAZY: Containers are only loaded when each \nfunction is first invoked. Those containers \npersist for additional invocations.\n* debug_function:\nOptional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args.\n* shutdown:\nEmulate a shutdown event after invoke completes, to test extension handling of shutdown behavior.\n* container_host:\nHost of locally emulated Lambda container. This option is useful when the container runs on a different host than AWS SAM CLI. For example, if one wants to run AWS SAM CLI in a Docker container on macOS, this option could specify `host.docker.internal`\n* container_host_interface:\nIP address of the host network interface that container ports should bind to. Use 0.0.0.0 to bind to all interfaces.\n* invoke_image:\nContainer image URIs for invoking functions or starting api and function. One can specify the image URI used for the local function invocation (--invoke-image public.ecr.aws/sam/build-nodejs14.x:latest). One can also specify for each individual function with (--invoke-image Function1=public.ecr.aws/sam/build-nodejs14.x:latest). If a function does not have invoke image specified, the default AWS SAM CLI emulation image will be used.\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.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", "type": "object", "properties": { "hook_name": { @@ -581,7 +581,7 @@ "debug_function": { "title": "debug_function", "type": "string", - "description": "Optional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args." + "description": "Optional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args." }, "shutdown": { "title": "shutdown", @@ -653,7 +653,7 @@ "properties": { "parameters": { "title": "Parameters for the local start lambda command", - "description": "Available parameters for the local start lambda command:\n* hook_name:\nHook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']\n* skip_prepare_infra:\nSkip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name.\n* host:\nLocal hostname or IP address to bind to (default: '127.0.0.1')\n* port:\nLocal port number to listen on (default: '3001')\n* template_file:\nAWS SAM template which references built artifacts for resources in the template. (if applicable)\n* env_vars:\nJSON file containing values for Lambda function's environment variables.\n* parameter_overrides:\nString that contains AWS CloudFormation parameter overrides encoded as key=value pairs.\n* debug_port:\nWhen specified, Lambda function container will start in debug mode and will expose this port on localhost.\n* debugger_path:\nHost path to a debugger that will be mounted into the Lambda container.\n* debug_args:\nAdditional arguments to be passed to the debugger.\n* container_env_vars:\nJSON file containing environment variables to be set within the container environment\n* docker_volume_basedir:\nSpecify the location basedir where the SAM template exists. If Docker is running on a remote machine, Path of the SAM template must be mounted on the Docker machine and modified to match the remote machine.\n* log_file:\nFile to capture output logs.\n* layer_cache_basedir:\nSpecify the location basedir where the lambda layers used by the template will be downloaded to.\n* skip_pull_image:\nSkip pulling down the latest Docker image for Lambda runtime.\n* docker_network:\nName or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network.\n* force_image_build:\nForce rebuilding the image used for invoking functions with layers.\n* warm_containers:\nOptional. Specifies how AWS SAM CLI manages \ncontainers for each function.\nTwo modes are available:\nEAGER: Containers for all functions are \nloaded at startup and persist between \ninvocations.\nLAZY: Containers are only loaded when each \nfunction is first invoked. Those containers \npersist for additional invocations.\n* debug_function:\nOptional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args.\n* shutdown:\nEmulate a shutdown event after invoke completes, to test extension handling of shutdown behavior.\n* container_host:\nHost of locally emulated Lambda container. This option is useful when the container runs on a different host than AWS SAM CLI. For example, if one wants to run AWS SAM CLI in a Docker container on macOS, this option could specify `host.docker.internal`\n* container_host_interface:\nIP address of the host network interface that container ports should bind to. Use 0.0.0.0 to bind to all interfaces.\n* invoke_image:\nContainer image URIs for invoking functions or starting api and function. One can specify the image URI used for the local function invocation (--invoke-image public.ecr.aws/sam/build-nodejs14.x:latest). One can also specify for each individual function with (--invoke-image Function1=public.ecr.aws/sam/build-nodejs14.x:latest). If a function does not have invoke image specified, the default AWS SAM CLI emulation image will be used.\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.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", + "description": "Available parameters for the local start lambda command:\n* hook_name:\nHook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']\n* skip_prepare_infra:\nSkip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name.\n* host:\nLocal hostname or IP address to bind to (default: '127.0.0.1')\n* port:\nLocal port number to listen on (default: '3001')\n* template_file:\nAWS SAM template which references built artifacts for resources in the template. (if applicable)\n* env_vars:\nJSON file containing values for Lambda function's environment variables.\n* parameter_overrides:\nString that contains AWS CloudFormation parameter overrides encoded as key=value pairs.\n* debug_port:\nWhen specified, Lambda function container will start in debug mode and will expose this port on localhost.\n* debugger_path:\nHost path to a debugger that will be mounted into the Lambda container.\n* debug_args:\nAdditional arguments to be passed to the debugger.\n* container_env_vars:\nJSON file containing environment variables to be set within the container environment\n* docker_volume_basedir:\nSpecify the location basedir where the SAM template exists. If Docker is running on a remote machine, Path of the SAM template must be mounted on the Docker machine and modified to match the remote machine.\n* log_file:\nFile to capture output logs.\n* layer_cache_basedir:\nSpecify the location basedir where the lambda layers used by the template will be downloaded to.\n* skip_pull_image:\nSkip pulling down the latest Docker image for Lambda runtime.\n* docker_network:\nName or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network.\n* force_image_build:\nForce rebuilding the image used for invoking functions with layers.\n* warm_containers:\nOptional. Specifies how AWS SAM CLI manages \ncontainers for each function.\nTwo modes are available:\nEAGER: Containers for all functions are \nloaded at startup and persist between \ninvocations.\nLAZY: Containers are only loaded when each \nfunction is first invoked. Those containers \npersist for additional invocations.\n* debug_function:\nOptional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args.\n* shutdown:\nEmulate a shutdown event after invoke completes, to test extension handling of shutdown behavior.\n* container_host:\nHost of locally emulated Lambda container. This option is useful when the container runs on a different host than AWS SAM CLI. For example, if one wants to run AWS SAM CLI in a Docker container on macOS, this option could specify `host.docker.internal`\n* container_host_interface:\nIP address of the host network interface that container ports should bind to. Use 0.0.0.0 to bind to all interfaces.\n* invoke_image:\nContainer image URIs for invoking functions or starting api and function. One can specify the image URI used for the local function invocation (--invoke-image public.ecr.aws/sam/build-nodejs14.x:latest). One can also specify for each individual function with (--invoke-image Function1=public.ecr.aws/sam/build-nodejs14.x:latest). If a function does not have invoke image specified, the default AWS SAM CLI emulation image will be used.\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.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)", "type": "object", "properties": { "hook_name": { @@ -756,7 +756,7 @@ "debug_function": { "title": "debug_function", "type": "string", - "description": "Optional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args." + "description": "Optional. Specifies the Lambda Function logicalId to apply debug options to when --warm-containers is specified. This parameter applies to --debug-port, --debugger-path, and --debug-args." }, "shutdown": { "title": "shutdown", From 1d208bb2ac9512e89a29b38fb76d669bbc74585a Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 14:59:20 -0700 Subject: [PATCH 6/9] Regenerate schema and add sorting logic --- samcli/local/common/runtime_template.py | 18 ++++++++++-------- schema/samcli.json | 6 +++--- schema/schema.py | 12 ++++++------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py index 707ea0f3f3..c999e33982 100644 --- a/samcli/local/common/runtime_template.py +++ b/samcli/local/common/runtime_template.py @@ -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") + } + ) ) ) @@ -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 diff --git a/schema/samcli.json b/schema/samcli.json index d9c9636e9d..6bc0586be5 100644 --- a/schema/samcli.json +++ b/schema/samcli.json @@ -23,7 +23,7 @@ "properties": { "parameters": { "title": "Parameters for the init command", - "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/go1.x-base, amazon/java8-base, amazon/python3.10-base, amazon/python3.8-base, amazon/java17-base, amazon/java11-base, amazon/python3.7-base, amazon/go-provided.al2-base, amazon/nodejs14.x-base, amazon/dotnet6-base, amazon/ruby2.7-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.11-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/nodejs16.x-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: cli-package, pip, mod, npm, maven, bundler, gradle\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.", + "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": { "no_interactive": { @@ -83,7 +83,7 @@ "base_image": { "title": "base_image", "type": "string", - "description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/go1.x-base, amazon/java8-base, amazon/python3.10-base, amazon/python3.8-base, amazon/java17-base, amazon/java11-base, amazon/python3.7-base, amazon/go-provided.al2-base, amazon/nodejs14.x-base, amazon/dotnet6-base, amazon/ruby2.7-base, amazon/java8.al2-base, amazon/nodejs18.x-base, amazon/nodejs12.x-base, amazon/python3.11-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/nodejs16.x-base", + "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", @@ -108,7 +108,7 @@ "dependency_manager": { "title": "dependency_manager", "type": "string", - "description": "Dependency manager for Lambda runtime.\n\nDependency managers: cli-package, pip, mod, npm, maven, bundler, gradle", + "description": "Dependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip", "enum": [ "bundler", "cli-package", diff --git a/schema/schema.py b/schema/schema.py index 9eca300292..81d27513ab 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -74,12 +74,12 @@ class SamCliCommandSchema: def to_schema(self) -> dict: """Return the JSON schema representation of the SAM CLI command.""" COMMANDS_TO_EXCLUDE = [ # TEMPORARY: for use only while generating piece-by-piece - "deploy", - "build", - "local", - "validate", - "package", - "init", + # "deploy", + # "build", + # "local", + # "validate", + # "package", + # "init", "delete", "bootstrap", "list", From 87c76182e9b9c31ab0d257cacedc1e6aca706935 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 15:02:06 -0700 Subject: [PATCH 7/9] Uncomment excluded commands --- schema/schema.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/schema/schema.py b/schema/schema.py index 81d27513ab..9eca300292 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -74,12 +74,12 @@ class SamCliCommandSchema: def to_schema(self) -> dict: """Return the JSON schema representation of the SAM CLI command.""" COMMANDS_TO_EXCLUDE = [ # TEMPORARY: for use only while generating piece-by-piece - # "deploy", - # "build", - # "local", - # "validate", - # "package", - # "init", + "deploy", + "build", + "local", + "validate", + "package", + "init", "delete", "bootstrap", "list", From 7f05a9c94a253a8eaf860ba03742da05e1442ea1 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 15:20:56 -0700 Subject: [PATCH 8/9] Move ANSI regex to root --- schema/schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schema/schema.py b/schema/schema.py index 9eca300292..24438b6788 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -20,6 +20,7 @@ PARAMS_TO_OMIT_DEFAULT_FIELD = [ "layer_cache_basedir" # sets default to root directory to that of machine the schema is generated on ] +ANSI_REGEX = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") class SchemaKeys(Enum): @@ -123,8 +124,7 @@ def clean_text(text: str) -> str: """Clean up a string of text to be formatted for the JSON schema.""" if not text: return "" - ansi_regex = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") - text = ansi_regex.sub("", text) + text = ANSI_REGEX.sub("", text) return text.replace("\b", "").strip("\n").strip() From 1d9eeeea266cafa4959234c7abf8a3c3ea965641 Mon Sep 17 00:00:00 2001 From: Leonardo Gama Date: Thu, 20 Jul 2023 17:13:16 -0700 Subject: [PATCH 9/9] Replace regex with easier, more readable replacement --- schema/schema.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/schema/schema.py b/schema/schema.py index 24438b6788..ee95b25612 100644 --- a/schema/schema.py +++ b/schema/schema.py @@ -3,7 +3,6 @@ import importlib import json -import re from dataclasses import dataclass from enum import Enum from typing import Any, Dict, List, Optional @@ -20,7 +19,11 @@ PARAMS_TO_OMIT_DEFAULT_FIELD = [ "layer_cache_basedir" # sets default to root directory to that of machine the schema is generated on ] -ANSI_REGEX = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])") +CHARS_TO_CLEAN = [ + "\b", # backspaces + "\u001b[0m", # ANSI start bold + "\u001b[1m", # ANSI end bold +] class SchemaKeys(Enum): @@ -124,8 +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 "" - text = ANSI_REGEX.sub("", text) - 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: