summaryrefslogtreecommitdiff
path: root/pkg/bindings/connection.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-05-22 11:43:37 -0700
committerJhon Honce <jhonce@redhat.com>2020-05-26 10:00:15 -0700
commit1fb907198f67462aaef553b7b831c7ff72189564 (patch)
tree5e43539094efcc2474e94e15b882c6c41599467d /pkg/bindings/connection.go
parente1193c8703489b8aba5cc093a7339eff6d2559d8 (diff)
downloadpodman-1fb907198f67462aaef553b7b831c7ff72189564.tar.gz
podman-1fb907198f67462aaef553b7b831c7ff72189564.tar.bz2
podman-1fb907198f67462aaef553b7b831c7ff72189564.zip
V2 Fix interface nil checks
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/bindings/connection.go')
-rw-r--r--pkg/bindings/connection.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index d21d55beb..d30698c1d 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -16,7 +16,6 @@ import (
"time"
"github.com/blang/semver"
- "github.com/containers/libpod/pkg/api/types"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -28,7 +27,7 @@ var (
basePath = &url.URL{
Scheme: "http",
Host: "d",
- Path: "/v" + types.MinimalAPIVersion + "/libpod",
+ Path: "/v" + APIVersion.String() + "/libpod",
}
)
@@ -157,17 +156,22 @@ func pingNewConnection(ctx context.Context) error {
}
if response.StatusCode == http.StatusOK {
- v, err := semver.ParseTolerant(response.Header.Get("Libpod-API-Version"))
+ versionHdr := response.Header.Get("Libpod-API-Version")
+ if versionHdr == "" {
+ logrus.Info("Service did not provide Libpod-API-Version Header")
+ return nil
+ }
+ versionSrv, err := semver.ParseTolerant(versionHdr)
if err != nil {
return err
}
- switch APIVersion.Compare(v) {
+ switch APIVersion.Compare(versionSrv) {
case 1, 0:
// Server's job when client version is equal or older
return nil
case -1:
- return errors.Errorf("server API version is too old. client %q server %q", APIVersion.String(), v.String())
+ return errors.Errorf("server API version is too old. client %q server %q", APIVersion.String(), versionSrv.String())
}
}
return errors.Errorf("ping response was %q", response.StatusCode)