mirror of
https://github.com/cloudnative-pg/plugin-barman-cloud.git
synced 2026-01-11 21:23:12 +01:00
21 lines
543 B
Go
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
|
|
}
|