mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-12-24 22:37:19 +00:00
backport of commit 6be838e9e2 (#17303)
Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
93994bc135
commit
ed3cf6cd21
@@ -3,11 +3,12 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/posener/complete"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/posener/complete"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -119,12 +120,12 @@ func (c *NamespacePatchCommand) Run(args []string) int {
|
||||
|
||||
secret, err := client.Logical().JSONMergePatch(context.Background(), "sys/namespaces/"+namespacePath, data)
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error patching namespace: %s", err))
|
||||
return 2
|
||||
}
|
||||
if re, ok := err.(*api.ResponseError); ok && re.StatusCode == http.StatusNotFound {
|
||||
c.UI.Error("Namespace not found")
|
||||
return 2
|
||||
}
|
||||
|
||||
if secret == nil || secret.Data == nil {
|
||||
c.UI.Error(fmt.Sprintf("No namespace found: %s", err))
|
||||
c.UI.Error(fmt.Sprintf("Error patching namespace: %s", err))
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user