-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
69 lines (59 loc) · 2.14 KB
/
app.py
File metadata and controls
69 lines (59 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from flask import Flask, render_template, jsonify, request
from utils.parser import fetch_github_yaml_files, extract_apps
from utils.helm import fetch_all_chart_versions
from config import GIT_BRANCHES
import asyncio
app = Flask(__name__)
@app.route('/')
def index():
# Initial data without remote helm version checks
default_branch = GIT_BRANCHES[0]
docs = asyncio.run(fetch_github_yaml_files(default_branch))
apps = extract_apps(docs)
for app in apps:
app['latestVersion'] = "loading..."
return render_template(
"index.html",
apps=apps,
branches=GIT_BRANCHES,
selected_branch=default_branch,
)
@app.route('/data')
def data():
branch = request.args.get('branch', GIT_BRANCHES[0])
docs = asyncio.run(fetch_github_yaml_files(branch))
apps = extract_apps(docs)
for app_data in apps:
app_data['latestVersion'] = "loading..."
return jsonify(apps)
@app.route('/latest')
def latest():
async def load_latest():
branch = request.args.get('branch', GIT_BRANCHES[0])
docs = await fetch_github_yaml_files(branch)
apps = extract_apps(docs)
tasks = [fetch_all_chart_versions(app['repoURL'], app['chart']) for app in apps]
all_versions_list = await asyncio.gather(*tasks)
enriched = []
for app, versions in zip(apps, all_versions_list):
if isinstance(versions, dict) and "error" in versions:
enriched.append({
"name": app["name"],
"chart": app["chart"],
"currentVersion": app["currentVersion"],
"latestVersion": "error",
"allVersions": []
})
else:
enriched.append({
"name": app["name"],
"chart": app["chart"],
"currentVersion": app["currentVersion"],
"latestVersion": versions[0],
"allVersions": versions
})
return enriched
results = asyncio.run(load_latest())
return jsonify(results)
if __name__ == "__main__":
app.run(debug=True)