diff --git a/forms.py b/forms.py index b8afd7d..4d59444 100644 --- a/forms.py +++ b/forms.py @@ -8,7 +8,7 @@ from wtforms.validators import InputRequired, Email, Length from flask_bootstrap import Bootstrap class deploySelectForm(FlaskForm): - tiller_ns = SelectField('tiller_ns', choices=[], coerce=str) + ns = SelectField('ns', choices=[], coerce=str) chart = SelectField('chart', choices=[]) version = SelectField('remember me') # Added if/when I want to add additional helm version options records = SelectField('records', choices=[('10', '10'), ('20', '20'), ('30', '30'), ('40', '40'), ('50', '50'), ('100', '100'), ('150', '150'), ('200', '200'), ('256', '256 (max)')], default=['10']) diff --git a/main.py b/main.py index fe8243d..9fa1e69 100644 --- a/main.py +++ b/main.py @@ -19,19 +19,11 @@ app.register_blueprint(routes) def get_namespaces(): config.load_incluster_config() - v1 = client.Corev1Api() + v1 = client.CoreV1Api() ns = v1.list_namespace() - print(ns) - command = "/usr/local/bin/kubectl get ns -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 + for namespace in ns.items: + print("%s" % (namespace.metadata.name)) + return ns def get_tiller_namespaces(): command = "/usr/local/bin/kubectl get deploy --all-namespaces -l name=tiller -ojson" diff --git a/routes/kube_helm_routes.py b/routes/kube_helm_routes.py index 3ee87ec..d570b7c 100644 --- a/routes/kube_helm_routes.py +++ b/routes/kube_helm_routes.py @@ -7,10 +7,10 @@ import json @routes.route('/', methods=['GET', 'POST']) def index(): - tiller_ns = get_tiller_namespaces() + ns = get_namespaces() form = deploySelectForm() - form.tiller_ns.choices = [(name['metadata']['namespace'], name['metadata']['namespace']) for name in tiller_ns['items']] - return render_template('nameChartSelect.html', tiller_ns=tiller_ns, form=form) + 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():