-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Acces to config out of Flask context (#55)
* Create Microservice class with singleton to import config in any file * Updated doc and examples * Updated dependencies * Updated tests dependencies * increment version
- Loading branch information
Showing
20 changed files
with
488 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,7 @@ pylintReport.txt | |
|
||
# Deploy | ||
build/ | ||
dist/ | ||
dist/ | ||
|
||
# other | ||
site/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from pyms.flask.app import Microservice | ||
|
||
ms = Microservice(path=__file__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pyms: | ||
requests: | ||
data: "" | ||
swagger: | ||
path: "" | ||
file: "swagger.yaml" | ||
my-configure-microservice: | ||
DEBUG: true | ||
TESTING: false | ||
APP_NAME: "Python Microservice" | ||
APPLICATION_ROOT: "" | ||
request_variable_test: "this is a test" | ||
MyVar: "this is MyVar" | ||
test1: "ttest1" | ||
test2: "ttest2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from examples.microservice_configuration import ms | ||
app = ms.create_app() | ||
|
||
if __name__ == '__main__': | ||
""" | ||
run first: | ||
export CONFIGMAP_SERVICE=my-configure-microservice | ||
""" | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
swagger: "2.0" | ||
info: | ||
description: "This is a sample server Test server" | ||
version: "1.0.0" | ||
title: "Swagger Test list" | ||
termsOfService: "http://swagger.io/terms/" | ||
contact: | ||
email: "[email protected]" | ||
license: | ||
name: "Apache 2.0" | ||
url: "http://www.apache.org/licenses/LICENSE-2.0.html" | ||
tags: | ||
- name: "colors" | ||
description: "Everything about your colors" | ||
externalDocs: | ||
description: "Find out more" | ||
url: "http://swagger.io" | ||
- name: "store" | ||
description: "Example endpoint list of colors" | ||
- name: "user" | ||
description: "Operations about user" | ||
externalDocs: | ||
description: "Find out more about our store" | ||
url: "http://swagger.io" | ||
schemes: | ||
- "http" | ||
paths: | ||
/: | ||
get: | ||
tags: | ||
- "test" | ||
summary: "Example endpoint" | ||
description: "" | ||
operationId: "examples.microservice_configuration.views.example" | ||
consumes: | ||
- "application/json" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "A list of colors (may be filtered by palette)" | ||
schema: | ||
$ref: '#/definitions/Example' | ||
405: | ||
description: "Invalid input" | ||
definitions: | ||
Example: | ||
type: "object" | ||
properties: | ||
main: | ||
type: "string" | ||
externalDocs: | ||
description: "Find out more about Swagger" | ||
url: "http://swagger.io" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pyms.flask.app import config | ||
|
||
GLOBAL_VARIABLE = config().request_variable_test | ||
GLOBAL_VARIABLE2 = config().MyVar | ||
|
||
|
||
def example(): | ||
return { | ||
"GLOBAL_VARIABLE": GLOBAL_VARIABLE, | ||
"GLOBAL_VARIABLE2": GLOBAL_VARIABLE2, | ||
"test1": config().test1, | ||
"test2": config().test2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
__email__ = "[email protected]" | ||
|
||
__version__ = "1.0.3" | ||
__version__ = "1.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
CONFIGMAP_FILE_ENVIRONMENT = "CONFIGMAP_FILE" | ||
SERVICE_ENVIRONMENT = "CONFIGMAP_SERVICE" | ||
|
||
LOGGER_NAME = "pyms" | ||
|
||
|
Oops, something went wrong.