From 4b2dca4355df279a57a03463bd47eac9a0afba65 Mon Sep 17 00:00:00 2001 From: jenkins-x-bot Date: Mon, 14 Sep 2020 13:55:18 +0800 Subject: [PATCH] Added helm2 specifics --- forms.py | 1 - main.py | 3 +-- routes/kube_helm_routes.py | 15 ++++++--------- tables.py | 16 ++++++++-------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/forms.py b/forms.py index dc42c43..8a4ea6b 100644 --- a/forms.py +++ b/forms.py @@ -7,7 +7,6 @@ from wtforms import validators, ValidationError from wtforms.validators import InputRequired, Email, Length from flask_bootstrap import Bootstrap - class deploySelectForm(FlaskForm): tiller_ns = SelectField('tiller_ns', choices=[], coerce=str) namespace = SelectField('namespace', choices=[], coerce=str) diff --git a/main.py b/main.py index 9077fe8..a4682f7 100644 --- a/main.py +++ b/main.py @@ -69,7 +69,6 @@ def get_chartdata(tiller_ns, namespace, chart): command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " --output json" #helm2 #command = "/usr/local/bin/helm -n " + namespace + " history " + chart + " -ojson" #helm3 info(f"Running command: {command}") - print(f"Running command: {command}") try: output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8") except CalledProcessError as err: @@ -79,7 +78,7 @@ def get_chartdata(tiller_ns, namespace, chart): data = json.loads(output) for revision in data: revision["namespace"] = namespace - print(data[0]) + revision["tiller_ns"] = tiller_ns return data if __name__ == "__main__": diff --git a/routes/kube_helm_routes.py b/routes/kube_helm_routes.py index 4983ec9..58662a5 100644 --- a/routes/kube_helm_routes.py +++ b/routes/kube_helm_routes.py @@ -26,15 +26,12 @@ def chartVersions(): return render_template('chartRevisionList.html', table=table, namespace=namespace) -@routes.route('/nsLookup//') -def namespaceLookup(tiller, namespace): - charts = get_charts(tiller, namespace) +@routes.route('/nsLookup///') +def namespaceLookup(tiller, namespace, tiller_ns): + charts = get_charts(tiller, namespace, tiller_ns) return jsonify(charts) -@routes.route('/deployChartRevision///', methods=['POST']) -def deployChartRevision(revision, chart, namespace): - print(revision) - print(chart) - print(namespace) - charts = get_charts(namespace) +@routes.route('/deployChartRevision////', methods=['POST']) +def deployChartRevision(revision, chart, namespace, tiller_ns): + charts = get_charts(tiller_ns, namespace) return jsonify(charts) diff --git a/tables.py b/tables.py index 90caf64..9119f9b 100644 --- a/tables.py +++ b/tables.py @@ -1,11 +1,11 @@ from flask_table import Table, Col, LinkCol, ButtonCol class chartVersionTable(Table): - Revision = Col('Chart Revision') - Updated = Col('Updated') - Status = Col('Status') - Namespace = Col('Namespace') - Chart = Col('Chart Version') - AppVersion = Col('Application Version') - Description = Col('Description') - deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='Revision', chart='Chart', namespace='Namespace'), button_attrs={"type" : "submit", "class" : "btn btn-danger"}) + revision = Col('Chart Revision') + updated = Col('Updated') + status = Col('Status') + namespace = Col('Namespace') + tiller_ns = Col('Tiiler Namespace') + chart = Col('Chart Version') + description = Col('Description') + deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='revision', chart='chart', namespace='namespace', tiller_ns='tiller_ns'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})