Attempt to read the cluster name from the insecure storage.
(b physical.Backend)
| 3396 | |
| 3397 | // Attempt to read the cluster name from the insecure storage. |
| 3398 | func (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 | |
| 3423 | func SetStorageMigration(b physical.Backend, active bool) error { |
| 3424 | if !active { |
no test coverage detected