binapigen: enhanced vpp version resolution 77/33677/2
authorVladimir Lavor <vlavor@cisco.com>
Tue, 7 Sep 2021 13:21:19 +0000 (15:21 +0200)
committerOndrej Fabry <ofabry@cisco.com>
Wed, 8 Sep 2021 12:27:53 +0000 (12:27 +0000)
While assuming whether the VPP is installed (in order to retrieve a version),
the generator looks directly for the VPP executable instead of the API path.

This allows to get version if generated from any directory.

Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Change-Id: I147e4fba49c102bf5f1cbcf2784c212479dc15b6

binapigen/vppapi/util.go

index 3db8ef5..1374bb9 100644 (file)
@@ -42,12 +42,12 @@ func ResolveVPPVersion(apidir string) string {
        }
 
        // assuming VPP package is installed
-       if path.Clean(apidir) == DefaultDir {
+       if _, err := exec.LookPath("vpp"); err == nil {
                version, err := GetVPPVersionInstalled()
                if err != nil {
                        logrus.Warnf("resolving VPP version from installed package failed: %v", err)
                } else {
-                       logrus.Debugf("resolved VPP version from installed package: %v", version)
+                       logrus.Infof("resolved VPP version from installed package: %v", version)
                        return version
                }
        }