@@ -207,13 +207,15 @@ func CreatePrimaryJobViaRestoreSnapshot(
207207
208208// CreatePrimaryJobViaRecovery creates a new primary instance in a Pod, restoring from a Backup
209209func CreatePrimaryJobViaRecovery (cluster apiv1.Cluster , nodeSerial int , backup * apiv1.Backup ) * batchv1.Job {
210- initCommand := []string {
210+ commonFlags := buildCommonInitJobFlags (cluster )
211+ initCommand := make ([]string , 0 , 3 + len (commonFlags ))
212+ initCommand = append (initCommand ,
211213 "/controller/manager" ,
212214 "instance" ,
213215 "restore" ,
214- }
216+ )
215217
216- initCommand = append (initCommand , buildCommonInitJobFlags ( cluster ) ... )
218+ initCommand = append (initCommand , commonFlags ... )
217219
218220 job := CreatePrimaryJob (cluster , nodeSerial , jobRoleFullRecovery , initCommand )
219221
@@ -248,41 +250,47 @@ func addBarmanEndpointCAToJobFromCluster(cluster apiv1.Cluster, backup *apiv1.Ba
248250
249251// CreatePrimaryJobViaPgBaseBackup creates a new primary instance in a Pod
250252func CreatePrimaryJobViaPgBaseBackup (cluster apiv1.Cluster , nodeSerial int ) * batchv1.Job {
251- initCommand := []string {
253+ commonFlags := buildCommonInitJobFlags (cluster )
254+ initCommand := make ([]string , 0 , 3 + len (commonFlags ))
255+ initCommand = append (initCommand ,
252256 "/controller/manager" ,
253257 "instance" ,
254258 "pgbasebackup" ,
255- }
259+ )
256260
257- initCommand = append (initCommand , buildCommonInitJobFlags ( cluster ) ... )
261+ initCommand = append (initCommand , commonFlags ... )
258262
259263 return CreatePrimaryJob (cluster , nodeSerial , jobRolePGBaseBackup , initCommand )
260264}
261265
262266// JoinReplicaInstance create a new PostgreSQL node, copying the contents from another Pod
263267func JoinReplicaInstance (cluster apiv1.Cluster , nodeSerial int ) * batchv1.Job {
264- initCommand := []string {
268+ commonFlags := buildCommonInitJobFlags (cluster )
269+ initCommand := make ([]string , 0 , 5 + len (commonFlags ))
270+ initCommand = append (initCommand ,
265271 "/controller/manager" ,
266272 "instance" ,
267273 "join" ,
268274 "--parent-node" , cluster .GetServiceReadWriteName (),
269- }
275+ )
270276
271- initCommand = append (initCommand , buildCommonInitJobFlags ( cluster ) ... )
277+ initCommand = append (initCommand , commonFlags ... )
272278
273279 return CreatePrimaryJob (cluster , nodeSerial , jobRoleJoin , initCommand )
274280}
275281
276282// RestoreReplicaInstance creates a new PostgreSQL replica starting from a volume snapshot backup
277283func RestoreReplicaInstance (cluster apiv1.Cluster , nodeSerial int ) * batchv1.Job {
278- initCommand := []string {
284+ commonFlags := buildCommonInitJobFlags (cluster )
285+ initCommand := make ([]string , 0 , 4 + len (commonFlags ))
286+ initCommand = append (initCommand ,
279287 "/controller/manager" ,
280288 "instance" ,
281289 "restoresnapshot" ,
282290 "--immediate" ,
283- }
291+ )
284292
285- initCommand = append (initCommand , buildCommonInitJobFlags ( cluster ) ... )
293+ initCommand = append (initCommand , commonFlags ... )
286294
287295 job := CreatePrimaryJob (cluster , nodeSerial , jobRoleSnapshotRecovery , initCommand )
288296 return job
0 commit comments