Skip to content

Commit

Permalink
Use port from AppBinding (#461)
Browse files Browse the repository at this point in the history
/cherry-pick

Signed-off-by: Emruz Hossain <[email protected]>

Ref: stashed/stash#1272
  • Loading branch information
hossainemruz authored and 1gtm committed Dec 17, 2020
1 parent 33294d8 commit b418cef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ func (opt *postgresOptions) backupPostgreSQL(targetRef api_v1beta1.TargetRef) (*
"-h", appBinding.Spec.ClientConfig.Service.Name,
},
}
// if port is specified, append port in the arguments
if appBinding.Spec.ClientConfig.Service.Port != 0 {
opt.backupOptions.StdinPipeCommand.Args = append(opt.backupOptions.StdinPipeCommand.Args, fmt.Sprintf("--port=%d", appBinding.Spec.ClientConfig.Service.Port))
}
for _, arg := range strings.Fields(opt.pgArgs) {
opt.backupOptions.StdinPipeCommand.Args = append(opt.backupOptions.StdinPipeCommand.Args, arg)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package pkg

import (
"context"
"fmt"
"path/filepath"
"strings"

Expand Down Expand Up @@ -182,6 +183,10 @@ func (opt *postgresOptions) restorePostgreSQL(targetRef api_v1beta1.TargetRef) (
"-h", appBinding.Spec.ClientConfig.Service.Name,
},
}
// if port is specified, append port in the arguments
if appBinding.Spec.ClientConfig.Service.Port != 0 {
opt.dumpOptions.StdoutPipeCommand.Args = append(opt.dumpOptions.StdoutPipeCommand.Args, fmt.Sprintf("--port=%d", appBinding.Spec.ClientConfig.Service.Port))
}
for _, arg := range strings.Fields(opt.pgArgs) {
opt.dumpOptions.StdoutPipeCommand.Args = append(opt.dumpOptions.StdoutPipeCommand.Args, arg)
}
Expand Down

0 comments on commit b418cef

Please sign in to comment.