From f66b447e0c345de869ea72e76b1d9bc318daaf94 Mon Sep 17 00:00:00 2001
From: jenkins-x-bot
Date: Mon, 14 Sep 2020 10:28:41 +0800
Subject: [PATCH] Update to support helm2
---
forms.py | 3 ++-
main.py | 22 ++++++++++++++++++----
routes/.nfs0000000000029d2200000001 | Bin 0 -> 12288 bytes
routes/.nfs0000000000029d2f00000002 | Bin 0 -> 12288 bytes
routes/kube_helm_routes.py | 18 ++++++++++--------
templates/nameChartSelect.html | 24 ++++++++++++++++++------
6 files changed, 48 insertions(+), 19 deletions(-)
create mode 100644 routes/.nfs0000000000029d2200000001
create mode 100644 routes/.nfs0000000000029d2f00000002
diff --git a/forms.py b/forms.py
index e9a7874..dc42c43 100644
--- a/forms.py
+++ b/forms.py
@@ -9,7 +9,8 @@ from flask_bootstrap import Bootstrap
class deploySelectForm(FlaskForm):
+ tiller_ns = SelectField('tiller_ns', choices=[], coerce=str)
namespace = SelectField('namespace', choices=[], coerce=str)
chart = SelectField('chart', choices=[])
version = SelectField('remember me')
- submitButton = SubmitField("Submit")
\ No newline at end of file
+ submitButton = SubmitField("Submit")
diff --git a/main.py b/main.py
index 820ca84..1651edf 100644
--- a/main.py
+++ b/main.py
@@ -28,6 +28,18 @@ def get_namespaces():
data = json.loads(output)
return data
+def get_tiller_namespaces():
+ command = "/usr/local/bin/kubectl get po --all-namespaces -l name=tiller -ojson"
+ info(f"Running command: {command}")
+ try:
+ output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
+ except CalledProcessError as err:
+ error(err.output.decode("utf-8"))
+ raise err
+ info(f"Output from command:\n{output}")
+ data = json.loads(output)
+ return data
+
def get_deployments(namespace):
command = "/usr/local/bin/kubectl -n " + namespace + " get deploy -ojson"
info(f"Running command: {command}")
@@ -40,8 +52,9 @@ def get_deployments(namespace):
data = json.loads(output)
return data
-def get_charts(namespace):
- command = "/usr/bin/helm -n " + namespace + " list -ojson"
+def get_charts(tiller_ns, namespace):
+ command = "/usr/bin/helm --tiller-namespace " + tiller_ns + " list -ojson" #helm2
+ #command = "/usr/bin/helm -n " + namespace + " list -ojson" #helm3
info(f"Running command: {command}")
try:
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
@@ -52,8 +65,9 @@ def get_charts(namespace):
data = json.loads(output)
return data
-def get_chartdata(namespace, chart):
- command = "/usr//bin/helm -n " + namespace + " history " + chart + " -ojson"
+def get_chartdata(tiller_ns, namespace, chart):
+ command = "/usr/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " -ojson" #helm2
+ #command = "/usr/bin/helm -n " + namespace + " history " + chart + " -ojson" #helm3
info(f"Running command: {command}")
print(f"Running command: {command}")
try:
diff --git a/routes/.nfs0000000000029d2200000001 b/routes/.nfs0000000000029d2200000001
new file mode 100644
index 0000000000000000000000000000000000000000..ec2f3a41bb490f98e6f6a0b5f3de6831908802c9
GIT binary patch
literal 12288
zcmeI2J&zMd7{>>yknnOz3TPr05Zblm^YSL;h|UNJK@~Nt6G~?5@{mBOfKYXQjW_o_XeZp83r)bGB}`
z&TW2k%UNliW4M+Wd-CRX@8t7?Z1o^xche*p>-Gg#8ja&DmkX>IduSZ`BQ8}K_;*6(
z$K#$<`EckDqd;yiXJa)=ljRYQVqc`W;?m#Fw|GxC^lU>b+e=0ZQy~K)u)hf8YPh^|
zWaHw6^Jc4`Iep6c{IiYy#eil@1c(3;AOb{y2oM1xKm_(V0hJwKkH7#w_s!KP?gw_=
zi;r|80z`la5CI}U1c(3;AOb{y2oM1xKmOZ>zdvH^QFl^c2dVe~&Qs7&-wRhyFaw*zeHK&_n1a=nH7)6UP34oB=Ud3+`vLN%l!*WlAOb{y2oM1x@IC|_T!O1y
zB+gx#CgE`G^+$nFvf(h@XFoV?=MGmr`@u_sn9D5a^M*0WM3|`gjb=dIO7Q!k4AZ2+
z27KrYcowDOYdYTdMTb{fG;QdnGl}*UyIMT3X>OkD&vD?dmL9J7t0q3~m5(cK(}_8r
z2p!0F$NlcxwRN|PucvyZ^C_4vJMVWw&{L@*+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3@`~|#b=kggMy+z*JrUht8etEL`%I#fl{6=lo&F6@8&Mt?N`
literal 0
HcmV?d00001
diff --git a/routes/kube_helm_routes.py b/routes/kube_helm_routes.py
index 6fd82ba..4983ec9 100644
--- a/routes/kube_helm_routes.py
+++ b/routes/kube_helm_routes.py
@@ -1,32 +1,34 @@
from flask import render_template, request, jsonify
from forms import deploySelectForm
-from main import get_namespaces, get_charts, get_chartdata
+from main import get_namespaces, get_charts, get_chartdata, get_tiller_namespaces
from . import routes
from tables import chartVersionTable
import json
@routes.route('/', methods=['GET', 'POST'])
def index():
+ tiller_ns = get_tiller_namespaces()
namespaces = get_namespaces()
- print(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, form=form)
+ return render_template('nameChartSelect.html', namespaces=namespaces, 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(namespace, chart)
+ chartVersions = get_chartdata(tiller_ns, namespace, chart)
table = chartVersionTable(chartVersions)
table.border = True
table.classes = ['table-striped', 'table-condensed', 'table-hover']
return render_template('chartRevisionList.html', table=table, namespace=namespace)
-@routes.route('/nsLookup/')
-def namespaceLookup(namespace):
- charts = get_charts(namespace)
+@routes.route('/nsLookup//')
+def namespaceLookup(tiller, namespace):
+ charts = get_charts(tiller, namespace)
return jsonify(charts)
@routes.route('/deployChartRevision///', methods=['POST'])
@@ -35,4 +37,4 @@ def deployChartRevision(revision, chart, namespace):
print(chart)
print(namespace)
charts = get_charts(namespace)
- return jsonify(charts)
\ No newline at end of file
+ return jsonify(charts)
diff --git a/templates/nameChartSelect.html b/templates/nameChartSelect.html
index 9b97fa5..48057a5 100644
--- a/templates/nameChartSelect.html
+++ b/templates/nameChartSelect.html
@@ -18,13 +18,21 @@
- Namespace:
- {{ form.namespace(class_="form-control") }}
+ Tiller Namespace:
+ {{ form.tiller_ns(class_="form-control") }}
- Chart:
+ Namespace:
+ {{ form.namespace(class_="form-control") }}
+
+
+
+
+
+
+ Chart:
{{ form.chart(class_="form-control") }}
@@ -36,20 +44,24 @@
+ dd