Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
45e75b6
WIP: Interactive Init Command
awood45 Sep 13, 2019
33eb157
WIP: Mutually Exclusive and Required Params
awood45 Sep 24, 2019
5aba829
WIP: Stubbed Out Interactive Flow
awood45 Sep 27, 2019
01206f1
WIP: Working Flow
awood45 Oct 2, 2019
928aba6
Adds SageMaker Ground Truth Lambda events
Oct 7, 2019
911dc86
WIP: Working Init Flow
awood45 Oct 7, 2019
80f8307
WIP: Existing Init Unit Tests Pass
awood45 Oct 7, 2019
58a6e42
WIP: Clean Up Lint Warnings, Add Go Dep Manager
awood45 Oct 8, 2019
ad09dc3
Linting Improvements
awood45 Oct 9, 2019
6cf331b
Merge branch 'develop' into interactive-init
awood45 Oct 9, 2019
535544b
Add Docstrings, Fix Branch Indentation
awood45 Oct 9, 2019
f4b528b
Merge branch 'interactive-init' of github.com:awood45/aws-sam-cli int…
awood45 Oct 9, 2019
b6d7cf6
Remove Planning Comment
awood45 Oct 9, 2019
64b45ea
Check for Multiple Git Executables
awood45 Oct 10, 2019
8993087
Add Click Command Unit Tests for Init
awood45 Oct 10, 2019
bf2f2b3
Fix _git_executable Function
awood45 Oct 10, 2019
8c53066
Fix Git Templates Function Call
awood45 Oct 10, 2019
8066ae8
Use Filter for Template Selection
awood45 Oct 15, 2019
b09929f
Unit Test the Template Class
awood45 Oct 15, 2019
694a0be
Additional Test Coverage
awood45 Oct 15, 2019
9eb8167
Remove Unused Variable
awood45 Oct 15, 2019
0378bcc
Address Init PR Comments
awood45 Oct 15, 2019
7438d9f
Update Init Integ Tests
awood45 Oct 17, 2019
2900324
Run of Black Reformatting
awood45 Oct 23, 2019
c238d82
Merge branch 'develop' into interactive-init
awood45 Oct 23, 2019
ee91629
Deprecate: Remove Python2.7 installation support (#1416)
jfuss Oct 23, 2019
ccefe34
fix: typo in CloudFrontServeObjectOnViewer event (#1451)
Tina-Wang-0904 Oct 23, 2019
458668b
chore: add some functional tests to appveyor (#1450)
jfuss Oct 24, 2019
b1b4585
Matches event params to API params.
Oct 24, 2019
8d82ec0
feat: Expose multiple ports when running in debug mode (#1479)
sdubov Oct 25, 2019
2930050
Fixes empty account id in CloudWatch Scheduled Event
Oct 27, 2019
0c99a66
fix: Lambda timeout from parameter (#925)
setrofim May 31, 2019
e5334da
update with HEAD of develop and add a unit test
jfuss Oct 28, 2019
6df7b0a
Merge develop into interactive-init
awood45 Oct 28, 2019
c4025a3
Improvements to fix linter issues in init
awood45 Oct 28, 2019
d34ea10
Update Mock Import
awood45 Oct 28, 2019
7061eb6
Try batch file for git
awood45 Oct 28, 2019
7cf2e35
Make Unit Test for Init Windows-Compatible
awood45 Oct 28, 2019
cc3cba0
Switch execname order
awood45 Oct 28, 2019
5053efa
Catch exceptions when checking git executables
awood45 Oct 28, 2019
0ec8bb2
Add explicit exception for missing git
awood45 Oct 28, 2019
7624b20
Add git executable unit test
awood45 Oct 28, 2019
efcc51f
Add git executable check
awood45 Oct 28, 2019
4b76385
Add Exception Info when Git Fails
awood45 Oct 28, 2019
b3594a0
Fix Warning Method
awood45 Oct 28, 2019
3382135
Run git in Appveyor test stage
awood45 Oct 29, 2019
f8d7977
WIP: Create Shared Directory
awood45 Oct 29, 2019
7255c88
Create Shared Dir if Necessary
awood45 Oct 29, 2019
957e802
Add Shared Dir Unit Tests
awood45 Oct 29, 2019
216b802
Add One More Test
awood45 Oct 29, 2019
8fe22cc
Move Local Imports into do_cli
awood45 Oct 29, 2019
4d9a3a0
Merge pull request #1454 from awood45/interactive-init
awood45 Oct 29, 2019
fddc33f
Merge pull request #1484 from trenton/scheduled-event-fix
awood45 Oct 29, 2019
80532d9
Merge pull request #1447 from trenton/ground-truth-events
awood45 Oct 29, 2019
b462e06
Merge pull request #1202 from setrofim/develop
awood45 Oct 29, 2019
402d8bf
chore: bump version to 0.30.0
awood45 Oct 29, 2019
66b6542
Merge pull request #1487 from awood45/release0.30.0
awood45 Oct 29, 2019
e30ce9f
Add HELP_TEXT for init command (#1492)
awood45 Oct 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ integ-test:
func-test:
# Verify function test coverage only for `samcli.local` package
@echo Telemetry Status: $(SAM_CLI_TELEMETRY)
pytest --cov samcli.local --cov samcli.commands.local --cov-report term-missing tests/functional
pytest --cov samcli.local --cov samcli.commands.local --cov-report term-missing tests/functional/commands/validate tests/functional/commands/cli/test_global_config.py

smoke-test:
# Smoke tests run in parallel
Expand Down
5 changes: 5 additions & 0 deletions appveyor-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ environment:
HOME: 'C:\Users\appveyor'
HOMEDRIVE: 'C:'
HOMEPATH: 'C:\Users\appveyor'
NOSE_PARAMETERIZED_NO_WARN: 1

init:
# Uncomment this for RDP
Expand Down Expand Up @@ -59,11 +60,15 @@ install:
# Switch to Docker Linux containers
- ps: Switch-DockerLinux

# Check for git executable
- "git --version"

# Echo final Path
- "echo %PATH%"

test_script:
# Reactivate virtualenv before running tests
- "git --version"
- "venv\\Scripts\\activate"
- "docker system prune -a -f"
- "pytest -vv tests/integration"
Expand Down
12 changes: 12 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ environment:
- PYTHON_HOME: "C:\\Python36-x64"
PYTHON_VERSION: '3.6.8'
PYTHON_ARCH: '64'
NOSE_PARAMETERIZED_NO_WARN: 1

- PYTHON_HOME: "C:\\Python37-x64"
PYTHON_VERSION: '3.7.4'
PYTHON_ARCH: '64'
RUN_SMOKE: 1
NOSE_PARAMETERIZED_NO_WARN: 1

for:
-
Expand All @@ -30,12 +32,16 @@ for:
- "echo %PATH%"
- "python --version"
# Upgrade setuptools, wheel and virtualenv
- "SET PATH=%PYTHON_HOME%;%PATH%"
- "echo %PYTHON_HOME%"
- "echo %PATH%"
- "python -m pip install --upgrade setuptools wheel virtualenv"

# Create new virtual environment and activate it
- "rm -rf venv"
- "python -m virtualenv venv"
- "venv\\Scripts\\activate"
- "python --version"

build_script:
# Activate virtualenv again on windows
Expand All @@ -48,6 +54,9 @@ for:
- "venv\\Scripts\\activate"
- "pytest --cov samcli --cov-report term-missing --cov-fail-under 95 tests/unit"
- "pylint --rcfile .pylintrc samcli"
# There are some functional tests that are currently broken due to not being updated with changed code or still running with node4.3 runtimes
# We need to update those but this allows us to at least runs the ones we currently have working
- "pytest tests/functional/commands/validate tests/functional/commands/cli/test_global_config.py"

# Runs only in Linux
- sh: "pytest -vv tests/integration"
Expand Down Expand Up @@ -88,6 +97,9 @@ for:
test_script:
- "pytest --cov samcli --cov-report term-missing --cov-fail-under 95 tests/unit"
- "pylint --rcfile .pylintrc samcli"
# There are some functional tests that are currently broken due to not being updated with changed code or still running with node4.3 runtimes
# We need to update those but this allows us to at least runs the ones we currently have working
- "pytest tests/functional/commands/validate tests/functional/commands/cli/test_global_config.py"

# Runs only in Linux
- sh: "pytest -vv tests/integration"
Expand Down
121 changes: 121 additions & 0 deletions designs/debug_mode_multiple_exposed_ports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Title: Template for design documents
====================================

What is the problem?
--------------------
Currently, there is one port is exposed from Docker instance when running lambda in debug mode.
This port is used to connect a debugger. In my case, I need two ports to be exposed due to Debugger
implementation specific (the Debugger connect to two sockets to collect different information).

What will be changed?
---------------------
SAM CLI has a ``--debug-port`` parameter that provide a port. This parameter is stored in DebugContext object.
``DebugContext`` should store an array of ports instead of a single port. This array should be transformed
into a map containing each stored port when passing to docker container arguments.

Success criteria for the change
-------------------------------
All ports specified via single or multiple ``--debug-port`` SAM CLI options should be exposed by docker container.

Out-of-Scope
------------

User Experience Walkthrough
---------------------------
From the user perspective, it should only provide an ability to specify multiple ``--debug-port`` options:
``--debug-port 5600 --debug-port 5601``

Implementation
==============

CLI Changes
-----------

SAM CLI provide an option to specify multiple ports ``--debug-port 5600 --debug-port 5601``.

### Breaking Change

No changes.

Design
------

Update ``--debug-port`` option to allow to use it multiple times in SAM CLI.
The option type should take only integer values. The value is stored in ``DebugContext``.
This value should be converted into a map of ``{ container_port : host_port }``
that is passed to ``ports`` argument when creating a docker container.

`.samrc` Changes
----------------

No changes.

Security
--------

No changes.

**What new dependencies (libraries/cli) does this change require?**

**What other Docker container images are you using?**

**Are you creating a new HTTP endpoint? If so explain how it will be
created & used**

**Are you connecting to a remote API? If so explain how is this
connection secured**

**Are you reading/writing to a temporary folder? If so, what is this
used for and when do you clean up?**

**How do you validate new .samrc configuration?**

What is your Testing Plan (QA)?
===============================

Goal
----
Make sure SAM CLI users can specify multiple ports and those ports are exposed
after creating a docker container in debug mode:

``sam local invoke --template <path_to_template>/template.yaml --event <path_to_event>/event.json --debugger-path <path_to_debugger> --debug-port 5600 --debug-port 5601``

Pre-requesites
--------------
Running SAM CLI with debug mode.

Test Scenarios/Cases
--------------------
1. Single port is specified: ``--debug-port 5600``
2. Multiple ports are specified: ``--debug-port 5600 --debug-port 5601``
3. No ports specified: ``--debug-port ``
4. No ``--debug-port`` parameter is specified

Expected Results
----------------
1. Single port is exposed in docker container
2. All specified ports are exposed in docker container
3. No ports exposed.
4. No ports exposed.

Pass/Fail
---------

Documentation Changes
=====================

Open Issues
============
- [1463](https://github.com/awslabs/aws-sam-cli/issues/1463)

Task Breakdown
==============

- \[x\] Send a Pull Request with this design document
- \[ \] Build the command line interface
- \[ \] Build the underlying library
- \[x\] Unit tests
- \[x\] Functional Tests
- \[x\] Integration tests
- \[ \] Run all tests on Windows
- \[x\] Update documentation
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"] # PEP 508 specifications.

[tool.black]
line-length = 120
target_version = ['py37', 'py27', 'py36']
target_version = ['py37', 'py36']
exclude = '''

(
Expand All @@ -17,6 +17,7 @@ exclude = '''
| dist
| pip-wheel-metadata
| samcli/local/init/templates
| tests/integration/testdata
)/
)
'''
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
env =
AWS_DEFAULT_REGION = ap-southeast-1
filterwarnings =
error
#filterwarnings =
# error
3 changes: 0 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
six~=1.11.0
chevron~=0.12
click~=7.0
enum34~=1.1.6; python_version<"3.4"
Flask~=1.0.2
boto3~=1.9, >=1.9.56
PyYAML~=5.1
Expand All @@ -10,7 +8,6 @@ aws-sam-translator==1.15.1
docker~=4.0
dateparser~=0.7
python-dateutil~=2.6
pathlib2~=2.3.2; python_version<"3.4"
requests==2.22.0
serverlessrepo==0.1.9
aws_lambda_builders==0.5.0
25 changes: 8 additions & 17 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
coverage==4.3.4
pytest-cov==2.4.0
# astroid > 2.0.4 is not compatible with pylint1.7
astroid>=1.5.8,<2.1.0
pylint==1.7.2
coverage==4.5.4
pytest-cov==2.7.1
pylint==2.3.1

# Test requirements
pytest==3.6.0
py==1.5.1
pluggy==0.6.0
mock==2.0.0
parameterized==0.6.1
pathlib2==2.3.2; python_version<"3.4"
futures==3.2.0; python_version<"3.2.3"
# Py3.2 backport
backports.tempfile==1.0
pytest-xdist==1.20.0
pytest-forked==1.0.2
pytest==5.2.1
parameterized==0.7.0
pytest-xdist==1.30.0
pytest-forked==1.1.3
pytest-timeout==1.3.3
pytest-rerunfailures==5.0
pytest-rerunfailures==7.0
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__ = "0.23.0"
__version__ = "0.30.0"
19 changes: 4 additions & 15 deletions samcli/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
import importlib
import sys
from collections import OrderedDict

import click
Expand All @@ -24,13 +23,6 @@
"samcli.commands.publish",
]

DEPRECATION_NOTICE = (
"Deprecated : AWS SAM CLI no longer supports "
"installations on Python 2.7. "
"Install AWS SAM CLI via https://docs.aws.amazon.com/serverless-application-model/"
"latest/developerguide/serverless-sam-cli-install.html for continued support with new versions. \n"
)


class BaseCommand(click.MultiCommand):
"""
Expand All @@ -53,7 +45,7 @@ class BaseCommand(click.MultiCommand):
will produce a command name "baz".
"""

def __init__(self, cmd_packages=None, *args, **kwargs):
def __init__(self, *args, cmd_packages=None, **kwargs):
"""
Initializes the class, optionally with a list of available commands

Expand All @@ -69,9 +61,6 @@ def __init__(self, cmd_packages=None, *args, **kwargs):
self._commands = {}
self._commands = BaseCommand._set_commands(cmd_packages)

if sys.version_info.major == 2:
click.secho(DEPRECATION_NOTICE, fg="red", err=True)

@staticmethod
def _set_commands(package_names):
"""
Expand Down Expand Up @@ -109,18 +98,18 @@ def get_command(self, ctx, cmd_name):
"""
if cmd_name not in self._commands:
logger.error("Command %s not available", cmd_name)
return
return None

pkg_name = self._commands[cmd_name]

try:
mod = importlib.import_module(pkg_name)
except ImportError:
logger.exception("Command '%s' is not configured correctly. Unable to import '%s'", cmd_name, pkg_name)
return
return None

if not hasattr(mod, "cli"):
logger.error("Command %s is not configured correctly. It must expose an function called 'cli'", cmd_name)
return
return None

return mod.cli
6 changes: 5 additions & 1 deletion samcli/cli/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import click


class Context(object):
class Context:
"""
Top level context object for the CLI. Exposes common functionality required by a CLI, including logging,
environment config parsing, debug logging etc.
Expand Down Expand Up @@ -98,6 +98,8 @@ def command_path(self):
if click_core_ctx:
return click_core_ctx.command_path

return None

@staticmethod
def get_current_context():
"""
Expand Down Expand Up @@ -129,6 +131,8 @@ def my_command_handler(ctx):
if click_core_ctx:
return click_core_ctx.find_object(Context) or click_core_ctx.ensure_object(Context)

return None

def _refresh_session(self):
"""
Update boto3's default session by creating a new session based on values set in the context. Some properties of
Expand Down
7 changes: 2 additions & 5 deletions samcli/cli/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
import logging
import uuid
import os
from pathlib import Path

import click

try:
from pathlib import Path
except ImportError: # pragma: no cover
from pathlib2 import Path # pragma: no cover

LOG = logging.getLogger(__name__)

Expand All @@ -21,7 +18,7 @@
TELEMETRY_ENABLED_KEY = "telemetryEnabled"


class GlobalConfig(object):
class GlobalConfig:
"""
Contains helper methods for global configuration files and values. Handles
configuration file creation, updates, and fetching in a platform-neutral way.
Expand Down
Loading