mirror of
https://github.com/nikdoof/ohayodash.git
synced 2025-12-14 02:22:17 +00:00
Lint cleanup
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from ohayodash.base import base
|
from ohayodash.base import base
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|||||||
@@ -8,30 +8,27 @@ ANNOTATION_BASE = 'ohayodash.github.io'
|
|||||||
|
|
||||||
base = Blueprint('base', __name__, template_folder='templates')
|
base = Blueprint('base', __name__, template_folder='templates')
|
||||||
|
|
||||||
|
if 'KUBERNETES_SERVICE_HOST' in os.environ:
|
||||||
|
kubernetes.config.load_incluster_config()
|
||||||
|
else:
|
||||||
|
kubernetes.config.load_kube_config()
|
||||||
|
|
||||||
def check_tags(tag, object):
|
|
||||||
|
def check_tags(tag, kubeobj):
|
||||||
# Skip if we're limited to a tag, and the CM has tags but not that one.
|
# Skip if we're limited to a tag, and the CM has tags but not that one.
|
||||||
tags = object.metadata.annotations.get('{0}/tags'.format(ANNOTATION_BASE), '')
|
tags = kubeobj.metadata.annotations.get('{0}/tags'.format(ANNOTATION_BASE), '')
|
||||||
obj_tags = {x for x in tags.split(',') if x != ''}
|
obj_tags = {tagname for tagname in tags.split(',') if tagname != ''}
|
||||||
|
|
||||||
# If its not tagged, allow
|
# If its not tagged, allow
|
||||||
if not obj_tags:
|
if not obj_tags:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# If tag is on the object, allow
|
# If tag is on the object, allow
|
||||||
if tag in obj_tags:
|
return tag in obj_tags
|
||||||
return True
|
|
||||||
|
|
||||||
# Else, disallow
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_k8s_applications(tag: str = None) -> list:
|
def get_k8s_applications(tag: str = None) -> list:
|
||||||
"""Get all ingresses from the cluster and produce a application list."""
|
"""Get all ingresses from the cluster and produce a application list."""
|
||||||
if 'KUBERNETES_SERVICE_HOST' in os.environ:
|
|
||||||
kubernetes.config.load_incluster_config()
|
|
||||||
else:
|
|
||||||
kubernetes.config.load_kube_config()
|
|
||||||
api = kubernetes.client.NetworkingV1Api()
|
api = kubernetes.client.NetworkingV1Api()
|
||||||
|
|
||||||
applications = []
|
applications = []
|
||||||
@@ -68,10 +65,6 @@ def get_k8s_applications(tag: str = None) -> list:
|
|||||||
|
|
||||||
def get_bookmarks(tag: str = None) -> list:
|
def get_bookmarks(tag: str = None) -> list:
|
||||||
"""Get all 'bookmark' ConfigMaps from the cluster and produce a bookmark list."""
|
"""Get all 'bookmark' ConfigMaps from the cluster and produce a bookmark list."""
|
||||||
if 'KUBERNETES_SERVICE_HOST' in os.environ:
|
|
||||||
kubernetes.config.load_incluster_config()
|
|
||||||
else:
|
|
||||||
kubernetes.config.load_kube_config()
|
|
||||||
v1 = kubernetes.client.CoreV1Api()
|
v1 = kubernetes.client.CoreV1Api()
|
||||||
ret = v1.list_config_map_for_all_namespaces(watch=False)
|
ret = v1.list_config_map_for_all_namespaces(watch=False)
|
||||||
|
|
||||||
@@ -131,8 +124,8 @@ def providers(tag=None):
|
|||||||
{'name': 'Soundcloud', 'url': 'https://soundcloud.com/search?q=', 'prefix': '/so'},
|
{'name': 'Soundcloud', 'url': 'https://soundcloud.com/search?q=', 'prefix': '/so'},
|
||||||
{'name': 'Spotify', 'url': 'https://open.spotify.com/search/results/', 'prefix': '/s'},
|
{'name': 'Spotify', 'url': 'https://open.spotify.com/search/results/', 'prefix': '/s'},
|
||||||
{'name': 'TheTVDB', 'url': 'https://www.thetvdb.com/search?query=', 'prefix': '/tv'},
|
{'name': 'TheTVDB', 'url': 'https://www.thetvdb.com/search?query=', 'prefix': '/tv'},
|
||||||
{'name': 'Trakt', 'url': 'https://trakt.tv/search?query=', 'prefix': '/t'}
|
{'name': 'Trakt', 'url': 'https://trakt.tv/search?query=', 'prefix': '/t'},
|
||||||
]
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -140,7 +133,7 @@ def providers(tag=None):
|
|||||||
@base.route('/<tag>/apps.json')
|
@base.route('/<tag>/apps.json')
|
||||||
def applications(tag=None):
|
def applications(tag=None):
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'apps': get_k8s_applications(tag)
|
'apps': get_k8s_applications(tag),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -148,5 +141,5 @@ def applications(tag=None):
|
|||||||
@base.route('/<tag>/links.json')
|
@base.route('/<tag>/links.json')
|
||||||
def bookmarks(tag=None):
|
def bookmarks(tag=None):
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'bookmarks': get_bookmarks(tag)
|
'bookmarks': get_bookmarks(tag),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user