plugin-barman-cloud/internal/cnpgi/common/backup.go
Armando Ruocco 44ae212756 feat(spike): restore
Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
2024-11-06 10:51:16 +01:00

21 lines
543 B
Go

package common
import (
"encoding/json"
"fmt"
barmanapi "github.com/cloudnative-pg/barman-cloud/pkg/api"
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
)
func GetCredentialsFromBackup(backup *cnpgv1.Backup) (barmanapi.BarmanCredentials, error) {
rawCred := backup.Status.PluginMetadata["credentials"]
var creds barmanapi.BarmanCredentials
if err := json.Unmarshal([]byte(rawCred), &creds); err != nil {
return barmanapi.BarmanCredentials{}, fmt.Errorf("while unmarshaling credentials: %w", err)
}
return creds, nil
}