MCPcopy
hub / github.com/hashicorp/vault / readClusterNameFromInsecureStorage

Method readClusterNameFromInsecureStorage

command/server.go:3398–3421  ·  view source on GitHub ↗

Attempt to read the cluster name from the insecure storage.

(b physical.Backend)

Source from the content-addressed store, hash-verified

3396
3397// Attempt to read the cluster name from the insecure storage.
3398func (c *ServerCommand) readClusterNameFromInsecureStorage(b physical.Backend) (string, error) {
3399 ctx := context.Background()
3400 entry, err := b.Get(ctx, "core/cluster/local/name")
3401 if err != nil {
3402 return "", err
3403 }
3404
3405 var result map[string]interface{}
3406 // Decode JSON data into the map
3407
3408 if entry != nil {
3409 if err := jsonutil.DecodeJSON(entry.Value, &result); err != nil {
3410 return "", fmt.Errorf("failed to decode JSON data: %w", err)
3411 }
3412 }
3413
3414 // Retrieve the value of the "name" field from the map
3415 name, ok := result["name"].(string)
3416 if !ok {
3417 return "", fmt.Errorf("failed to extract name field from decoded JSON")
3418 }
3419
3420 return name, nil
3421}
3422
3423func SetStorageMigration(b physical.Backend, active bool) error {
3424 if !active {

Callers 1

RunMethod · 0.95

Calls 2

DecodeJSONFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected