@@ -24,6 +24,7 @@ import (
2424
2525// WALServiceImplementation is the implementation of the WAL Service
2626type WALServiceImplementation struct {
27+ ServerName string
2728 BarmanObjectKey client.ObjectKey
2829 ClusterObjectKey client.ObjectKey
2930 Client client.Client
@@ -72,16 +73,6 @@ func (w WALServiceImplementation) Archive(
7273 return nil , err
7374 }
7475
75- // TODO: refactor this code elsewhere
76- serverName := cluster .Name
77- for _ , plugin := range cluster .Spec .Plugins {
78- if plugin .IsEnabled () && plugin .Name == metadata .PluginName {
79- if pluginServerName , ok := plugin .Parameters ["serverName" ]; ok {
80- serverName = pluginServerName
81- }
82- }
83- }
84-
8576 var objectStore barmancloudv1.ObjectStore
8677 if err := w .Client .Get (ctx , w .BarmanObjectKey , & objectStore ); err != nil {
8778 return nil , err
@@ -111,7 +102,7 @@ func (w WALServiceImplementation) Archive(
111102 return nil , err
112103 }
113104
114- options , err := arch .BarmanCloudWalArchiveOptions (ctx , & objectStore .Spec .Configuration , serverName )
105+ options , err := arch .BarmanCloudWalArchiveOptions (ctx , & objectStore .Spec .Configuration , w . ServerName )
115106 if err != nil {
116107 return nil , err
117108 }
@@ -164,17 +155,7 @@ func (w WALServiceImplementation) Restore(
164155 }
165156 env = MergeEnv (env , credentialsEnv )
166157
167- // TODO: refactor this code elsewhere
168- serverName := cluster .Name
169- for _ , plugin := range cluster .Spec .Plugins {
170- if plugin .IsEnabled () && plugin .Name == metadata .PluginName {
171- if pluginServerName , ok := plugin .Parameters ["serverName" ]; ok {
172- serverName = pluginServerName
173- }
174- }
175- }
176-
177- options , err := barmanCommand .CloudWalRestoreOptions (ctx , barmanConfiguration , serverName )
158+ options , err := barmanCommand .CloudWalRestoreOptions (ctx , barmanConfiguration , w .ServerName )
178159 if err != nil {
179160 return nil , fmt .Errorf ("while getting barman-cloud-wal-restore options: %w" , err )
180161 }
0 commit comments