summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2021-09-28 21:42:24 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2021-09-28 21:43:02 +0200
commitdc62323aa7f6782d69c7ac6509eb270e86ef31bd (patch)
tree2f764f7816c44d9a62a0fe72b473ce5627ed89a9 /src/k8splugin/api
parent5aa8c4de9fd620ef42ac5bf73b62f76d80e713a0 (diff)
Fix for config resources delete with instance delete
Issue-ID: MULTICLOUD-1332 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com> Change-Id: I08a3d623d6f12777d88a168af0cb804c63104887
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r--src/k8splugin/api/api.go5
-rw-r--r--src/k8splugin/api/confighandler.go6
-rw-r--r--src/k8splugin/api/configtemplatehandler.go24
3 files changed, 30 insertions, 5 deletions
diff --git a/src/k8splugin/api/api.go b/src/k8splugin/api/api.go
index 94fb9b34..e34b93a2 100644
--- a/src/k8splugin/api/api.go
+++ b/src/k8splugin/api/api.go
@@ -123,6 +123,7 @@ func NewRouter(defClient rb.DefinitionManager,
}
templateHandler := rbTemplateHandler{client: templateClient}
resRouter.HandleFunc("/definition/{rbname}/{rbversion}/config-template", templateHandler.createHandler).Methods("POST")
+ resRouter.HandleFunc("/definition/{rbname}/{rbversion}/config-template", templateHandler.listHandler).Methods("GET")
resRouter.HandleFunc("/definition/{rbname}/{rbversion}/config-template/{tname}/content", templateHandler.uploadHandler).Methods("POST")
resRouter.HandleFunc("/definition/{rbname}/{rbversion}/config-template/{tname}", templateHandler.getHandler).Methods("GET")
resRouter.HandleFunc("/definition/{rbname}/{rbversion}/config-template/{tname}", templateHandler.deleteHandler).Methods("DELETE")
@@ -137,8 +138,8 @@ func NewRouter(defClient rb.DefinitionManager,
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.getHandler).Methods("GET")
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.updateHandler).Methods("PUT")
instRouter.HandleFunc("/instance/{instID}/config/{cfgname}", configHandler.deleteHandler).Methods("DELETE")
- instRouter.HandleFunc("/instance/{instID}/config/rollback", configHandler.rollbackHandler).Methods("POST")
- instRouter.HandleFunc("/instance/{instID}/config/tagit", configHandler.tagitHandler).Methods("POST")
+ instRouter.HandleFunc("/instance/{instID}/config/{cfgname}/rollback", configHandler.rollbackHandler).Methods("POST")
+ instRouter.HandleFunc("/instance/{instID}/config/{cfgname}/tagit", configHandler.tagitHandler).Methods("POST")
// Instance Healthcheck API
if healthcheckClient == nil {
diff --git a/src/k8splugin/api/confighandler.go b/src/k8splugin/api/confighandler.go
index c2236378..b0a8f851 100644
--- a/src/k8splugin/api/confighandler.go
+++ b/src/k8splugin/api/confighandler.go
@@ -176,6 +176,7 @@ func (h rbConfigHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
instanceID := vars["instID"]
+ cfgName := vars["cfgname"]
if r.Body == nil {
http.Error(w, "Empty body", http.StatusBadRequest)
@@ -188,7 +189,7 @@ func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request)
http.Error(w, err.Error(), http.StatusUnprocessableEntity)
return
}
- err = h.client.Rollback(instanceID, p)
+ err = h.client.Rollback(instanceID, cfgName, p)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -200,6 +201,7 @@ func (h rbConfigHandler) rollbackHandler(w http.ResponseWriter, r *http.Request)
func (h rbConfigHandler) tagitHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
instanceID := vars["instID"]
+ cfgName := vars["cfgname"]
if r.Body == nil {
http.Error(w, "Empty body", http.StatusBadRequest)
@@ -213,7 +215,7 @@ func (h rbConfigHandler) tagitHandler(w http.ResponseWriter, r *http.Request) {
return
}
- err = h.client.Tagit(instanceID, p)
+ err = h.client.Tagit(instanceID, cfgName, p)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/k8splugin/api/configtemplatehandler.go b/src/k8splugin/api/configtemplatehandler.go
index bd7c2db9..0560c7ea 100644
--- a/src/k8splugin/api/configtemplatehandler.go
+++ b/src/k8splugin/api/configtemplatehandler.go
@@ -20,9 +20,10 @@ import (
"encoding/json"
"io"
"io/ioutil"
- "github.com/onap/multicloud-k8s/src/k8splugin/internal/rb"
"net/http"
+ "github.com/onap/multicloud-k8s/src/k8splugin/internal/rb"
+
"github.com/gorilla/mux"
)
@@ -122,6 +123,27 @@ func (h rbTemplateHandler) getHandler(w http.ResponseWriter, r *http.Request) {
}
}
+// getHandler handles GET operations on a particular template
+func (h rbTemplateHandler) listHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ rbName := vars["rbname"]
+ rbVersion := vars["rbversion"]
+
+ ret, err := h.client.List(rbName, rbVersion)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
// deleteHandler handles DELETE operations on a template
func (h rbTemplateHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)