code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def run(self, remote_invoke_input: RemoteInvokeExecutionInfo) -> None:
"""
Instantiates remote invoke executor with populated resource summary information, executes it with the provided
input & returns its response back to the caller. If resource is not supported by command, raises
Resou... |
Instantiates remote invoke executor with populated resource summary information, executes it with the provided
input & returns its response back to the caller. If resource is not supported by command, raises
ResourceNotSupportedForRemoteInvoke exception.
Parameters
----------
... | run | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def _populate_resource_summary(self) -> None:
"""
Populates self._resource_summary field from self._stack_name and/or self._resource_id
Either self._stack_name or self._resource_id should be defined, it fails otherwise.
If only self._stack_name is defined, it tries to find single resou... |
Populates self._resource_summary field from self._stack_name and/or self._resource_id
Either self._stack_name or self._resource_id should be defined, it fails otherwise.
If only self._stack_name is defined, it tries to find single resource in that stack,
see _get_single_resource_from_... | _populate_resource_summary | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def _get_single_resource_from_stack(self) -> CloudFormationResourceSummary:
"""
Queries all resources from stack with its type,
and returns its information if stack has only one resource from that type (including nested stacks)
"""
LOG.debug(
"Trying to get single res... |
Queries all resources from stack with its type,
and returns its information if stack has only one resource from that type (including nested stacks)
| _get_single_resource_from_stack | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def _get_from_physical_resource_id(self) -> CloudFormationResourceSummary:
"""
It first tries to parse given string as ARN and extracts the service name out of it. If it succeeds and that
service is supported, it generates CloudFormationResourceSummary out of that information
If it fail... |
It first tries to parse given string as ARN and extracts the service name out of it. If it succeeds and that
service is supported, it generates CloudFormationResourceSummary out of that information
If it fails, it tries to resolve CloudFormationResourceSummary from the physical id of the resou... | _get_from_physical_resource_id | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def stdout(self) -> StreamWriter:
"""
Returns stream writer for stdout to output Lambda function logs to
Returns
-------
samcli.lib.utils.stream_writer.StreamWriter
Stream writer for stdout
"""
stream = osutils.stdout()
return StreamWriter(str... |
Returns stream writer for stdout to output Lambda function logs to
Returns
-------
samcli.lib.utils.stream_writer.StreamWriter
Stream writer for stdout
| stdout | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def stderr(self) -> StreamWriter:
"""
Returns stream writer for stderr to output Lambda function errors to
Returns
-------
samcli.lib.utils.stream_writer.StreamWriter
Stream writer for stderr
"""
stream = osutils.stderr()
return StreamWriter(s... |
Returns stream writer for stderr to output Lambda function errors to
Returns
-------
samcli.lib.utils.stream_writer.StreamWriter
Stream writer for stderr
| stderr | python | aws/aws-sam-cli | samcli/commands/remote/remote_invoke_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/remote_invoke_context.py | Apache-2.0 |
def cli(
ctx: Context,
stack_name: str,
resource_id: str,
event: str,
event_file: TextIOWrapper,
output: RemoteInvokeOutputFormat,
test_event_name: str,
parameter: dict,
save_params: bool,
config_file: str,
config_env: str,
) -> None:
"""
`sam remote invoke` command e... |
`sam remote invoke` command entry point
| cli | python | aws/aws-sam-cli | samcli/commands/remote/invoke/cli.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/invoke/cli.py | Apache-2.0 |
def required_with_custom_error_callback(custom_error: str):
"""
It returns a callback with a custom error message when the configured option is not provided.
You shouldn't add `required=True` to the click.option for this to work correctly.
Parameters
----------
custom_error : str
Error ... |
It returns a callback with a custom error message when the configured option is not provided.
You shouldn't add `required=True` to the click.option for this to work correctly.
Parameters
----------
custom_error : str
Error message that should be thrown when the option is not provided.
| required_with_custom_error_callback | python | aws/aws-sam-cli | samcli/commands/remote/test_event/utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/utils.py | Apache-2.0 |
def not_empty_callback(ctx: click.core.Context, param: click.Option, provided_value: Any):
"""
Callback that checks that the option is not empty.
This works on an option that's already marked with `required=True`, but this enforces
that it's also not empty (Usually possible forcing an empty string like ... |
Callback that checks that the option is not empty.
This works on an option that's already marked with `required=True`, but this enforces
that it's also not empty (Usually possible forcing an empty string like `--param-name ""`)
| not_empty_callback | python | aws/aws-sam-cli | samcli/commands/remote/test_event/utils.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/utils.py | Apache-2.0 |
def cli(
ctx: Context,
stack_name: Optional[str],
name: str,
resource_id: Optional[str],
config_file: str,
config_env: str,
) -> None:
"""
`sam remote test-event delete` command entry point
"""
do_cli(
stack_name,
resource_id,
name,
ctx.region,
... |
`sam remote test-event delete` command entry point
| cli | python | aws/aws-sam-cli | samcli/commands/remote/test_event/delete/cli.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/delete/cli.py | Apache-2.0 |
def cli(
ctx: Context,
stack_name: Optional[str],
resource_id: Optional[str],
name: str,
output_file: TextIOWrapper,
config_file: str,
config_env: str,
):
"""
`sam remote test-event get` command entry point
"""
do_cli(
stack_name,
resource_id,
name,
... |
`sam remote test-event get` command entry point
| cli | python | aws/aws-sam-cli | samcli/commands/remote/test_event/get/cli.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/get/cli.py | Apache-2.0 |
def cli(
ctx: Context,
stack_name: Optional[str],
resource_id: Optional[str],
config_file: str,
config_env: str,
):
"""
`sam remote test-event get` command entry point
"""
do_cli(
stack_name,
resource_id,
ctx.region,
ctx.profile,
config_file,
... |
`sam remote test-event get` command entry point
| cli | python | aws/aws-sam-cli | samcli/commands/remote/test_event/list/cli.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/list/cli.py | Apache-2.0 |
def cli(
ctx: Context,
stack_name: Optional[str],
resource_id: Optional[str],
name: str,
file: TextIOWrapper,
force: bool,
config_file: str,
config_env: str,
):
"""
`sam remote test-event put` command entry point
"""
do_cli(
stack_name,
resource_id,
... |
`sam remote test-event put` command entry point
| cli | python | aws/aws-sam-cli | samcli/commands/remote/test_event/put/cli.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/remote/test_event/put/cli.py | Apache-2.0 |
def execute_infra_contexts(
build_context: "BuildContext",
package_context: "PackageContext",
deploy_context: "DeployContext",
sync_context: "SyncContext",
) -> InfraSyncResult:
"""Executes the sync for infra.
Parameters
----------
build_context : BuildContext
package_context : Pack... | Executes the sync for infra.
Parameters
----------
build_context : BuildContext
package_context : PackageContext
deploy_context : DeployContext
sync_context : SyncContext
Returns
-------
InfraSyncResult
Data class that contains infra sync execution result
| execute_infra_contexts | python | aws/aws-sam-cli | samcli/commands/sync/command.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/command.py | Apache-2.0 |
def execute_code_sync(
template: str,
build_context: "BuildContext",
deploy_context: "DeployContext",
sync_context: "SyncContext",
resource_ids: Optional[List[str]],
resource_types: Optional[List[str]],
auto_dependency_layer: bool,
use_built_resources: bool = False,
) -> None:
"""Exe... | Executes the sync flow for code.
Parameters
----------
template : str
Template file name
build_context : BuildContext
BuildContext
deploy_context : DeployContext
DeployContext
sync_context: SyncContext
SyncContext object that obtains sync information.
resourc... | execute_code_sync | python | aws/aws-sam-cli | samcli/commands/sync/command.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/command.py | Apache-2.0 |
def execute_watch(
template: str,
build_context: "BuildContext",
package_context: "PackageContext",
deploy_context: "DeployContext",
sync_context: "SyncContext",
auto_dependency_layer: bool,
disable_infra_syncs: bool,
watch_exclude: Dict[str, List[str]],
):
"""Start sync watch execut... | Start sync watch execution
Parameters
----------
template : str
Template file path
build_context : BuildContext
BuildContext
package_context : PackageContext
PackageContext
deploy_context : DeployContext
DeployContext
sync_context: SyncContext
SyncCon... | execute_watch | python | aws/aws-sam-cli | samcli/commands/sync/command.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/command.py | Apache-2.0 |
def check_enable_dependency_layer(template_file: str):
"""
Check if auto dependency layer should be enabled
:param template_file: template file string
:return: True if ADL should be enabled, False otherwise
"""
stacks, _ = SamLocalStackProvider.get_stacks(template_file)
for stack in stacks:
... |
Check if auto dependency layer should be enabled
:param template_file: template file string
:return: True if ADL should be enabled, False otherwise
| check_enable_dependency_layer | python | aws/aws-sam-cli | samcli/commands/sync/command.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/command.py | Apache-2.0 |
def _sync_state_to_toml_document(sync_state: SyncState) -> TOMLDocument:
"""
Writes the sync state information to the TOML file.
Parameters
-------
sync_state: SyncState
The SyncState to cache the information in the TOML file
Returns
-------
TOMLDocument
Object which wi... |
Writes the sync state information to the TOML file.
Parameters
-------
sync_state: SyncState
The SyncState to cache the information in the TOML file
Returns
-------
TOMLDocument
Object which will be dumped to the TOML file
| _sync_state_to_toml_document | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def _toml_document_to_sync_state(toml_document: Dict) -> Optional[SyncState]:
"""
Reads the cached information from the provided toml_document.
Parameters
-------
toml_document: SyncState
The toml document to read the information from
"""
if not toml_document:
return None
... |
Reads the cached information from the provided toml_document.
Parameters
-------
toml_document: SyncState
The toml document to read the information from
| _toml_document_to_sync_state | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def update_infra_sync_time(self) -> None:
"""
Updates the last infra sync time and stores it in the TOML file.
"""
with _lock:
LOG.debug("Updating latest_infra_sync_time in sync state")
self._current_state.update_infra_sync_time()
self._write() |
Updates the last infra sync time and stores it in the TOML file.
| update_infra_sync_time | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def get_latest_infra_sync_time(self) -> Optional[datetime]:
"""
Returns the time last infra sync happened.
Returns
-------
Optional[datetime]
The last infra sync time if it exists
"""
with _lock:
infra_sync_time = self._current_state.lates... |
Returns the time last infra sync happened.
Returns
-------
Optional[datetime]
The last infra sync time if it exists
| get_latest_infra_sync_time | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def update_resource_sync_state(self, resource_id: str, hash_value: str) -> None:
"""
Updates the sync_state information for the provided resource_id
to be stored in the TOML file.
Parameters
-------
resource_id: str
The resource identifier of the resource
... |
Updates the sync_state information for the provided resource_id
to be stored in the TOML file.
Parameters
-------
resource_id: str
The resource identifier of the resource
hash_value: str
The logical ID identifier of the resource
| update_resource_sync_state | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def get_resource_latest_sync_hash(self, resource_id: str) -> Optional[str]:
"""
Returns the latest hash from resource_sync_state if this information was
cached for the provided resource_id.
Parameters
-------
resource_id: str
The resource identifier of the re... |
Returns the latest hash from resource_sync_state if this information was
cached for the provided resource_id.
Parameters
-------
resource_id: str
The resource identifier of the resource
Returns
-------
Optional[str]
The hash of t... | get_resource_latest_sync_hash | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def _cleanup_build_folders(self) -> None:
"""
Cleans up build, cache and dependencies folders for clean start of the next session
"""
LOG.debug("Cleaning up build directory %s", self._build_dir)
rmtree_if_exists(self._build_dir)
LOG.debug("Cleaning up cache directory %s"... |
Cleans up build, cache and dependencies folders for clean start of the next session
| _cleanup_build_folders | python | aws/aws-sam-cli | samcli/commands/sync/sync_context.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/sync/sync_context.py | Apache-2.0 |
def generate_trace_puller(
xray_client: Any,
output: OutputOption = OutputOption.text,
) -> ObservabilityPuller:
"""
Generates puller instance with correct consumer and/or mapper configuration
Parameters
----------
xray_client : Any
boto3 xray client to be used in XRayTracePuller in... |
Generates puller instance with correct consumer and/or mapper configuration
Parameters
----------
xray_client : Any
boto3 xray client to be used in XRayTracePuller instance
output : OutputOption
Decides how the output will be presented in the console. It is been used to select corr... | generate_trace_puller | python | aws/aws-sam-cli | samcli/commands/traces/traces_puller_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/traces/traces_puller_factory.py | Apache-2.0 |
def generate_xray_event_consumer(output: OutputOption = OutputOption.text) -> ObservabilityEventConsumer:
"""
Generates consumer instance with the given variables.
If output is JSON, then it will return consumer with formatters for just JSON.
Otherwise, it will return regular text console consumer
"... |
Generates consumer instance with the given variables.
If output is JSON, then it will return consumer with formatters for just JSON.
Otherwise, it will return regular text console consumer
| generate_xray_event_consumer | python | aws/aws-sam-cli | samcli/commands/traces/traces_puller_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/traces/traces_puller_factory.py | Apache-2.0 |
def generate_xray_service_graph_consumer(output: OutputOption = OutputOption.text) -> ObservabilityEventConsumer:
"""
Generates consumer instance with the given variables.
If output is JSON, then it will return consumer with formatters for just JSON.
Otherwise, it will return regular text console consum... |
Generates consumer instance with the given variables.
If output is JSON, then it will return consumer with formatters for just JSON.
Otherwise, it will return regular text console consumer
| generate_xray_service_graph_consumer | python | aws/aws-sam-cli | samcli/commands/traces/traces_puller_factory.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/traces/traces_puller_factory.py | Apache-2.0 |
def do_cli(ctx, template, lint):
"""
Implementation of the ``cli`` method, just separated out for unit testing purposes
"""
from samtranslator.translator.managed_policy_translator import ManagedPolicyLoader
from samcli.commands.exceptions import UserException
from samcli.commands.local.cli_comm... |
Implementation of the ``cli`` method, just separated out for unit testing purposes
| do_cli | python | aws/aws-sam-cli | samcli/commands/validate/validate.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/validate/validate.py | Apache-2.0 |
def _read_sam_file(template) -> SamTemplate:
"""
Reads the file (json and yaml supported) provided and returns the dictionary representation of the file.
:param str template: Path to the template file
:return dict: Dictionary representing the SAM Template
:raises: SamTemplateNotFoundException when ... |
Reads the file (json and yaml supported) provided and returns the dictionary representation of the file.
:param str template: Path to the template file
:return dict: Dictionary representing the SAM Template
:raises: SamTemplateNotFoundException when the template file does not exist
| _read_sam_file | python | aws/aws-sam-cli | samcli/commands/validate/validate.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/validate/validate.py | Apache-2.0 |
def _lint(ctx: Context, template: str, template_path: str) -> None:
"""
Parses provided SAM template and maps errors from CloudFormation template back to SAM template.
Cfn-lint loggers are added to the SAM cli logging hierarchy which at the root logger
configures with INFO level logging and a different... |
Parses provided SAM template and maps errors from CloudFormation template back to SAM template.
Cfn-lint loggers are added to the SAM cli logging hierarchy which at the root logger
configures with INFO level logging and a different formatting. This exposes and duplicates
some cfn-lint logs that are no... | _lint | python | aws/aws-sam-cli | samcli/commands/validate/validate.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/validate/validate.py | Apache-2.0 |
def unsupported_command_cdk(alternative_command=None):
"""
Log a warning message to the user if they attempt
to use a CDK template with an unsupported sam command
Parameters
----------
alternative_command:
Alternative command to use instead of sam command
"""
def decorator(fun... |
Log a warning message to the user if they attempt
to use a CDK template with an unsupported sam command
Parameters
----------
alternative_command:
Alternative command to use instead of sam command
| unsupported_command_cdk | python | aws/aws-sam-cli | samcli/commands/_utils/cdk_support_decorators.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/cdk_support_decorators.py | Apache-2.0 |
def handle_parse_result(
self, ctx: click.Context, opts: Mapping[str, Any], args: List[str]
) -> Tuple[Any, List[str]]:
"""
Checks whether any option is in self.incompatible_params
If one is found, prompt and throw an UsageError
Then checks any combination in self.required_p... |
Checks whether any option is in self.incompatible_params
If one is found, prompt and throw an UsageError
Then checks any combination in self.required_param_lists is satisfied.
With option = "a" and required_param_lists = [["b", "c"], ["c", "d"]]
It is valid to specify --a --b -... | handle_parse_result | python | aws/aws-sam-cli | samcli/commands/_utils/click_mutex.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/click_mutex.py | Apache-2.0 |
def command_exception_handler(f, additional_mapping: Optional[Dict[Any, Callable[[Any], None]]] = None):
"""
This function returns a wrapped function definition, which handles configured exceptions gracefully
"""
def decorator_command_exception_handler(func):
@wraps(func)
def wrapper_co... |
This function returns a wrapped function definition, which handles configured exceptions gracefully
| command_exception_handler | python | aws/aws-sam-cli | samcli/commands/_utils/command_exception_handler.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/command_exception_handler.py | Apache-2.0 |
def is_experimental_enabled(config_entry: ExperimentalEntry) -> bool:
"""Whether a given experimental flag is enabled or not.
If experimentalAll is set to True, then it will always return True.
Parameters
----------
config_entry : ExperimentalEntry
Experimental flag ExperimentalEntry
R... | Whether a given experimental flag is enabled or not.
If experimentalAll is set to True, then it will always return True.
Parameters
----------
config_entry : ExperimentalEntry
Experimental flag ExperimentalEntry
Returns
-------
bool
Whether the experimental flag is enabled ... | is_experimental_enabled | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def set_experimental(config_entry: ExperimentalEntry = ExperimentalFlag.All, enabled: bool = True) -> None:
"""Set the experimental flag to enabled or disabled.
Parameters
----------
config_entry : ExperimentalEntry, optional
Flag to be set, by default ExperimentalFlag.All
enabled : bool, o... | Set the experimental flag to enabled or disabled.
Parameters
----------
config_entry : ExperimentalEntry, optional
Flag to be set, by default ExperimentalFlag.All
enabled : bool, optional
Enabled or disabled, by default True
| set_experimental | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def get_all_experimental() -> List[ExperimentalEntry]:
"""
Returns
-------
List[ExperimentalEntry]
List all experimental flags in the ExperimentalFlag class.
"""
all_experimental_flags = []
for name in dir(ExperimentalFlag):
if name.startswith("__"):
continue
... |
Returns
-------
List[ExperimentalEntry]
List all experimental flags in the ExperimentalFlag class.
| get_all_experimental | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def get_all_experimental_env_vars() -> List[str]:
"""
Returns
-------
List[str]
List all env var names of experimental flags
"""
flags = get_all_experimental()
return [flag.env_var_key for flag in flags] |
Returns
-------
List[str]
List all env var names of experimental flags
| get_all_experimental_env_vars | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def get_enabled_experimental_flags() -> List[str]:
"""
Returns a list of string, which contains enabled experimental flags for current session
Returns
-------
List[str]
List of strings which contains all enabled experimental flag names
"""
enabled_experimentals = []
for experime... |
Returns a list of string, which contains enabled experimental flags for current session
Returns
-------
List[str]
List of strings which contains all enabled experimental flag names
| get_enabled_experimental_flags | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def update_experimental_context(show_warning=True):
"""Set experimental for the current click context.
Parameters
----------
show_warning : bool, optional
Should warning be shown, by default True
"""
if not Context.get_current_context().experimental:
Context.get_current_context(... | Set experimental for the current click context.
Parameters
----------
show_warning : bool, optional
Should warning be shown, by default True
| update_experimental_context | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def _experimental_option_callback(ctx, param, enabled: Optional[bool]):
"""Click parameter callback for --beta-features or --no-beta-features.
If neither is specified, enabled will be None.
If --beta-features is set, enabled will be True,
we should turn on all experimental flags.
If --no-beta-featur... | Click parameter callback for --beta-features or --no-beta-features.
If neither is specified, enabled will be None.
If --beta-features is set, enabled will be True,
we should turn on all experimental flags.
If --no-beta-features is set, enabled will be False,
we should turn off all experimental flags... | _experimental_option_callback | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def force_experimental(
f, config_entry: ExperimentalEntry = ExperimentalFlag.All, prompt=EXPERIMENTAL_PROMPT, default=None
):
"""Decorator for adding --beta-features and --no-beta-features click options to a command.
If experimental flag env var or --beta-features flag is not specified, this will then
... | Decorator for adding --beta-features and --no-beta-features click options to a command.
If experimental flag env var or --beta-features flag is not specified, this will then
prompt the user for confirmation.
The program will exit if confirmation is denied.
| force_experimental | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def force_experimental_option(
f, option: str, config_entry: ExperimentalEntry = ExperimentalFlag.All, prompt=EXPERIMENTAL_PROMPT
):
"""Decorator for making a specific option to be experimental.
A prompt will be shown if experimental is not enabled and the option is specified.
"""
def wrap(func):
... | Decorator for making a specific option to be experimental.
A prompt will be shown if experimental is not enabled and the option is specified.
| force_experimental_option | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def prompt_experimental(
config_entry: ExperimentalEntry = ExperimentalFlag.All, prompt: str = EXPERIMENTAL_PROMPT
) -> bool:
"""Prompt the user for experimental features.
If the corresponding experimental flag is already specified, the prompt will be skipped.
If confirmation is granted, the correspondi... | Prompt the user for experimental features.
If the corresponding experimental flag is already specified, the prompt will be skipped.
If confirmation is granted, the corresponding experimental flag env var will be set.
Parameters
----------
config_entry : ExperimentalEntry, optional
Which exp... | prompt_experimental | python | aws/aws-sam-cli | samcli/commands/_utils/experimental.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/experimental.py | Apache-2.0 |
def get_or_default_template_file_name(ctx, param, provided_value, include_build):
"""
Default value for the template file name option is more complex than what Click can handle.
This method either returns user provided file name or one of the two default options (template.yaml/template.yml)
depending on... |
Default value for the template file name option is more complex than what Click can handle.
This method either returns user provided file name or one of the two default options (template.yaml/template.yml)
depending on the file that exists
:param ctx: Click Context
:param param: Param name
:pa... | get_or_default_template_file_name | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def guided_deploy_stack_name(ctx, param, provided_value):
"""
Provide a default value for stack name if invoked with a guided deploy.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, it would be the value provided by the user.
:return: Actual val... |
Provide a default value for stack name if invoked with a guided deploy.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, it would be the value provided by the user.
:return: Actual value to be used in the CLI
| guided_deploy_stack_name | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def image_repositories_callback(ctx, param, provided_value):
"""
Create an dictionary of function logical ids to ECR URIs.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by ImageRepositoriesType.
:return: dictionary of fun... |
Create an dictionary of function logical ids to ECR URIs.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by ImageRepositoriesType.
:return: dictionary of function logic ids to ECR URIs.
| image_repositories_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def remote_invoke_boto_parameter_callback(ctx, param, provided_value):
"""
Create an dictionary of boto parameters to their provided values.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by RemoteInvokeBotoApiParameterType.
... |
Create an dictionary of boto parameters to their provided values.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by RemoteInvokeBotoApiParameterType.
:return: dictionary of boto api parameters to their provided values. E.g. L... | remote_invoke_boto_parameter_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def local_add_host_callback(ctx, param, provided_value):
"""
Create a dictionary of hostnames to IP addresses to add into Docker container's hosts file.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by DockerAdditionalHostTyp... |
Create a dictionary of hostnames to IP addresses to add into Docker container's hosts file.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, after being processed by DockerAdditionalHostType.
:return: dictionary of hostnames to IP addresses.
| local_add_host_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.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 b... |
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 form... | artifact_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def resolve_s3_callback(ctx, param, provided_value, artifact, exc_set, exc_not_set):
"""
S3 Bucket is only required if there are artifacts that are all zip based.
:param ctx: Click Context
:param param: Param name
:param provided_value: Value provided by Click, it would be the value provided by the ... |
S3 Bucket is only required if there are artifacts that are all zip based.
: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.
... | resolve_s3_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def skip_prepare_infra_callback(ctx, param, provided_value):
"""
Callback for --skip-prepare-infra to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value: bool
True... |
Callback for --skip-prepare-infra to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value: bool
True if option was provided
| skip_prepare_infra_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def watch_exclude_option_callback(
ctx: click.Context, param: click.Option, values: Tuple[Dict[str, List[str]]]
) -> Dict[str, List[str]]:
"""
Parses the multiple provided values into a mapping of resources to a list of exclusions.
Parameters
----------
ctx: click.Context
The click cont... |
Parses the multiple provided values into a mapping of resources to a list of exclusions.
Parameters
----------
ctx: click.Context
The click context
param: click.Option
The parameter that was provided
values: Tuple[Dict[str, List[str]]]
A list of values that was passed i... | watch_exclude_option_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def hook_name_click_option(force_prepare=True, invalid_coexist_options=None):
"""
Click Option for hook-name option
"""
def hook_name_setup(f):
return click.option(
"--hook-name",
default=None,
type=click.STRING,
required=False,
help=f... |
Click Option for hook-name option
| hook_name_click_option | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def skip_prepare_infra_click_option():
"""
Click option to skip the hook preparation stage
"""
return click.option(
"--skip-prepare-infra/--prepare-infra",
is_flag=True,
required=False,
callback=skip_prepare_infra_callback,
help="Skip preparation stage when there ... |
Click option to skip the hook preparation stage
| skip_prepare_infra_click_option | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def terraform_plan_file_callback(ctx, param, provided_value):
"""
Callback for --terraform-plan-file to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value: bool
Tr... |
Callback for --terraform-plan-file to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value: bool
True if option was provided
| terraform_plan_file_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def terraform_project_root_path_callback(ctx, param, provided_value):
"""
Callback for --terraform-project-root-path to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value:... |
Callback for --terraform-project-root-path to check if --hook-name is also specified
Parameters
----------
ctx: click.core.Context
Click context
param: click.Option
Parameter properties
provided_value: bool
True if option was provided
| terraform_project_root_path_callback | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def generate_next_command_recommendation(command_tuples: List[Tuple[str, str]]) -> str:
"""
Generates a message containing some suggested commands to run next.
:type command_tuples: list[tuple]
:param command_tuples: list of tuples containing the command with their respective description
"""
te... |
Generates a message containing some suggested commands to run next.
:type command_tuples: list[tuple]
:param command_tuples: list of tuples containing the command with their respective description
| generate_next_command_recommendation | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def container_env_var_file_click_option(cls):
"""
Click option to --container-env-var-file option
"""
return click.option(
"--container-env-var-file",
"-ef",
default=None,
type=click.Path(), # Must be a json file
help="Environment variables json file (e.g., env_v... |
Click option to --container-env-var-file option
| container_env_var_file_click_option | python | aws/aws-sam-cli | samcli/commands/_utils/options.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/options.py | Apache-2.0 |
def process_env_var(container_env_var: Optional[Tuple[str]]) -> Dict:
"""
Parameters
----------
container_env_var : Tuple
the tuple of command line env vars received from --container-env-var flag
Each input format needs to be either function specific format (FuncName.VarName=Value)
... |
Parameters
----------
container_env_var : Tuple
the tuple of command line env vars received from --container-env-var flag
Each input format needs to be either function specific format (FuncName.VarName=Value)
or global format (VarName=Value)
Returns
-------
dictionary
... | process_env_var | python | aws/aws-sam-cli | samcli/commands/_utils/option_value_processor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/option_value_processor.py | Apache-2.0 |
def process_image_options(image_args: Optional[Tuple[str]]) -> Dict:
"""
Parameters
----------
image_args : Tuple
Tuple of command line image options in the format of
"Function1=public.ecr.aws/abc/abc:latest" or
"public.ecr.aws/abc/abc:latest"
Returns
-------
diction... |
Parameters
----------
image_args : Tuple
Tuple of command line image options in the format of
"Function1=public.ecr.aws/abc/abc:latest" or
"public.ecr.aws/abc/abc:latest"
Returns
-------
dictionary
Function as key and the corresponding image URI as value.
... | process_image_options | python | aws/aws-sam-cli | samcli/commands/_utils/option_value_processor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/option_value_processor.py | Apache-2.0 |
def _parse_key_value_pair(arg: str) -> Tuple[Optional[str], str]:
"""
Parameters
----------
arg : str
Arg in the format of "Value" or "Key=Value"
Returns
-------
key : Optional[str]
If key is not specified, None will be the key.
value : str
"""
key: Optional[str]
... |
Parameters
----------
arg : str
Arg in the format of "Value" or "Key=Value"
Returns
-------
key : Optional[str]
If key is not specified, None will be the key.
value : str
| _parse_key_value_pair | python | aws/aws-sam-cli | samcli/commands/_utils/option_value_processor.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/option_value_processor.py | Apache-2.0 |
def parameterized_option(option):
"""Meta decorator for option decorators.
This adds the ability to specify optional parameters for option decorators.
Usage:
@parameterized_option
def some_option(f, required=False)
...
@some_option
def command(...)
or
... | Meta decorator for option decorators.
This adds the ability to specify optional parameters for option decorators.
Usage:
@parameterized_option
def some_option(f, required=False)
...
@some_option
def command(...)
or
@some_option(required=True)
... | parameterized_option | python | aws/aws-sam-cli | samcli/commands/_utils/parameterized_option.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/parameterized_option.py | Apache-2.0 |
def pprint_column_names(
format_string, format_kwargs, margin=None, table_header=None, color="yellow", display_sleep=False
):
"""
:param format_string: format string to be used that has the strings, minimum width to be replaced
:param format_kwargs: dictionary that is supplied to the format_string to f... |
:param format_string: format string to be used that has the strings, minimum width to be replaced
:param format_kwargs: dictionary that is supplied to the format_string to format the string
:param margin: margin that is to be reduced from column width for columnar text.
:param table_header: Supplied t... | pprint_column_names | python | aws/aws-sam-cli | samcli/commands/_utils/table_print.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/table_print.py | Apache-2.0 |
def wrapped_text_generator(texts, width, margin, **textwrap_kwargs):
"""
Return a generator where the contents are wrapped text to a specified width.
:param texts: list of text that needs to be wrapped at specified width
:param width: width of the text to be wrapped
:param margin: margin to be red... |
Return a generator where the contents are wrapped text to a specified width.
:param texts: list of text that needs to be wrapped at specified width
:param width: width of the text to be wrapped
:param margin: margin to be reduced from width for cleaner UX
:param textwrap_kwargs: keyword arguments... | wrapped_text_generator | python | aws/aws-sam-cli | samcli/commands/_utils/table_print.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/table_print.py | Apache-2.0 |
def pprint_columns(columns, width, margin, format_string, format_args, columns_dict, color="yellow", **textwrap_kwargs):
"""
Print columns based on list of columnar text, associated formatting string and associated format arguments.
:param columns: list of columnnar text that go into columns as specified ... |
Print columns based on list of columnar text, associated formatting string and associated format arguments.
:param columns: list of columnnar text that go into columns as specified by the format_string
:param width: width of the text to be wrapped
:param margin: margin to be reduced from width for cl... | pprint_columns | python | aws/aws-sam-cli | samcli/commands/_utils/table_print.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/table_print.py | Apache-2.0 |
def get_template_data(template_file):
"""
Read the template file, parse it as JSON/YAML and return the template as a dictionary.
Parameters
----------
template_file : string
Path to the template to read
Returns
-------
Template data as a dictionary
"""
if not pathlib.P... |
Read the template file, parse it as JSON/YAML and return the template as a dictionary.
Parameters
----------
template_file : string
Path to the template to read
Returns
-------
Template data as a dictionary
| get_template_data | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def move_template(src_template_path, dest_template_path, template_dict):
"""
Move the SAM/CloudFormation template from ``src_template_path`` to ``dest_template_path``. For convenience, this
method accepts a dictionary of template data ``template_dict`` that will be written to the destination instead of
... |
Move the SAM/CloudFormation template from ``src_template_path`` to ``dest_template_path``. For convenience, this
method accepts a dictionary of template data ``template_dict`` that will be written to the destination instead of
reading from the source file.
SAM/CloudFormation template can contain certa... | move_template | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def _update_relative_paths(template_dict, original_root, new_root):
"""
SAM/CloudFormation template can contain certain properties whose value is a relative path to a local file/folder.
This path is usually relative to the template's location. If the template is being moved from original location
``orig... |
SAM/CloudFormation template can contain certain properties whose value is a relative path to a local file/folder.
This path is usually relative to the template's location. If the template is being moved from original location
``original_root`` to new location ``new_root``, use this method to update these p... | _update_relative_paths | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def _update_aws_include_relative_path(template_dict, original_root, new_root):
"""
Update relative paths in "AWS::Include" directive. This directive can be present at any part of the template,
and not just within resources.
"""
for key, val in template_dict.items():
if key == "Fn::Transform... |
Update relative paths in "AWS::Include" directive. This directive can be present at any part of the template,
and not just within resources.
| _update_aws_include_relative_path | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def _resolve_relative_to(path, original_root, new_root):
"""
If the given ``path`` is a relative path, then assume it is relative to ``original_root``. This method will
update the path to be resolve it relative to ``new_root`` and return.
Examples
-------
# Assume a file called template.txt... |
If the given ``path`` is a relative path, then assume it is relative to ``original_root``. This method will
update the path to be resolve it relative to ``new_root`` and return.
Examples
-------
# Assume a file called template.txt at location /tmp/original/root/template.txt expressed as relati... | _resolve_relative_to | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def get_template_parameters(template_file):
"""
Get Parameters from a template file.
Parameters
----------
template_file : string
Path to the template to read
Returns
-------
Template Parameters as a dictionary
"""
template_dict = get_template_data(template_file=templat... |
Get Parameters from a template file.
Parameters
----------
template_file : string
Path to the template to read
Returns
-------
Template Parameters as a dictionary
| get_template_parameters | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def get_template_artifacts_format(template_file):
"""
Get a list of template artifact formats based on PackageType wherever the underlying resource
have the actual need to be packaged.
:param template_file:
:return: list of artifact formats
"""
template_dict = get_template_data(template_fil... |
Get a list of template artifact formats based on PackageType wherever the underlying resource
have the actual need to be packaged.
:param template_file:
:return: list of artifact formats
| get_template_artifacts_format | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def get_template_function_resource_ids(template_file, artifact):
"""
Get a list of function logical ids from template file.
Function resource types include
AWS::Lambda::Function
AWS::Serverless::Function
:param template_file: template file location.
:param artifact: artifact of type ... |
Get a list of function logical ids from template file.
Function resource types include
AWS::Lambda::Function
AWS::Serverless::Function
:param template_file: template file location.
:param artifact: artifact of type IMAGE or ZIP
:return: list of artifact formats
| get_template_function_resource_ids | python | aws/aws-sam-cli | samcli/commands/_utils/template.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/commands/_utils/template.py | Apache-2.0 |
def find_resolver(self, token):
"""
Find the resolver for the appropriate token. The implementation of this function
is a direct match against a regex as the number of uses-case to be supported are less.
"""
groups = self.list_resolver_regex.findall(token)
if not groups:
... |
Find the resolver for the appropriate token. The implementation of this function
is a direct match against a regex as the number of uses-case to be supported are less.
| find_resolver | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def search(self, data):
"""
Search by applying all resolvers against structured data.
"""
for resolver in self.resolvers:
data = resolver.resolve(data)
return data |
Search by applying all resolvers against structured data.
| search | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def copytree(src, dst):
"""Modified copytree method
Note: before python3.8 there is no `dir_exists_ok` argument, therefore
this function explicitly creates one if it does not exist.
"""
if not os.path.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
src_item = os.path.j... | Modified copytree method
Note: before python3.8 there is no `dir_exists_ok` argument, therefore
this function explicitly creates one if it does not exist.
| copytree | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def find_and_copy_assets(directory_path, expression, data_object):
"""
Takes in an expression, directory_path and a json input from the standard input,
tries to find the appropriate element within the json based on the element. It then takes action to
either copy or unzip to the specified directory_path... |
Takes in an expression, directory_path and a json input from the standard input,
tries to find the appropriate element within the json based on the element. It then takes action to
either copy or unzip to the specified directory_path.
Parameters:
-----------
directory_path: str
path of... | find_and_copy_assets | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def create_backend_override():
"""
Copies and rename the override tf file from the metadata directory to the root
directory of the TF application.
"""
override_src_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), TF_BACKEND_OVERRIDE_FILENAME)
override_dest_path = os.path.join(os.... |
Copies and rename the override tf file from the metadata directory to the root
directory of the TF application.
| create_backend_override | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def validate_environment_variables():
"""
Validate that the Terraform environment variables do not contain blocked arguments.
"""
for env_var in TF_ENVIRONMENT_VARIABLES:
env_value = os.environ.get(env_var, "")
trimmed_arguments = []
# get all trimmed arguments in a list and spl... |
Validate that the Terraform environment variables do not contain blocked arguments.
| validate_environment_variables | python | aws/aws-sam-cli | samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/copy_terraform_built_artifacts.py | Apache-2.0 |
def enrich_resources_and_generate_makefile(
sam_metadata_resources: List[SamMetadataResource],
cfn_resources: Dict[str, Dict],
output_directory_path: str,
terraform_application_dir: str,
lambda_resources_to_code_map: Dict,
project_root_dir: str,
) -> None:
"""
Use the sam metadata resour... |
Use the sam metadata resources to enrich the mapped resources and to create a Makefile with a rule for
each lambda resource to be built.
Parameters
----------
sam_metadata_resources: List[SamMetadataResource]
The list of sam metadata resources defined in the terraform project.
cfn_reso... | enrich_resources_and_generate_makefile | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _enrich_zip_lambda_function(
sam_metadata_resource: Dict,
cfn_lambda_function: Dict,
cfn_lambda_function_logical_id: str,
terraform_application_dir: str,
output_directory_path: str,
project_root_dir: str,
):
"""
Use the sam metadata resources to enrich the zip lambda function.
P... |
Use the sam metadata resources to enrich the zip lambda function.
Parameters
----------
sam_metadata_resource: Dict
The sam metadata resource properties
cfn_lambda_function: dict
CloudFormation lambda function to be enriched
cfn_lambda_function_logical_id: str
the cloud... | _enrich_zip_lambda_function | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _enrich_image_lambda_function(
sam_metadata_resource: Dict,
cfn_lambda_function: Dict,
cfn_lambda_function_logical_id: str,
terraform_application_dir: str,
output_directory_path: str,
project_root_dir: str,
):
"""
Use the sam metadata resources to enrich the image lambda function.
... |
Use the sam metadata resources to enrich the image lambda function.
Parameters
----------
sam_metadata_resource: Dict
The sam metadata resource properties
cfn_lambda_function: dict
CloudFormation lambda function to be enriched
cfn_lambda_function_logical_id: str
the clo... | _enrich_image_lambda_function | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _enrich_lambda_layer(
sam_metadata_resource: Dict,
cfn_lambda_layer: Dict,
cfn_lambda_layer_logical_id: str,
terraform_application_dir: str,
output_directory_path: str,
project_root_dir: str,
) -> None:
"""
Use the sam metadata resources to enrich the lambda layer.
Parameters
... |
Use the sam metadata resources to enrich the lambda layer.
Parameters
----------
sam_metadata_resource: Dict
The sam metadata resource properties
cfn_lambda_layer: dict
CloudFormation lambda layer to be enriched
cfn_lambda_layer_logical_id: str
the cloudFormation lambda la... | _enrich_lambda_layer | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _validate_referenced_resource_layer_matches_metadata_type(
cfn_resource: dict,
sam_metadata_resource: dict,
sam_metadata_resource_address: str,
) -> None:
"""
Validate if the resource that match the resource name provided in the sam metadata resource matches the resource
type provided in the... |
Validate if the resource that match the resource name provided in the sam metadata resource matches the resource
type provided in the metadata as well.
Parameters
----------
cfn_resource: dict
The CFN resource that matches the sam metadata resource name
sam_metadata_resource: Dict
... | _validate_referenced_resource_layer_matches_metadata_type | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _get_source_code_path(
sam_metadata_resource: dict,
sam_metadata_resource_address: str,
project_root_dir: str,
src_code_property_name: str,
property_path_property_name: str,
src_code_attribute_name: str,
) -> str:
"""
Validate that sam metadata resource contains the valid metadata pr... |
Validate that sam metadata resource contains the valid metadata properties
to get a lambda function or layer source code.
Parameters
----------
sam_metadata_resource: Dict
The sam metadata resource properties
sam_metadata_resource_address: str
The sam metadata resource address
... | _get_source_code_path | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _get_relevant_cfn_resource(
sam_metadata_resource: SamMetadataResource,
cfn_resources: Dict[str, Dict],
lambda_resources_to_code_map: Dict[str, List[Tuple[Dict, str]]],
) -> List[Tuple[Dict, str]]:
"""
use the sam metadata resource name property to determine the resource address, and transform t... |
use the sam metadata resource name property to determine the resource address, and transform the address to logical
id to use it to get the cfn_resource.
If the metadata resource does not contain a resource name property, so we need to use the resource built artifact
path to find tha lambda resources t... | _get_relevant_cfn_resource | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _set_zip_metadata_resources(
resource: dict,
cfn_source_code_path: str,
output_directory_path: str,
terraform_application_dir: str,
code_property: str,
project_root_dir: str,
) -> None:
"""
Update the CloudFormation resource metadata with the enrichment properties from the TF resourc... |
Update the CloudFormation resource metadata with the enrichment properties from the TF resource
Parameters
----------
resource: dict
The CFN resource that matches the sam metadata resource name
cfn_source_code_path: dict
Absolute path location of where the original source code resi... | _set_zip_metadata_resources | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _validate_referenced_resource_matches_sam_metadata_type(
cfn_resource: dict, sam_metadata_resource: dict, sam_metadata_resource_address: str, expected_package_type: str
) -> None:
"""
Validate if the resource that match the resource name provided in the sam metadata resource matches the resource
typ... |
Validate if the resource that match the resource name provided in the sam metadata resource matches the resource
type provided in the metadata as well.
Parameters
----------
cfn_resource: dict
The CFN resource that matches the sam metadata resource name
sam_metadata_resource: Dict
... | _validate_referenced_resource_matches_sam_metadata_type | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def _get_python_command_name() -> str:
"""
Verify that python is installed and return the name of the python command
Returns
-------
str
The name of the python command installed
"""
command_names_to_try = ["python3", "py3", "python", "py"]
for command_name in command_names_to_tr... |
Verify that python is installed and return the name of the python command
Returns
-------
str
The name of the python command installed
| _get_python_command_name | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/enrich.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/enrich.py | Apache-2.0 |
def prepare(params: dict) -> dict:
"""
Prepares a terraform application for use with the SAM CLI
Parameters
----------
params: dict
Parameters of the IaC application
Returns
-------
dict
information of the generated metadata files
"""
output_dir_path = params.ge... |
Prepares a terraform application for use with the SAM CLI
Parameters
----------
params: dict
Parameters of the IaC application
Returns
-------
dict
information of the generated metadata files
| prepare | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/hook.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/hook.py | Apache-2.0 |
def _update_resources_paths(cfn_resources: Dict[str, Any], terraform_application_dir: str) -> None:
"""
As Sam Cli and terraform handles the relative paths differently. Sam Cli handles the relative paths to be relative
to the template, but terraform handles them to be relative to the project root directory.... |
As Sam Cli and terraform handles the relative paths differently. Sam Cli handles the relative paths to be relative
to the template, but terraform handles them to be relative to the project root directory. This Function purpose is
to update the CFN resources paths to be absolute paths, and change relative p... | _update_resources_paths | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/hook.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/hook.py | Apache-2.0 |
def _generate_plan_file(skip_prepare_infra: bool, terraform_application_dir: str) -> dict:
"""
Call the relevant Terraform commands to generate, load and return the Terraform plan file
which the AWS SAM CLI will then parse to extract the fields required to run local emulators.
Parameters
----------... |
Call the relevant Terraform commands to generate, load and return the Terraform plan file
which the AWS SAM CLI will then parse to extract the fields required to run local emulators.
Parameters
----------
skip_prepare_infra: bool
Flag to skip skip prepare hook if we already have the me... | _generate_plan_file | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/hook.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/hook.py | Apache-2.0 |
def _validate_environment_variables() -> None:
"""
Validate that the Terraform environment variables do not contain blocked arguments.
Raises
------
UnallowedEnvironmentVariableArgumentException
Raised when a Terraform related environment variable contains a blocked value
"""
for en... |
Validate that the Terraform environment variables do not contain blocked arguments.
Raises
------
UnallowedEnvironmentVariableArgumentException
Raised when a Terraform related environment variable contains a blocked value
| _validate_environment_variables | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/hook.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/hook.py | Apache-2.0 |
def generate_makefile_rule_for_lambda_resource(
sam_metadata_resource: SamMetadataResource,
logical_id: str,
terraform_application_dir: str,
python_command_name: str,
output_dir: str,
) -> str:
"""
Generates and returns a makefile rule for the lambda resource associated with the given sam me... |
Generates and returns a makefile rule for the lambda resource associated with the given sam metadata resource.
Parameters
----------
sam_metadata_resource: SamMetadataResource
A sam metadata resource; the generated makefile rule will correspond to building the lambda resource
associate... | generate_makefile_rule_for_lambda_resource | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def generate_makefile(
makefile_rules: List[str],
output_directory_path: str,
) -> None:
"""
Generates a makefile with the given rules in the given directory
Parameters
----------
makefile_rules: List[str]
the list of rules to write in the Makefile
output_directory_path: str
... |
Generates a makefile with the given rules in the given directory
Parameters
----------
makefile_rules: List[str]
the list of rules to write in the Makefile
output_directory_path: str
the output directory path to write the generated makefile
| generate_makefile | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def _generate_backend_override_file(output_directory_path: str):
"""
Generates an override tf file to use a temporary backend
Parameters
----------
output_directory_path: str
the output directory path to write the generated makefile
"""
statefile_filename = f"{uuid.uuid4()}.tfstate"... |
Generates an override tf file to use a temporary backend
Parameters
----------
output_directory_path: str
the output directory path to write the generated makefile
| _generate_backend_override_file | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def _build_makerule_python_command(
python_command_name: str,
output_dir: str,
resource_address: str,
sam_metadata_resource: SamMetadataResource,
terraform_application_dir: str,
) -> str:
"""
Build the Python command recipe to be used inside of the Makefile rule
Parameters
---------... |
Build the Python command recipe to be used inside of the Makefile rule
Parameters
----------
python_command_name: str
the python command name to use for running a script in the makefile recipe
output_dir: str
the directory into which the Makefile is written
resource_address: st... | _build_makerule_python_command | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def _build_jpath_string(sam_metadata_resource: SamMetadataResource, resource_address: str) -> str:
"""
Constructs the JPath string for a given sam metadata resource from the planned_values
to the build_output_path as is created by the Terraform plan output
Parameters
----------
sam_metadata_res... |
Constructs the JPath string for a given sam metadata resource from the planned_values
to the build_output_path as is created by the Terraform plan output
Parameters
----------
sam_metadata_resource: SamMetadataResource
A sam metadata resource; the generated recipe jpath will correspond to ... | _build_jpath_string | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def _get_parent_modules(module_address: Optional[str]) -> List[str]:
"""
Convert an a full Terraform resource address to a list of module
addresses from the root module to the current module
e.g. "module.level1_lambda.module.level2_lambda" as input will return
["module.level1_lambda", "module.level... |
Convert an a full Terraform resource address to a list of module
addresses from the root module to the current module
e.g. "module.level1_lambda.module.level2_lambda" as input will return
["module.level1_lambda", "module.level1_lambda.module.level2_lambda"]
Parameters
----------
module_ad... | _get_parent_modules | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/makefile_generator.py | Apache-2.0 |
def _build_code_property(tf_properties: dict, resource: TFResource) -> Any:
"""
Builds the Code property of a CloudFormation AWS Lambda Function out of the
properties of the equivalent terraform resource
Parameters
----------
tf_properties: dict
Properties of the terraform AWS Lambda fu... |
Builds the Code property of a CloudFormation AWS Lambda Function out of the
properties of the equivalent terraform resource
Parameters
----------
tf_properties: dict
Properties of the terraform AWS Lambda function resource
resource: TFResource
Configuration terraform resource
... | _build_code_property | python | aws/aws-sam-cli | samcli/hook_packages/terraform/hooks/prepare/property_builder.py | https://github.com/aws/aws-sam-cli/blob/master/samcli/hook_packages/terraform/hooks/prepare/property_builder.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.