-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
34 additions
and
10 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
from dynaconf import Dynaconf | ||
import pkgutil | ||
import logging | ||
|
||
from dynaconf import Dynaconf | ||
from dynaconf.loaders import yaml_loader | ||
from enum import Enum | ||
|
||
class Config(Enum): | ||
default_image = "default_image" | ||
welcome_message = "welcome_message" | ||
log_level = "log_level" | ||
|
||
def get(self): | ||
key = self.value | ||
return settings().get(key) | ||
|
||
_settings = None | ||
def settings(): | ||
global _settings | ||
if not _settings: | ||
_settings = Dynaconf( | ||
envvar_prefix="UP", | ||
load_dotenv=True,) | ||
environments=False, | ||
envvar_prefix="UP") | ||
up_yaml = pkgutil.get_data(__name__, "up.yaml") | ||
if up_yaml: | ||
up_yaml = up_yaml.decode("utf-8") | ||
yaml_loader.load(_settings, filename=up_yaml) | ||
return _settings | ||
|
||
def get_log_level(): | ||
level_name = settings().get("log_level", "INFO") | ||
level = logging.getLevelName(level_name) | ||
return level | ||
|
||
|
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,2 @@ | ||
default_image: fedora | ||
welcome_message: Thank you for running up! |