Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
morington committed Jun 30, 2024
1 parent 9b69002 commit 68142bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion confhub/__meta__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0.7a"
__version__ = "0.1.1.0a"
16 changes: 4 additions & 12 deletions confhub/core/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,23 @@ def __init__(
self,
data_type: Type,
secret: bool,
filename: str,
development_mode: bool
filename: str
) -> None:
self.data_type = data_type
self.secret = secret
self.filename = filename
self.development_mode = development_mode

def get_default_value(self) -> str:
default_value = f"{self.data_type.__name__}; {DataTypeMapping.get_default_value(self.data_type.__name__)}"

if self.development_mode:
return f"{default_value}; DEVELOPMENT_{DataTypeMapping.get_default_value(self.data_type.__name__)}"
return default_value
return f"{self.data_type.__name__}; {DataTypeMapping.get_default_value(self.data_type.__name__)}"


def field(
data_type: Type,
secret: bool = False,
filename: str = None,
development_mode: bool = False
filename: str = None
) -> ConfigurationField:
return ConfigurationField(
data_type=data_type,
secret=secret,
filename=filename,
development_mode=development_mode
filename=filename
)
2 changes: 1 addition & 1 deletion confhub/core/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_service_data() -> Dict[str, Any]:
return yml_data.data


def parsing_value(value: str, development_mode: bool) -> Union[str, int, float, bool]:
def parsing_value(value: str, development_mode: bool) -> Union[str, int, float, bool, list]:
if isinstance(value, List):
return [parsing_value(_value, development_mode) for _value in value]
else:
Expand Down
8 changes: 4 additions & 4 deletions confhub/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class PostgreSQL(BlockCore):
Creating values is very simple:
value_name = field(data_type, development_mode=True/False, secret=True/False, filename='MY_FILE')
data_type - типа значения данных в конфигурации, поддерживаемые типы:
development_mode - indicates whether the field will have a different value in development mode (default False)
data_type - data value type in the configuration, supported types: `str`, `int`, `float`, `bool`
secret - means whether to hide this field as secrets (default is False, all files go to settings by default)
filename - you can independently define the field in the file that is required, Confhub will create it for you
filename - you can independently define the field in the file that is required, Confhub will create it for you.
If a file starts with a dot, it automatically goes into .gitignore.
'''
scheme = field(str)
host = field(str, development_mode=True)
host = field(str)
port = field(int, secret=True)
user = field(str, secret=True)
password = field(str, secret=True)
Expand Down

0 comments on commit 68142bd

Please sign in to comment.