From 20158212c82ee7a955822a98008638287ffb041a Mon Sep 17 00:00:00 2001 From: Peter Csajtai Date: Tue, 28 Jan 2020 10:28:48 +0100 Subject: [PATCH] Message changes --- configcat-validator.py | 2 +- configcat/reference_validator/config_fetcher.py | 4 ++-- configcat/reference_validator/reference_finder.py | 4 ++-- configcat/reference_validator/reference_validator.py | 11 +++++++++-- setup.py | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/configcat-validator.py b/configcat-validator.py index 578bf2d..a02d6d3 100644 --- a/configcat-validator.py +++ b/configcat-validator.py @@ -51,7 +51,7 @@ def main(): sys.exit(1) if validation_result: - log.info("PASSED. No differences found!") + log.info("PASSED. everything's fine, didn't find any unused feature flags.") def str2bool(v): diff --git a/configcat/reference_validator/config_fetcher.py b/configcat/reference_validator/config_fetcher.py index e878f4d..5469d0f 100644 --- a/configcat/reference_validator/config_fetcher.py +++ b/configcat/reference_validator/config_fetcher.py @@ -18,7 +18,7 @@ def __init__(self, self._base_url = base_url.rstrip('/') def get_flag_keys(self): - log.info("Fetching the current ConfigCat configuration from %s.", self._base_url) + log.debug("Fetching the current ConfigCat configuration from %s.", self._base_url) uri = 'https://' + self._base_url + '/configuration-files/' + self._api_key + '/config_v2.json' try: response = self._session.get(uri, headers={'X-ConfigCat-UserAgent': 'ConfigCat-CircleCI', @@ -29,7 +29,7 @@ def get_flag_keys(self): for key, value in json.items(): keys.append(key) - log.info("Successful fetch, %s settings found: %s.", len(keys), keys) + log.debug("Successful fetch, %s settings found in ConfigCat Dashboard: %s.", len(keys), keys) return keys except HTTPError as err: log.error("HTTP error recieved: %s.", str(err.response)) diff --git a/configcat/reference_validator/reference_finder.py b/configcat/reference_validator/reference_finder.py index 82af2d6..145f5fe 100644 --- a/configcat/reference_validator/reference_finder.py +++ b/configcat/reference_validator/reference_finder.py @@ -15,7 +15,7 @@ def __init__(self, def find_references(self, remote_keys): try: - log.info("Scanning the %s directory for ConfigCat setting references.", self._path) + log.debug("Scanning the %s directory for ConfigCat setting references.", self._path) regex_final = FLAG_REGEX.replace("##KEYS_PLACEHOLDER##", '|'.join(remote_keys)) args = ["ag", "-s", "-o", regex_final, self._path] @@ -28,7 +28,7 @@ def find_references(self, remote_keys): flags.append(group.strip()) distinct = set(flags) - log.info("%s references found: %s.", len(matches), distinct) + log.debug("References found for %s flags in code: %s.", len(matches), distinct) return distinct except subprocess.CalledProcessError: log.warning("No feature flag references found!") diff --git a/configcat/reference_validator/reference_validator.py b/configcat/reference_validator/reference_validator.py index 5a9687b..fc7623f 100644 --- a/configcat/reference_validator/reference_validator.py +++ b/configcat/reference_validator/reference_validator.py @@ -14,17 +14,24 @@ def validate(remote_keys, missing_references = remote_keys.difference(reference_keys) missing_remote_keys = reference_keys.difference(remote_keys) + log.warning( + "Found unused feature flags!") + result = True if len(missing_references) > 0: result = False - log.warning( + log.debug( "Feature flag/Setting keys not found in source code (but present in ConfigCat): %s.", missing_references) + for item in missing_references: + log.warning("Clean up '%s' from ConfigCat Dashboard.", item) if len(missing_remote_keys) > 0: result = False - log.warning( + log.debug( "Feature flag/Setting keys not found in ConfigCat (but present in source code): %s.", missing_remote_keys) + for item in missing_remote_keys: + log.warning("Clean up '%s' from code.", item) return result diff --git a/setup.py b/setup.py index 677ce54..c806c46 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import setuptools -version = "1.0.7" +version = "1.0.8" setuptools.setup( name='configcat-flag-reference-validator',