@@ -3,6 +3,7 @@ package bird
3
3
import (
4
4
"bufio"
5
5
"bytes"
6
+ "flag"
6
7
"fmt"
7
8
"io"
8
9
"net"
@@ -140,9 +141,15 @@ func RunCommand(command string, socket string) (string, string, error) {
140
141
return resp , birdVersion , nil // nil error
141
142
}
142
143
143
- var Validate = LocalValidate
144
+ func Validate (binary , cacheDir string ) error {
145
+ if flag .Lookup ("test.v" ) != nil {
146
+ return dockerValidate (binary , cacheDir )
147
+ } else {
148
+ return localValidate (binary , cacheDir )
149
+ }
150
+ }
144
151
145
- func DockerValidate (_ , _ string ) error {
152
+ func dockerValidate (_ , _ string ) error {
146
153
args := []string {
147
154
"docker" , "exec" ,
148
155
"pathvector-bird" ,
@@ -160,8 +167,8 @@ func DockerValidate(_, _ string) error {
160
167
return nil
161
168
}
162
169
163
- // LocalValidate checks if the cached configuration is syntactically valid
164
- func LocalValidate (binary string , cacheDir string ) error {
170
+ // localValidate checks if the cached configuration is syntactically valid
171
+ func localValidate (binary string , cacheDir string ) error {
165
172
log .Debugf ("Validating BIRD config" )
166
173
var outBuf , errBuf bytes.Buffer
167
174
birdCmd := exec .Command (binary , "-c" , "bird.conf" , "-p" )
0 commit comments