From a4ed98a20795afb435e31ee23d2bf3880a56c8e0 Mon Sep 17 00:00:00 2001 From: Adam Tengler Date: Tue, 23 Jan 2018 20:32:53 +0100 Subject: [PATCH] Helm views --- kqueen/blueprints/api/views.py | 38 ++++++++++++++++++++++++++++++++++ kqueen/helm.py | 4 ++++ 2 files changed, 42 insertions(+) diff --git a/kqueen/blueprints/api/views.py b/kqueen/blueprints/api/views.py index 1dd91d9c..40961bcc 100644 --- a/kqueen/blueprints/api/views.py +++ b/kqueen/blueprints/api/views.py @@ -13,6 +13,7 @@ from flask_jwt import jwt_required from importlib import import_module from kqueen.auth import encrypt_password +from kqueen.helm import HelmWrapper from kqueen.models import Cluster from kqueen.models import Organization from kqueen.models import Provisioner @@ -398,3 +399,40 @@ def swagger_json(): abort(500) return jsonify(data) + + +# Helm + +@api.route('/clusters//helm/install', methods=['POST']) +@jwt_required() +def helm_install(pk): + obj = get_object(Cluster, pk, current_identity) + + data = request.json + if not isinstance(data, dict) or (isinstance(data, dict) and 'name' not in data): + abort(400) + + helm = HelmWrapper(obj.kubeconfig) + return jsonify(helm.install(data['name'])) + + +@api.route('/clusters//helm/delete', methods=['POST']) +@jwt_required() +def helm_delete(pk): + obj = get_object(Cluster, pk, current_identity) + + data = request.json + if not isinstance(data, dict) or (isinstance(data, dict) and 'name' not in data): + abort(400) + + helm = HelmWrapper(obj.kubeconfig) + return jsonify(helm.delete(data['name'])) + + +@api.route('/clusters//helm/list', methods=['GET']) +@jwt_required() +def helm_list(pk): + obj = get_object(Cluster, pk, current_identity) + + helm = HelmWrapper(obj.kubeconfig) + return jsonify(helm.list()) diff --git a/kqueen/helm.py b/kqueen/helm.py index b0e10832..7add2b49 100644 --- a/kqueen/helm.py +++ b/kqueen/helm.py @@ -100,3 +100,7 @@ def repo_update(self): def reset(self): raw = self._call('helm reset') return self._no_parse(raw) + + def version(self): + raw = self._call('helm version') + return self._no_parse(raw)