Skip to content

Commit 57c4898

Browse files
hossainemruztamalsaha
authored andcommitted
Fix argument passing (#8)
1 parent 15b1b3c commit 57c4898

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

pkg/backup.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path/filepath"
8+
"strings"
89
"time"
910

1011
"github.com/appscode/go/flags"
@@ -161,13 +162,19 @@ func (opt *esOptions) backupElasticsearch() (*restic.BackupOutput, error) {
161162
esShell.ShowCMD = false
162163
esShell.Stdout = ioutil.Discard
163164
esShell.SetEnv("NODE_TLS_REJECT_UNAUTHORIZED", "0") //xref: https://github.com/taskrabbit/elasticsearch-dump#bypassing-self-sign-certificate-errors
164-
esShell.Command(MultiElasticDumpCMD, // xref: multielasticdump: https://github.com/taskrabbit/elasticsearch-dump#multielasticdump
165+
166+
args := []interface{}{
165167
fmt.Sprintf(`--input=%v`, esURL),
166168
fmt.Sprintf(`--output=%v`, opt.interimDataDir),
167169
"--ignoreType=alias,settings,template", // ref: https://github.com/taskrabbit/elasticsearch-dump#multielasticdump
168170
tlsArgs,
169-
opt.esArgs,
170-
)
171+
}
172+
for _, arg := range strings.Fields(opt.esArgs) {
173+
args = append(args, arg)
174+
}
175+
176+
esShell.Command(MultiElasticDumpCMD, args...) // xref: multielasticdump: https://github.com/taskrabbit/elasticsearch-dump#multielasticdump
177+
171178
if err := esShell.Run(); err != nil {
172179
return nil, err
173180
}

pkg/restore.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path/filepath"
8+
"strings"
89

910
"github.com/appscode/go/flags"
1011
"github.com/appscode/go/log"
@@ -163,13 +164,19 @@ func (opt *esOptions) restoreElasticsearch() (*restic.RestoreOutput, error) {
163164
esShell.ShowCMD = false
164165
esShell.Stdout = ioutil.Discard
165166
esShell.SetEnv("NODE_TLS_REJECT_UNAUTHORIZED", "0") //xref: https://github.com/taskrabbit/elasticsearch-dump#bypassing-self-sign-certificate-errors
166-
esShell.Command(MultiElasticDumpCMD, // xref: multielasticdump: https://github.com/taskrabbit/elasticsearch-dump#multielasticdump
167+
168+
args := []interface{}{
167169
"--direction=load",
168170
fmt.Sprintf(`--input=%v`, opt.interimDataDir),
169171
fmt.Sprintf(`--output=%v`, esURL),
170172
tlsArgs,
171-
opt.esArgs,
172-
)
173+
}
174+
for _, arg := range strings.Fields(opt.esArgs) {
175+
args = append(args, arg)
176+
}
177+
178+
esShell.Command(MultiElasticDumpCMD, args...) // xref: multielasticdump: https://github.com/taskrabbit/elasticsearch-dump#multielasticdump
179+
173180
if err := esShell.Run(); err != nil {
174181
return nil, err
175182
}

0 commit comments

Comments
 (0)