-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from pehala/tools2
Add tools
- Loading branch information
Showing
6 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Dynaconf loader for fetching data from tools namespace""" | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def fetch_route(name): | ||
"""Fetches the URL of a route with specific name""" | ||
def _fetcher(settings, _): | ||
try: | ||
openshift = settings["tools"] | ||
route = openshift.routes[name] | ||
if "tls" in route.model.spec: | ||
return "https://" + route.model.spec.host | ||
return "http://" + route.model.spec.host | ||
# pylint: disable=broad-except | ||
except Exception: | ||
logger.warning("Unable to fetch route %s from tools", name) | ||
return None | ||
return _fetcher | ||
|
||
|
||
def fetch_secret(name, key): | ||
"""Fetches the key out of a secret with specific name""" | ||
def _fetcher(settings, _): | ||
try: | ||
openshift = settings["tools"] | ||
return openshift.secrets[name][key] | ||
# pylint: disable=broad-except | ||
except Exception: | ||
logger.warning("Unable to fetch secret %s[%s] from tools", name, key) | ||
return None | ||
return _fetcher |