@@ -44,7 +44,9 @@ func (e *ConfigurationError) IsEmpty() bool {
4444
4545// PluginConfiguration is the configuration of the plugin
4646type PluginConfiguration struct {
47- BarmanObjectName string
47+ BarmanObjectName string
48+ RecoveryBarmanObjectName string
49+ RecoveryBarmanServerName string
4850}
4951
5052// NewFromCluster extracts the configuration from the cluster
@@ -54,22 +56,50 @@ func NewFromCluster(cluster *cnpgv1.Cluster) *PluginConfiguration {
5456 metadata .PluginName ,
5557 )
5658
59+ recoveryServerName := ""
60+ recoveryBarmanObjectName := ""
61+
62+ if recoveryParameters := getRecoveryParameters (cluster ); recoveryParameters != nil {
63+ recoveryBarmanObjectName = recoveryParameters ["barmanObjectName" ]
64+ recoveryServerName = recoveryParameters ["serverName" ]
65+ if len (recoveryServerName ) == 0 {
66+ recoveryServerName = cluster .Name
67+ }
68+ }
69+
5770 result := & PluginConfiguration {
5871 // used for the backup/archive
5972 BarmanObjectName : helper .Parameters ["barmanObjectName" ],
73+ // used for restore/wal_restore
74+ RecoveryBarmanServerName : recoveryServerName ,
75+ RecoveryBarmanObjectName : recoveryBarmanObjectName ,
6076 }
6177
6278 return result
6379}
6480
81+ func getRecoveryParameters (cluster * cnpgv1.Cluster ) map [string ]string {
82+ recoveryPluginConfiguration := cluster .GetRecoverySourcePlugin ()
83+ if recoveryPluginConfiguration == nil {
84+ return nil
85+ }
86+
87+ if recoveryPluginConfiguration .Name != metadata .PluginName {
88+ return nil
89+ }
90+
91+ return recoveryPluginConfiguration .Parameters
92+ }
93+
6594// Validate checks if the barmanObjectName is set
6695func (p * PluginConfiguration ) Validate () error {
6796 err := NewConfigurationError ()
68- if len (p .BarmanObjectName ) != 0 {
69- return nil
97+
98+ if len (p .BarmanObjectName ) == 0 && len (p .RecoveryBarmanObjectName ) == 0 {
99+ return err .WithMessage ("no reference to barmanObjectName have been included" )
70100 }
71101
72- return err . WithMessage ( "Missing barmanObjectName parameter" )
102+ return nil
73103}
74104
75105// Plugin represents a plugin with its associated cluster and parameters.
0 commit comments