Skip to content

Commit d540c03

Browse files
committed
Remove commandbuilder (moved go go-shell)
1 parent 6af5c90 commit d540c03

10 files changed

Lines changed: 13 additions & 267 deletions

sync/config.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sync
33
import (
44
"regexp"
55
"sync"
6+
"github.com/webdevops/go-shell/commandbuilder"
67
)
78

89
var waitGroup sync.WaitGroup
@@ -20,14 +21,6 @@ type Filesystem struct {
2021
Filter Filter
2122
}
2223

23-
type Connection struct {
24-
Type string
25-
Hostname string
26-
User string
27-
Password string
28-
Docker string
29-
WorkDir string
30-
}
3124

3225
type Database struct {
3326
Type string
@@ -46,7 +39,7 @@ type Database struct {
4639
User string
4740
Password string
4841

49-
Connection Connection
42+
Connection commandbuilder.Connection
5043
}
5144
Options struct {
5245
ClearDatabase bool `yaml:"clear-database"`
@@ -56,7 +49,7 @@ type Database struct {
5649
cacheRemoteTableList []string
5750
cacheLocalTableList []string
5851

59-
remoteConnection Connection
52+
remoteConnection commandbuilder.Connection
6053
}
6154

6255
type Execution struct {
@@ -67,7 +60,7 @@ type Execution struct {
6760

6861
type Server struct {
6962
Path string
70-
Connection Connection
63+
Connection commandbuilder.Connection
7164
Filesystem []Filesystem
7265
Database []Database
7366
ExecStartup []Execution `yaml:"exec-startup"`

sync/connection.go

Lines changed: 0 additions & 136 deletions
This file was deleted.

sync/connection_docker.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

sync/connection_local.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

sync/connection_ssh.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

sync/database.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"fmt"
55
"strings"
66
"github.com/webdevops/go-shell"
7+
"github.com/webdevops/go-shell/commandbuilder"
78
)
89

910

10-
func (database *Database) mysqlTableFilter(connection *Connection, connectionType string) ([]string, []string) {
11+
func (database *Database) mysqlTableFilter(connection *commandbuilder.Connection, connectionType string) ([]string, []string) {
1112
var exclude []string
1213
var include []string
1314

sync/execution.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"strings"
55
"github.com/webdevops/go-shell"
66
"fmt"
7+
"github.com/webdevops/go-shell/commandbuilder"
78
)
89

910
func (execution *Execution) String(server *Server) string {
@@ -28,11 +29,11 @@ func (execution *Execution) Execute(server *Server) {
2829
}
2930

3031
func (execution *Execution) commandBuilder(server *Server) []interface{} {
31-
var connection Connection
32+
var connection commandbuilder.Connection
3233

3334
switch execution.GetType() {
3435
case "local":
35-
connection = Connection{Type:"local"}
36+
connection = commandbuilder.Connection{Type:"local"}
3637
case "remote":
3738
connection = server.Connection
3839
}

sync/helper.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,6 @@ import (
99
"fmt"
1010
)
1111

12-
func NewShellCommand(command string, args ...string) *shell.Command {
13-
return shell.Cmd(ShellCommandInterfaceBuilder(command, args...)...)
14-
}
15-
16-
func ShellCommandInterfaceBuilder(command string, args ...string) []interface{} {
17-
cmd := []string{
18-
command,
19-
}
20-
21-
for _, val := range args {
22-
cmd = append(cmd, val)
23-
}
24-
25-
shellCmd := make([]interface{}, len(cmd))
26-
for i, v := range cmd {
27-
shellCmd[i] = v
28-
}
29-
30-
return shellCmd
31-
}
32-
3312
func CreateTempfile() *os.File {
3413
tmpfile, err := ioutil.TempFile("", "gsync")
3514
if err != nil {

sync/server_deploy_filesystem.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"errors"
66
"os"
7+
"github.com/webdevops/go-shell"
78
)
89

910
// General sync
@@ -45,6 +46,6 @@ func (filesystem *Filesystem) deployRsync(server *Server) {
4546
// make sure source/target paths are using suffix slash
4647
args = append(args, RsyncPath(sourcePath), RsyncPath(targetPath))
4748

48-
cmd := NewShellCommand("rsync", args...)
49+
cmd := shell.NewCmd("rsync", args...)
4950
cmd.Run()
5051
}

sync/server_sync_filesystem.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"errors"
66
"os"
7+
"github.com/webdevops/go-shell"
78
)
89

910
// General sync
@@ -45,6 +46,6 @@ func (filesystem *Filesystem) syncRsync(server *Server) {
4546
// make sure source/target paths are using suffix slash
4647
args = append(args, RsyncPath(sourcePath), RsyncPath(targetPath))
4748

48-
cmd := NewShellCommand("rsync", args...)
49+
cmd := shell.NewCmd("rsync", args...)
4950
cmd.Run()
5051
}

0 commit comments

Comments
 (0)