Skip to content

Commit

Permalink
Merge from aws/aws-sam-cli/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-sam-cli-bot authored Nov 24, 2021
2 parents 5621ff3 + 1fe8d30 commit c6f5bc4
Show file tree
Hide file tree
Showing 77 changed files with 1,351 additions and 341 deletions.
71 changes: 71 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
area/package:
- samcli/commands/package/*
- samcli/commands/package/**/*

area/local/invoke:
- samcli/commands/local/invoke/*
- samcli/commands/local/invoke/**/*
- samcli/local/*
- samcli/local/**/*

area/pipeline:
- samcli/commands/pipeline/*
- samcli/commands/pipeline/**/*

area/deploy:
- samcli/commands/deploy/*
- samcli/commands/deploy/**/*

area/local/start-api:
- samcli/commands/local/start-api/*
- samcli/commands/local/start-api/**/*
- samcli/local/*
- samcli/local/**/*

area/local/start-invoke:
- samcli/commands/local/start-invoke/*
- samcli/commands/local/start-invoke/**/*
- samcli/local/*
- samcli/local/**/*

area/local/generate-event:
- samcli/commands/local/generate-event/*
- samcli/commands/local/generate-event/**/*

area/init:
- samcli/commands/init/*
- samcli/commands/init/**/*

area/delete:
- samcli/commands/delete/*
- samcli/commands/delete/**/*

area/integration-tests:
- test/integration/*
- test/integration/**/*

area/publish:
- samcli/commands/publish/*
- samcli/commands/publish/**/*

area/sync:
- samcli/commands/sync/*
- samcli/commands/sync/**/*

area/validate:
- samcli/commands/validate/*
- samcli/commands/validate/**/*

area/build:
- samcli/commands/build/*
- samcli/commands/build/**/*
- samcli/lib/build/*
- samcli/lib/build/**/*

area/logs:
- samcli/commands/logs/*
- samcli/commands/logs/**/*

area/traces:
- samcli/commands/traces/*
- samcli/commands/traces/**/*
8 changes: 8 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This folder has Github Actions for this repo.

** pr-labler **

This is responsible for tagging our prs automattically. The primary thing it does is tags internal vs external (to the team) PRs. It will
also tag PRs with `area/*` tags based upon the files being changes in the PR. This is run on `pull_request_target` which only runs what is
in the repo not what is in the Pull Request. This is done to help guard against a PR running and changing. For this, the Action should NEVER
download or checkout the PR. It is purely for tagging/labeling not CI.
39 changes: 39 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]

jobs:
apply-file-based-labels:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
apply-internal-external-label:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const maintainers = ['jfuss', 'c2tarun', 'hoffa', 'awood45', 'CoshUS', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', 'wchengru', 'mingkun2020', 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1']
if (maintainers.includes(context.payload.sender.login)) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['pr/internal']
})
} else {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['pr/external']
})
}
2 changes: 1 addition & 1 deletion designs/resource_metadata_overriding.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ customers using AWS Cloud Development Kit (CDK).
What is the problem?
--------------------

Customers have different ways to define their AWS Resources. As of writing (Jan. 2109),
Customers have different ways to define their AWS Resources. As of writing (Jan. 2019),
SAM CLI supports the use case of defining an application in CloudFormation/SAM (a super
set of CloudFormation). These CloudFormation/SAM applications are written in `json` or `yaml`
and deployed through AWS CloudFormation. Frameworks like CDK offer customers an alternative
Expand Down
3 changes: 3 additions & 0 deletions installer/pyinstaller/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ echo "Copying Source"
cp -r ../[!.]* ./src
cp -r ./src/* ./output/aws-sam-cli-src

echo "Removing CI Scripts"
rm -vf ./output/aws-sam-cli-src/appveyor*.yml

echo "Installing Python"
curl "https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz" --output python.tgz
tar -xzf python.tgz
Expand Down
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ chevron~=0.12
click~=7.1
Flask~=1.1.2
#Need to add Schemas latest SDK.
boto3~=1.18
boto3>=1.18.32,==1.*
jmespath~=0.10.0
PyYAML~=5.3
cookiecutter~=1.7.2
aws-sam-translator==1.40.0
aws-sam-translator==1.42.0
#docker minor version updates can include breaking changes. Auto update micro version only.
docker~=4.2.0
dateparser~=1.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pytest-timeout==1.4.2
pytest-rerunfailures==9.1.1

# formatter
black==20.8b1
black==21.10b0
8 changes: 4 additions & 4 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ aws-lambda-builders==1.9.0 \
--hash=sha256:335966e9dc19ab37ad9a600dbcf90ecb8d47f1fcffbf83ef6eebe61fcbdd6731 \
--hash=sha256:742a67123dc0ea91983e7a6947dad0f23dff9c958a28da46162ee675ae257273
# via aws-sam-cli (setup.py)
aws-sam-translator==1.40.0 \
--hash=sha256:99e3b80c2ca4f6f67c9bcfa757ba9f30eee9716a4a93d698a581476dc9945307 \
--hash=sha256:ae52c5941048ea7e4a2fd268dbd5d34a133e128913a641f41c9360f6d77b05c3 \
--hash=sha256:bc7dbda72526763049a156a9bfdda9a2529d0a0a4ac670c1158980f6aee33dfd
aws-sam-translator==1.42.0 \
--hash=sha256:31875e4f639511f506d0c757a2a50756bd846440724079e867aafb12c534ac23 \
--hash=sha256:4f5d3d5d0567fe728e75c5c8dff599f7c88313b3b8e85b9b17a2c00cb046b2e4 \
--hash=sha256:8a7976c0ee2fca004a590e17d3551a49c8d8ba14ed0cb3674ea270d41d0dcd5b
# via aws-sam-cli (setup.py)
backports.zoneinfo==0.2.1 \
--hash=sha256:17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf \
Expand Down
2 changes: 1 addition & 1 deletion samcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
SAM CLI version
"""

__version__ = "1.35.0"
__version__ = "1.36.0"
7 changes: 4 additions & 3 deletions samcli/commands/_utils/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def disable_all_experimental():
set_experimental(entry, False)


def _update_experimental_context(show_warning=True):
def update_experimental_context(show_warning=True):
"""Set experimental for the current click context.
Parameters
Expand All @@ -135,6 +135,7 @@ def _experimental_option_callback(ctx, param, enabled: Optional[bool]):

if enabled:
set_experimental(ExperimentalFlag.All, True)
update_experimental_context()
else:
disable_all_experimental()

Expand Down Expand Up @@ -172,7 +173,6 @@ def wrap(func):
def wrapped_func(*args, **kwargs):
if not prompt_experimental(config_entry=config_entry, prompt=prompt):
sys.exit(1)
_update_experimental_context()
return func(*args, **kwargs)

return wrapped_func
Expand All @@ -194,7 +194,6 @@ def wrapped_func(*args, **kwargs):
if kwargs[option]:
if not prompt_experimental(config_entry=config_entry, prompt=prompt):
sys.exit(1)
_update_experimental_context()
return func(*args, **kwargs)

return wrapped_func
Expand Down Expand Up @@ -222,8 +221,10 @@ def prompt_experimental(
Whether user have accepted the experimental feature.
"""
if is_experimental_enabled(config_entry):
update_experimental_context()
return True
confirmed = click.confirm(prompt, default=False)
if confirmed:
set_experimental(config_entry=config_entry, enabled=True)
update_experimental_context()
return confirmed
98 changes: 98 additions & 0 deletions samcli/commands/_utils/option_value_processor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""
Parsing utilities commonly used to process information for commands
"""
import logging
from typing import Optional, Dict, Tuple

from samcli.commands.exceptions import InvalidImageException

LOG = logging.getLogger(__name__)


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)
or global format (VarName=Value)
Returns
-------
dictionary
Processed command line environment variables
"""
processed_env_vars: Dict = {}

if container_env_var:
for env_var in container_env_var:
location_key = "Parameters"

env_var_name, value = _parse_key_value_pair(env_var)

if not env_var_name or not value:
LOG.error("Invalid command line --container-env-var input %s, skipped", env_var)
continue

if "." in env_var_name:
location_key, env_var_name = env_var_name.split(".", 1)
if not location_key.strip() or not env_var_name.strip():
LOG.error("Invalid command line --container-env-var input %s, skipped", env_var)
continue

if not processed_env_vars.get(location_key):
processed_env_vars[location_key] = {}
processed_env_vars[location_key][env_var_name] = value

return processed_env_vars


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
-------
dictionary
Function as key and the corresponding image URI as value.
Global default image URI is contained in the None key.
"""
images: Dict[Optional[str], str] = dict()
if image_args:
for image_string in image_args:
function_name, image_uri = _parse_key_value_pair(image_string)
if not image_uri:
raise InvalidImageException(f"Invalid command line image input {image_string}.")
images[function_name] = image_uri

return images


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]
value: str
if "=" in arg:
parts = arg.split("=", 1)
key = parts[0].strip()
value = parts[1].strip()
else:
key = None
value = arg.strip()
return key, value
1 change: 1 addition & 0 deletions samcli/commands/build/build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def gen_success_msg(artifacts_dir: str, output_template_path: str, is_default_bu
Commands you can use next
=========================
[*] Invoke Function: {invokecmd}
[*] Test Function in the Cloud: sam sync --stack-name {{stack-name}} --watch
[*] Deploy: {deploycmd}
""".format(
invokecmd=invoke_cmd, deploycmd=deploy_cmd, artifacts_dir=artifacts_dir, template=output_template_path
Expand Down
Loading

0 comments on commit c6f5bc4

Please sign in to comment.