Update code

This commit is contained in:
Jonathan Ervine
2020-12-15 11:24:37 +08:00
parent 7e98a6023f
commit 6b8562662c
13 changed files with 130 additions and 262 deletions
Binary file not shown.
Binary file not shown.
+13 -17
View File
@@ -1,6 +1,6 @@
from flask import render_template, request, jsonify
from forms import deploySelectForm
from main import get_namespaces, get_charts, get_chartdata, get_tiller_namespaces
from main import get_namespaces, get_charts, get_chartdata, get_tiller_namespaces, chartRollback
from . import routes
from tables import chartVersionTable
import json
@@ -8,33 +8,29 @@ import json
@routes.route('/', methods=['GET', 'POST'])
def index():
tiller_ns = get_tiller_namespaces()
namespaces = get_namespaces()
form = deploySelectForm()
form.tiller_ns.choices = [(name['metadata']['namespace'], name['metadata']['namespace']) for name in tiller_ns['items']]
form.namespace.choices = [(name['metadata']['name'], name['metadata']['name']) for name in namespaces['items']]
return render_template('nameChartSelect.html', namespaces=namespaces, tiller_ns=tiller_ns, form=form)
return render_template('nameChartSelect.html', tiller_ns=tiller_ns, form=form)
@routes.route('/chartSelect', methods=['POST'])
def chartVersions():
namespace = request.form['namespace']
tiller_ns = request.form['tiller_ns']
chart = request.form['chart']
chartVersions = get_chartdata(tiller_ns, namespace, chart)
records = request.form['records']
namespace = 'default'
chartVersions = get_chartdata(tiller_ns, namespace, chart, records)
table = chartVersionTable(chartVersions)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('chartRevisionList.html', table=table, namespace=namespace)
return render_template('chartRevisionList.html', table=table)
@routes.route('/nsLookup/<tiller>/<namespace>')
def namespaceLookup(tiller, namespace):
charts = get_charts(tiller, namespace)
@routes.route('/nsLookup/<tiller_ns>/<namespace>')
def namespaceLookup(tiller_ns, namespace):
charts = get_charts(tiller_ns, namespace)
return jsonify(charts)
@routes.route('/deployChartRevision/<revision>/<chart>/<namespace>', methods=['POST'])
def deployChartRevision(revision, chart, namespace):
print(revision)
print(chart)
print(namespace)
charts = get_charts(namespace)
return jsonify(charts)
@routes.route('/deployChartRevision/<revision>/<chart>/<tiller_ns>', methods=['POST'])
def deployChartRevision(revision, chart, tiller_ns):
rollback = chartRollback(revision, chart, tiller_ns)
return rollback