@@ -15,6 +15,7 @@ import (
1515 "github.com/crunchydata/postgres-operator/internal/config"
1616 "github.com/crunchydata/postgres-operator/internal/naming"
1717 "github.com/crunchydata/postgres-operator/internal/postgres"
18+ "github.com/crunchydata/postgres-operator/internal/shell"
1819 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1920)
2021
@@ -34,12 +35,6 @@ const (
3435 "# Your changes will not be saved.\n "
3536)
3637
37- // quoteShellWord ensures that s is interpreted by a shell as single word.
38- func quoteShellWord (s string ) string {
39- // https://www.gnu.org/software/bash/manual/html_node/Quoting.html
40- return `'` + strings .ReplaceAll (s , `'` , `'"'"'` ) + `'`
41- }
42-
4338// clusterYAML returns Patroni settings that apply to the entire cluster.
4439func clusterYAML (
4540 cluster * v1beta1.PostgresCluster ,
@@ -581,15 +576,11 @@ func instanceYAML(
581576 "-" ,
582577 }, command ... )
583578
584- quoted := make ([]string , len (command ))
585- for i := range command {
586- quoted [i ] = quoteShellWord (command [i ])
587- }
588579 postgresql [pgBackRestCreateReplicaMethod ] = map [string ]any {
589- "command" : strings .Join (quoted , " " ),
590- "keep_data" : true ,
591- "no_leader" : true ,
592- "no_params" : true ,
580+ "command" : strings .Join (shell . QuoteWords ( command ... ) , " " ),
581+ "keep_data" : true , // Use the data directory from a prior method.
582+ "no_leader" : true , // Works without a replication connection.
583+ "no_params" : true , // Patroni should not add "--scope", "--role", etc.
593584 }
594585 methods = append ([]string {pgBackRestCreateReplicaMethod }, methods ... )
595586 }
0 commit comments