mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
fix namespace patch not found error message (#17242)
* fix namespace patch not found error message * handle 404 in namespace patch cmd
This commit is contained in:
@@ -3,11 +3,12 @@ package command
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/posener/complete"
|
"github.com/hashicorp/vault/api"
|
||||||
|
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -119,12 +120,12 @@ func (c *NamespacePatchCommand) Run(args []string) int {
|
|||||||
|
|
||||||
secret, err := client.Logical().JSONMergePatch(context.Background(), "sys/namespaces/"+namespacePath, data)
|
secret, err := client.Logical().JSONMergePatch(context.Background(), "sys/namespaces/"+namespacePath, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.UI.Error(fmt.Sprintf("Error patching namespace: %s", err))
|
if re, ok := err.(*api.ResponseError); ok && re.StatusCode == http.StatusNotFound {
|
||||||
return 2
|
c.UI.Error("Namespace not found")
|
||||||
}
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
if secret == nil || secret.Data == nil {
|
c.UI.Error(fmt.Sprintf("Error patching namespace: %s", err))
|
||||||
c.UI.Error(fmt.Sprintf("No namespace found: %s", err))
|
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user