Skip to content

Commit

Permalink
Message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Jan 28, 2020
1 parent 8e84a5e commit 2015821
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configcat-validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions configcat/reference_validator/config_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions configcat/reference_validator/reference_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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!")
Expand Down
11 changes: 9 additions & 2 deletions configcat/reference_validator/reference_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import setuptools

version = "1.0.7"
version = "1.0.8"

setuptools.setup(
name='configcat-flag-reference-validator',
Expand Down

0 comments on commit 2015821

Please sign in to comment.