diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2018-02-26 12:37:19 -0800 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2018-02-27 17:49:45 +0000 |
commit | 2199b03e5d7007ca125730c81304c10adf92dddc (patch) | |
tree | 2cfd68eb9b5ca856faeefa90d21d6f49a5f7ffa3 | |
parent | e2e955e442b8e47d9e88b4a6f334645bd33ef00f (diff) |
Adding deletedomain implementation
Adding deletedomain implementation in vault.go
This is a silent command and will not return any error
if the domain to be deleted does not exist
Issue-ID: AAF-144
Change-Id: Iff97a1a5be7415cd0c7ebb2894f16348718e2839
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
-rw-r--r-- | sms-service/src/sms/backend/vault.go | 12 | ||||
-rw-r--r-- | sms-service/src/sms/handler/handler.go | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/sms-service/src/sms/backend/vault.go b/sms-service/src/sms/backend/vault.go index 289fa3a..c3bbbc5 100644 --- a/sms-service/src/sms/backend/vault.go +++ b/sms-service/src/sms/backend/vault.go @@ -202,6 +202,18 @@ func (v *Vault) CreateSecret(dom string, sec Secret) error { // DeleteSecretDomain deletes a secret domain which translates to // an unmount operation on the given path in Vault func (v *Vault) DeleteSecretDomain(name string) error { + err := v.checkToken() + if err != nil { + return err + } + + name = strings.TrimSpace(name) + mountPath := v.vaultMount + "/" + name + + err = v.vaultClient.Sys().Unmount(mountPath) + if err != nil { + return errors.New("Unable to delete domain specified") + } return nil } diff --git a/sms-service/src/sms/handler/handler.go b/sms-service/src/sms/handler/handler.go index f5a0a0d..48d940f 100644 --- a/sms-service/src/sms/handler/handler.go +++ b/sms-service/src/sms/handler/handler.go @@ -70,7 +70,11 @@ func (h handler) deleteSecretDomainHandler(w http.ResponseWriter, r *http.Reques vars := mux.Vars(r) domName := vars["domName"] - h.secretBackend.DeleteSecretDomain(domName) + err := h.secretBackend.DeleteSecretDomain(domName) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } } // createSecretHandler handles creation of secrets on a given domain name |