Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 71ebcad

Browse files
troca de variável do projeto do projectrc para ficar compativel com os demais pontos da aplicacao;
Correção de Dockerfile (remoção de variável não usada nos exemplos);
1 parent 2bcb10d commit 71ebcad

File tree

64 files changed

+212
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+212
-166
lines changed

.projectrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# project
2-
PROJECT_NAME=template-serverless-lambda-python
2+
APP_NAME=template-serverless-lambda-python
33
NETWORK_NAME=service-python

docker/python/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
FROM python:3.8.11-alpine3.13
22
MAINTAINER Anderson Contreira <anderson.contreira@gmail.com>
33

4-
ARG PROJECT_NAME=template-serverless-lambda-python
54
ARG FLASK_PORT=5000
65
ARG ENVIRONMENT_NAME=development
76
ENV FLASK_ENV=$ENVIRONMENT_NAME \
87
FLASK_APP=app.py
98

109
EXPOSE ${FLASK_PORT}
1110

12-
WORKDIR /${PROJECT_NAME}
11+
WORKDIR /app
1312

1413
# SQLite support
1514
RUN apk update \

examples/lambda_api/.projectrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PROJECT_NAME=template-serverless-lambda-python-lambda-api
1+
APP_NAME=template-serverless-lambda-python-lambda-api
22
NETWORK_NAME=service-python
33
APP_QUEUE=test-queue
44
APP_LAMBDA_NAME=lambda_api

examples/lambda_api/docker/python/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
FROM python:3.8.11-alpine3.13
22
MAINTAINER Anderson Contreira <anderson.contreira@gmail.com>
33

4-
ARG PROJECT_NAME=template-serverless-lambda-python
54
ARG FLASK_PORT=5000
65
ARG ENVIRONMENT_NAME=development
76
ENV FLASK_ENV=$ENVIRONMENT_NAME \
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1-
APP_NAME = 'template-serverless-lambda-python-lambda-api'
2-
APP_VERSION = '1.0.0'
3-
APP_ARCH_VERSION = 'v1'
1+
import os
2+
from dotenv import dotenv_values
3+
4+
if __package__:
5+
current_path = os.path.abspath(os.path.dirname(__file__)).replace('/' + str(__package__), '', 1)
6+
else:
7+
current_path = os.path.abspath(os.path.dirname(__file__))
8+
9+
env_vars = {}
10+
projectrc_file = current_path + '.projectrc'
11+
12+
PROJECT_NAME = os.path.basename(current_path).replace('_', '-')
13+
14+
if not current_path[-1] == '/':
15+
current_path += '/'
16+
17+
if os.path.exists(projectrc_file):
18+
env_vars = dotenv_values(projectrc_file)
19+
20+
APP_NAME = env_vars['APP_NAME'] if 'APP_NAME' in env_vars else PROJECT_NAME
21+
APP_VERSION = env_vars['APP_VERSION'] if 'APP_VERSION' in env_vars else '1.0.0'
22+
APP_ARCH_VERSION = env_vars['APP_ARCH_VERSION'] if 'APP_ARCH_VERSION' in env_vars else 'v1'

examples/lambda_api/scripts/docker/exec-sh.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ elif test -f ./scripts/.projectrc; then
55
source ./scripts/.projectrc
66
fi
77

8-
if [ -z "$PROJECT_NAME" ]; then
9-
echo 'PROJECT_NAME not defined'
8+
if [ -z "$APP_NAME" ]; then
9+
echo 'APP_NAME not defined'
1010
exit 1
1111
else
12-
docker-compose exec $PROJECT_NAME /bin/sh
12+
docker-compose exec $APP_NAME /bin/sh
1313
fi

examples/lambda_api/scripts/zip.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ elif test -f ./scripts/.projectrc; then
55
source ./scripts/.projectrc
66
fi
77

8-
if [ -z "$PROJECT_NAME" ]; then
9-
echo 'PROJECT_NAME not defined'
8+
if [ -z "$APP_NAME" ]; then
9+
echo 'APP_NAME not defined'
1010
exit 1
1111
else
12-
zip -r $PROJECT_NAME.zip ./ -x '*.git*' -x './zip.sh*' -x './venv/*' -x './.idea/*' -x './node_modules/*'
12+
zip -r $APP_NAME.zip ./ -x '*.git*' -x './zip.sh*' -x './venv/*' -x './.idea/*' -x './node_modules/*'
1313
fi

examples/lambda_api/tests/component/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from lambda_app.logging import get_logger
1313

1414
from tests.component.helpers.database.mysql_helper import MySQLHelper
15-
from tests.component.helpers.events.aws.sqs_helper import SQSHelper
15+
from tests.component.helpers.aws.sqs_helper import SQSHelper
1616
from tests.unit.helpers.aws.sqs_helper import get_sqs_event_sample
1717
from tests.unit.mocks.aws_mocks.aws_lambda_mock import FakeLambdaContext
1818
from tests.unit.mocks.lambda_event_mocks.request_event import create_aws_api_gateway_proxy_request_event

0 commit comments

Comments
 (0)