Skip to content

Commit 334c583

Browse files
committed
Fix invalid pointer when copy connection
1 parent 0acb98d commit 334c583

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

sync/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func (database *Database) ApplyDefaults(server *Server) {
99
// set default connection if not set
1010
if database.Connection == nil {
11-
*database.Connection = *server.Connection
11+
database.Connection = server.Connection.Clone()
1212
}
1313
}
1414

sync/filesystem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func (filesystem *Filesystem) ApplyDefaults(server *Server) {
99
// set default connection if not set
1010
if filesystem.Connection == nil {
11-
*filesystem.Connection = *server.Connection
11+
filesystem.Connection = server.Connection.Clone()
1212
}
1313

1414
// set default path

sync/helper.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"github.com/webdevops/go-shell"
99
"fmt"
10+
"runtime/debug"
1011
)
1112

1213
func CreateTempfile() *os.File {
@@ -81,5 +82,9 @@ func ShellErrorHandler(recover interface{}) {
8182

8283
os.Exit(2)
8384
}
85+
} else {
86+
fmt.Print("ERROR:")
87+
fmt.Println(recover)
88+
debug.PrintStack()
8489
}
8590
}

sync/yaml_commandbuilder_connection.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sync
22

33
import (
4+
"github.com/mohae/deepcopy"
45
"github.com/webdevops/go-shell/commandbuilder"
56
)
67

@@ -54,3 +55,10 @@ func (yconn *YamlCommandBuilderConnection) IsEmpty() (status bool) {
5455

5556
return true
5657
}
58+
59+
// Clone yaml connection (without shell connection instance)
60+
func (yconn *YamlCommandBuilderConnection) Clone() (conn *YamlCommandBuilderConnection) {
61+
conn = deepcopy.Copy(yconn).(*YamlCommandBuilderConnection)
62+
conn.connection = nil
63+
return conn
64+
}

0 commit comments

Comments
 (0)