From 6315ce861c0c24abaf6c8920f96911b53637912f Mon Sep 17 00:00:00 2001 From: srntqn Date: Wed, 9 Feb 2022 22:07:42 +0100 Subject: [PATCH 1/2] feat: use pydantic BaseSettings for Config dataclass --- harmony/cli.py | 16 +++++----------- harmony/libs/serializers/config.py | 14 +++++++------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/harmony/cli.py b/harmony/cli.py index bc9fae0..8999eb6 100644 --- a/harmony/cli.py +++ b/harmony/cli.py @@ -3,8 +3,6 @@ import logging import sys -from os import getenv - from . import __version__, __module_name__ from .libs.k8s_cluster import KubernetesCluster from .libs.serializers.project import Project @@ -13,20 +11,16 @@ from .libs.k8s_deployment import K8sDeployment from .libs.worker import read_projects_from_config, fetch_app_version_from_vcs, sync_versions_in_vcs_and_cluster -CONFIG = Config(**{'config_location': getenv('CONFIG_LOCATION'), - 'verify_ssl': getenv('VERIFY_SSL'), - 'k8s_api_server': getenv('K8S_API_SERVER_HOST'), - 'k8s_api_key': getenv('K8S_API_KEY'), - 'log_level': getenv('LOG_LEVEL')}) - -logging.basicConfig(stream=sys.stdout, - level=logging.getLevelName(CONFIG.log_level)) - +CONFIG = Config() PROJECTS = read_projects_from_config(CONFIG.config_location) CLUSTER = KubernetesCluster(CONFIG.verify_ssl, CONFIG.k8s_api_server, CONFIG.k8s_api_key) +logging.basicConfig(stream=sys.stdout, + level=logging.getLevelName(CONFIG.log_level)) + + cli = typer.Typer(name=__module_name__) diff --git a/harmony/libs/serializers/config.py b/harmony/libs/serializers/config.py index 511a52a..64a5e82 100644 --- a/harmony/libs/serializers/config.py +++ b/harmony/libs/serializers/config.py @@ -1,9 +1,9 @@ -from pydantic import BaseModel, HttpUrl +from pydantic import BaseSettings, Field, HttpUrl -class Config(BaseModel): - config_location: str - verify_ssl: bool - k8s_api_server: HttpUrl - k8s_api_key: str - log_level: str +class Config(BaseSettings): + config_location: str = Field (..., env = 'CONFIG_LOCATION') + verify_ssl: bool = Field (..., env = 'VERIFY_SSL') + k8s_api_server: HttpUrl = Field(..., env = 'K8S_API_SERVER_HOST') + k8s_api_key: str = Field(..., env = 'K8S_API_KEY') + log_level: str = Field(..., env = 'LOG_LEVEL') From d5c94e75b2c59b288f404e13fecea28c70599f28 Mon Sep 17 00:00:00 2001 From: srntqn Date: Wed, 9 Feb 2022 22:19:07 +0100 Subject: [PATCH 2/2] chore: bump harmony version to 0.8.0 --- chart/Chart.yaml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chart/Chart.yaml b/chart/Chart.yaml index d82b0c4..bd3b6e4 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "0.7.0" +appVersion: "0.8.0" description: Harmony helm chart name: harmony version: 0.2.0 diff --git a/pyproject.toml b/pyproject.toml index bb25b54..94ee9a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "harmony" -version = "0.7.0" +version = "0.8.0" description = "" authors = ["srntqn "]