-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbr_instance.go
More file actions
96 lines (76 loc) · 1.85 KB
/
Copy pathdbr_instance.go
File metadata and controls
96 lines (76 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package ropdb
type DbrInstance struct {
handle string
dbname string
connectionUsername string
connectionPassword string
dbrUsername string
dbrPassword string
host string
dbfile *string
module string
tag *string
}
func (dbr *DbrInstance) Copy() *DbrInstance {
if dbr == nil {
return nil
}
copy := *dbr
// Make sure the pointers to strings aren't copied.
copy.dbfile = nil
if dbr.dbfile != nil {
dbfileCopy := *dbr.dbfile
copy.dbfile = &dbfileCopy
}
copy.tag = nil
if dbr.tag != nil {
tagCopy := *dbr.tag
copy.tag = &tagCopy
}
return ©
}
// Same loosely checks if the dbr instances are using the same database,
// if they aren't the same then it returns what was different.
func (dbr *DbrInstance) SameDatabase(other *DbrInstance) (bool, []string) {
var differences []string
if dbr.DatabaseName() != other.DatabaseName() {
differences = append(differences, "database name")
}
if dbr.Host() != other.Host() {
differences = append(differences, "host")
}
if len(differences) > 0 {
return false, differences
}
return true, []string{}
}
func (dbr *DbrInstance) Handle() string {
return dbr.handle
}
func (dbr *DbrInstance) DatabaseName() string {
return dbr.dbname
}
func (dbr *DbrInstance) ConnectionUsername() string {
return dbr.connectionUsername
}
func (dbr *DbrInstance) ConnectionPassword() string {
return dbr.connectionPassword
}
func (dbr *DbrInstance) DbrUsername() string {
return dbr.dbrUsername
}
func (dbr *DbrInstance) DbrPassword() string {
return dbr.dbrPassword
}
func (dbr *DbrInstance) Host() string {
return dbr.host
}
func (dbr *DbrInstance) DatabaseFile() *string {
return dbr.dbfile
}
func (dbr *DbrInstance) Module() string {
return dbr.module
}
func (dbr *DbrInstance) Tag() *string {
return dbr.tag
}