From ab7e3c59a16629995e3b9102bd823ea50d8692be Mon Sep 17 00:00:00 2001 From: Tobias Persson Date: Wed, 13 Oct 2021 10:58:35 +0200 Subject: [PATCH 1/3] Add and expose a feature flag library --- src/etos_lib/etos.py | 9 +++++++++ src/etos_lib/lib/feature_flags.py | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/etos_lib/lib/feature_flags.py diff --git a/src/etos_lib/etos.py b/src/etos_lib/etos.py index e7a6fa9..e3cec76 100644 --- a/src/etos_lib/etos.py +++ b/src/etos_lib/etos.py @@ -23,6 +23,7 @@ from .lib.utils import Utils from .lib.http import Http from .lib.debug import Debug +from .lib.feature_flags import FeatureFlags from .lib.database import Database from .lib.secrets import Secrets from .lib.exceptions import ( @@ -46,6 +47,7 @@ class ETOS: # pylint: disable=too-many-instance-attributes __graphql = None __http = None __debug = None + __feature_flags = None __secrets = None __database = None @@ -89,6 +91,13 @@ def debug(self): self.__debug = Debug() return self.__debug + @property + def feature_flags(self): + """Entry for feature flags for ETOS.""" + if self.__feature_flags is None: + self.__feature_flags = FeatureFlags() + return self.__feature_flags + @property def monitor(self): """Entry for ETOS Library monitor service.""" diff --git a/src/etos_lib/lib/feature_flags.py b/src/etos_lib/lib/feature_flags.py new file mode 100644 index 0000000..34efc55 --- /dev/null +++ b/src/etos_lib/lib/feature_flags.py @@ -0,0 +1,25 @@ +# Copyright 2021 Axis Communications AB. +# +# For a full list of individual contributors, please see the commit history. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""ETOS feature flags.""" +import os + +class FeatureFlags: + """Feature flags for ETOS.""" + + @property + def disable_clm(self): + """Whether or not CLM sending shall be disabled.""" + return os.getenv("ETOS_FEATURE_DISABLE_CLM", "false") == "true" \ No newline at end of file From 5e92c25471bc24bea7215d1521b49ae183df5b10 Mon Sep 17 00:00:00 2001 From: Tobias Persson Date: Wed, 13 Oct 2021 11:45:19 +0200 Subject: [PATCH 2/3] Fix copyright year --- src/etos_lib/etos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etos_lib/etos.py b/src/etos_lib/etos.py index e3cec76..0508874 100644 --- a/src/etos_lib/etos.py +++ b/src/etos_lib/etos.py @@ -1,4 +1,4 @@ -# Copyright 2020 Axis Communications AB. +# Copyright 2020-2021 Axis Communications AB. # # For a full list of individual contributors, please see the commit history. # From 903ce46b3278f708c04e1c856ad346bd5df0f0ae Mon Sep 17 00:00:00 2001 From: Tobias Persson Date: Fri, 15 Oct 2021 07:35:15 +0200 Subject: [PATCH 3/3] Change feature flag to be 'enable' instead of 'disable' --- src/etos_lib/lib/feature_flags.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/etos_lib/lib/feature_flags.py b/src/etos_lib/lib/feature_flags.py index 34efc55..b326152 100644 --- a/src/etos_lib/lib/feature_flags.py +++ b/src/etos_lib/lib/feature_flags.py @@ -20,6 +20,6 @@ class FeatureFlags: """Feature flags for ETOS.""" @property - def disable_clm(self): - """Whether or not CLM sending shall be disabled.""" - return os.getenv("ETOS_FEATURE_DISABLE_CLM", "false") == "true" \ No newline at end of file + def clm(self): + """Whether or not CLM sending shall be enabled.""" + return os.getenv("ETOS_FEATURE_CLM", "true") == "true" \ No newline at end of file