flask-python-helm/routes/kube_helm_routes.py

39 lines
1.3 KiB
Python

from flask import render_template, request, jsonify
from forms import deploySelectForm
from main import get_namespaces, get_charts, get_chartdata, chartRollback
from . import routes
from tables import chartVersionTable
import json
@routes.route('/', methods=['GET', 'POST'])
def index():
ns = get_namespaces()
form = deploySelectForm()
form.ns.choices = [(name.metadata.name, name.metadata.name) for name in ns.items]
return render_template('nameChartSelect.html', ns=ns, form=form)
@routes.route('/chartSelect', methods=['POST'])
def chartVersions():
chart = request.form['chart']
records = request.form['records']
ns = request.form['ns']
chartVersions = get_chartdata(ns, chart, records)
table = chartVersionTable(chartVersions)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('chartRevisionList.html', table=table)
<<<<<<< HEAD
@routes.route('/nsLookup/<ns>/<namespace>')
=======
@routes.route('/nsLookup/<ns>')
>>>>>>> a7df40eb7710553f5d0185c3fa04ea6991c06f89
def namespaceLookup(ns):
charts = get_charts(ns)
return jsonify(charts)
@routes.route('/deployChartRevision/<revision>/<chart>/<ns>', methods=['POST'])
def deployChartRevision(revision, chart, tiller_ns):
rollback = chartRollback(revision, chart, ns)
return rollback