@@ -77,11 +77,13 @@ func (v *VSwitchService) ListPorts(bridge string) ([]string, error) {
77
77
return nil , err
78
78
}
79
79
80
- if string (output ) == "" {
80
+ // Do no ports exist?
81
+ if len (output ) == 0 {
81
82
return nil , nil
82
83
}
84
+
83
85
ports := strings .Split (strings .TrimSpace (string (output )), "\n " )
84
- return ports , err
86
+ return ports , nil
85
87
}
86
88
87
89
// ListBridges lists the bridges in Open vSwitch.
@@ -91,11 +93,13 @@ func (v *VSwitchService) ListBridges() ([]string, error) {
91
93
return nil , err
92
94
}
93
95
94
- if string (output ) == "" {
96
+ // Do no bridges exist?
97
+ if len (output ) == 0 {
95
98
return nil , nil
96
99
}
100
+
97
101
bridges := strings .Split (strings .TrimSpace (string (output )), "\n " )
98
- return bridges , err
102
+ return bridges , nil
99
103
}
100
104
101
105
// PortToBridge attempts to determine which bridge a port is attached to.
@@ -116,7 +120,8 @@ func (v *VSwitchService) GetFailMode(bridge string) (FailMode, error) {
116
120
if err != nil {
117
121
return "" , err
118
122
}
119
- return FailMode (out ), err
123
+
124
+ return FailMode (out ), nil
120
125
}
121
126
122
127
// SetFailMode sets the specified FailMode for the specified bridge.
@@ -138,7 +143,8 @@ func (v *VSwitchService) GetController(bridge string) (string, error) {
138
143
if err != nil {
139
144
return "" , err
140
145
}
141
- return strings .TrimSpace (string (address )), err
146
+
147
+ return strings .TrimSpace (string (address )), nil
142
148
}
143
149
144
150
// exec executes an ExecFunc using 'ovs-vsctl'.
@@ -162,12 +168,15 @@ func (v *VSwitchGetService) Bridge(bridge string) (BridgeOptions, error) {
162
168
if err != nil {
163
169
return BridgeOptions {}, err
164
170
}
165
- protocols := [] string {}
166
- err = json . Unmarshal ( out , & protocols )
167
- if err != nil {
171
+
172
+ var protocols [] string
173
+ if err := json . Unmarshal ( out , & protocols ); err != nil {
168
174
return BridgeOptions {}, err
169
175
}
170
- return BridgeOptions {Protocols : protocols }, nil
176
+
177
+ return BridgeOptions {
178
+ Protocols : protocols ,
179
+ }, nil
171
180
}
172
181
173
182
// A VSwitchSetService is used in a VSwitchService to execute 'ovs-vsctl set'
0 commit comments