Skip to content

Commit 723403f

Browse files
authored
Use port from AppBinding (#461) (#490)
/cherry-pick Signed-off-by: Emruz Hossain <emruz@appscode.com> Ref: stashed/stash#1272
1 parent 8b973a4 commit 723403f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/backup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ func (opt *postgresOptions) backupPostgreSQL(targetRef api_v1beta1.TargetRef) (*
221221
"-h", appBinding.Spec.ClientConfig.Service.Name,
222222
},
223223
}
224+
// if port is specified, append port in the arguments
225+
if appBinding.Spec.ClientConfig.Service.Port != 0 {
226+
opt.backupOptions.StdinPipeCommand.Args = append(opt.backupOptions.StdinPipeCommand.Args, fmt.Sprintf("--port=%d", appBinding.Spec.ClientConfig.Service.Port))
227+
}
224228
for _, arg := range strings.Fields(opt.pgArgs) {
225229
opt.backupOptions.StdinPipeCommand.Args = append(opt.backupOptions.StdinPipeCommand.Args, arg)
226230
}

pkg/restore.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package pkg
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"path/filepath"
2223
"strings"
2324

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

0 commit comments

Comments
 (0)