Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
Ilens-Env-Settings
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Irfanuddin
Ilens-Env-Settings
Commits
7417c7d3
Commit
7417c7d3
authored
Mar 09, 2021
by
Irfanuddin
🚴🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FirstCommit
parents
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
0 deletions
+87
-0
.gitignore
.gitignore
+0
-0
ilens_env_settings/__init__.py
ilens_env_settings/__init__.py
+72
-0
requirements-dev.txt
requirements-dev.txt
+2
-0
setup.py
setup.py
+13
-0
No files found.
.gitignore
0 → 100644
View file @
7417c7d3
This diff is collapsed.
Click to expand it.
ilens_env_settings/__init__.py
0 → 100644
View file @
7417c7d3
"""
------------------------------------------------DO NOT EDIT-------------------------------------------------
The following file is an utility to load environment configuration for the application to use.
Any modifications to the module should be requested to DevOps team.
All variables will be read from system environment and fallback to .env file in the root directory of your project.
"""
import
sys
from
typing
import
Optional
,
Any
from
pydantic
import
BaseSettings
,
ValidationError
class
EnvironmentSettings
(
BaseSettings
):
def
__init__
(
self
,
**
values
:
Any
):
super
()
.
__init__
(
**
values
)
# Global application environment
APP_ENV
:
str
=
"dev"
# Mongo Details
MONGO_URI
:
Optional
[
str
]
# Kairos Details
KAIROS_URI
:
Optional
[
str
]
# MQTT Details
MQTT_HOST
:
Optional
[
str
]
MQTT_PORT
:
Optional
[
int
]
=
1883
MQTT_AUTH
:
Optional
[
bool
]
=
False
MQTT_USERNAME
:
Optional
[
str
]
MQTT_PASSWORD
:
Optional
[
str
]
# Redis Details
REDIS_HOST
:
Optional
[
str
]
REDIS_PORT
:
Optional
[
int
]
# KAFKA Details
KAFKA_HOST
:
Optional
[
str
]
KAFKA_PORT
:
Optional
[
int
]
# Postgres Details
POSTGRES_URI
:
Optional
[
str
]
# Base Proxy for all services
BASE_PROXY
:
str
# Security aspects
SECURITY_IP_CHECK
:
bool
=
True
SECURITY_USER_CHECK
:
bool
=
True
SECURITY_AGENT_CHECK
:
bool
=
True
def
get_env_settings
(
use_local
=
False
):
"""
The function loads all the environmental variables and makes it available as a class object.
:return: env_settings
"""
try
:
if
use_local
:
env_settings
=
EnvironmentSettings
(
_env_file
=
'.env'
,
_env_file_encoding
=
'utf-8'
,
validate_all
=
False
)
else
:
env_settings
=
EnvironmentSettings
()
return
env_settings
except
ValidationError
as
e
:
print
(
e
.
json
())
sys
.
exit
(
1
)
except
Exception
as
e
:
print
(
e
.
args
)
sys
.
exit
(
1
)
requirements-dev.txt
0 → 100644
View file @
7417c7d3
pydantic
python-dotenv
setup.py
0 → 100644
View file @
7417c7d3
from
setuptools
import
setup
setup
(
name
=
'env_settings'
,
version
=
'V5.4.2'
,
packages
=
[
'ilens_env_settings'
],
url
=
'git@gitlab-pm.knowledgelens.com:iudeen/ilens-env-settings.git'
,
license
=
'Restricted'
,
author
=
'irfanuddin'
,
author_email
=
'irfanuddin@knowledgelens.com'
,
description
=
''
,
install_requires
=
[
'python-dotenv'
,
'pydantic'
]
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment