@@ -720,8 +720,7 @@ postgresql:
720
720
- pgbackrest
721
721
- basebackup
722
722
pgbackrest:
723
- command: '''bash'' ''-ceu'' ''--'' ''install --directory --mode=0700 "${PGDATA?}"
724
- && exec "$@"'' ''-'' ''some'' ''backrest'' ''cmd'''
723
+ command: '''some'' ''backrest'' ''cmd'''
725
724
keep_data: true
726
725
no_leader: true
727
726
no_params: true
@@ -786,40 +785,17 @@ func TestPGBackRestCreateReplicaCommand(t *testing.T) {
786
785
}
787
786
assert .NilError (t , yaml .Unmarshal ([]byte (data ), & parsed ))
788
787
789
- dir := t . TempDir ( )
788
+ assert . Equal ( t , parsed . PostgreSQL . PGBackRest . Command , `'some' 'backrest' 'cmd'` )
790
789
791
790
// The command should be compatible with any shell.
792
791
{
793
- command := parsed .PostgreSQL .PGBackRest .Command
794
- file := filepath .Join (dir , "command.sh" )
795
- assert .NilError (t , os .WriteFile (file , []byte (command ), 0o600 ))
792
+ file := filepath .Join (t .TempDir (), "command.sh" )
793
+ assert .NilError (t , os .WriteFile (file , []byte (parsed .PostgreSQL .PGBackRest .Command ), 0o600 ))
796
794
797
795
cmd := exec .CommandContext (t .Context (), shellcheck , "--enable=all" , "--shell=sh" , file )
798
796
output , err := cmd .CombinedOutput ()
799
797
assert .NilError (t , err , "%q\n %s" , cmd .Args , output )
800
798
}
801
-
802
- // Naive parsing of shell words...
803
- command := strings .Split (strings .Trim (parsed .PostgreSQL .PGBackRest .Command , "'" ), "' '" )
804
-
805
- // Expect a bash command with an inline script.
806
- assert .DeepEqual (t , command [:3 ], []string {"bash" , "-ceu" , "--" })
807
- assert .Assert (t , len (command ) > 3 )
808
- script := command [3 ]
809
-
810
- // It should call the pgBackRest command.
811
- assert .Assert (t , strings .HasSuffix (script , ` exec "$@"` ))
812
- assert .DeepEqual (t , command [len (command )- 3 :], []string {"some" , "backrest" , "cmd" })
813
-
814
- // It should pass shellcheck.
815
- {
816
- file := filepath .Join (dir , "script.bash" )
817
- assert .NilError (t , os .WriteFile (file , []byte (script ), 0o600 ))
818
-
819
- cmd := exec .CommandContext (t .Context (), shellcheck , "--enable=all" , file )
820
- output , err := cmd .CombinedOutput ()
821
- assert .NilError (t , err , "%q\n %s" , cmd .Args , output )
822
- }
823
799
}
824
800
825
801
func TestProbeTiming (t * testing.T ) {
0 commit comments