Skip to content

Commit

Permalink
Enforce dependencies check at runtime
Browse files Browse the repository at this point in the history
Currently the binaries version are only checked when called
with flag "version". Now enforce it so that it fails with explicit
error message in case of missing binary or incorrect version installed.

Also update the dataplaneapi dependency version, as it requires
v2.1 since commit 8b553af
  • Loading branch information
mougams committed Sep 7, 2022
1 parent ed757dd commit fb08dee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion haproxy/haproxy_cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,20 @@ func CheckEnvironment(dataplaneapiBin, haproxyBin string) error {
currVer, e := getVersion(path)
if e != nil {
err = e
return
}
res, e := compareVersion(currVer, minVer)
if e != nil {
err = e
return
}
if res < 0 {
err = fmt.Errorf("%s version must be > %s, but is: %s", path, minVer, currVer)
return
}
}
go ensureVersion(haproxyBin, "2.0")
go ensureVersion(dataplaneapiBin, "1.2")
go ensureVersion(dataplaneapiBin, "2.1")

wg.Wait()
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ func main() {
flag.Parse()
if versionFlag != nil && *versionFlag {
fmt.Printf("Version: %s ; BuildTime: %s ; GitHash: %s\n", Version, BuildTime, GitHash)
status := 0
if err := validateRequirements(*dataplaneBin, *haproxyBin); err != nil {
fmt.Printf("ERROR: dataplane API / HAProxy dependencies are not satisfied: %s\n", err)
status = 4
}
os.Exit(status)
os.Exit(0)
}
if err := validateRequirements(*dataplaneBin, *haproxyBin); err != nil {
fmt.Printf("ERROR: dataplane API / HAProxy dependencies are not satisfied: %s\n", err)
os.Exit(4)
}

ll, err := log.ParseLevel(*logLevel)
Expand Down

0 comments on commit fb08dee

Please sign in to comment.