summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-16 04:06:30 +0200
committerGitHub <noreply@github.com>2020-09-16 04:06:30 +0200
commit26049193e0829c2ac841ff852732ddb4223a01fb (patch)
tree47ec84131bf8164941e5def9c347210fefc1fc5b /pkg
parent32b49463d9f38e6bdf4ad521a4b11fa17d836050 (diff)
parent8a8bae8299dff8d10c0a2f5873190e19a83ea01c (diff)
downloadpodman-26049193e0829c2ac841ff852732ddb4223a01fb.tar.gz
podman-26049193e0829c2ac841ff852732ddb4223a01fb.tar.bz2
podman-26049193e0829c2ac841ff852732ddb4223a01fb.zip
Merge pull request #7642 from jwhonce/issues/7327-2
Refactor API version values
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/ping.go4
-rw-r--r--pkg/api/handlers/compat/version.go8
-rw-r--r--pkg/api/handlers/utils/handler.go4
-rw-r--r--pkg/api/server/handler_api.go4
4 files changed, 13 insertions, 7 deletions
diff --git a/pkg/api/handlers/compat/ping.go b/pkg/api/handlers/compat/ping.go
index eb7eed5b6..06150bb63 100644
--- a/pkg/api/handlers/compat/ping.go
+++ b/pkg/api/handlers/compat/ping.go
@@ -5,7 +5,6 @@ import (
"net/http"
"github.com/containers/buildah"
- "github.com/containers/podman/v2/pkg/api/handlers/utils"
)
// Ping returns headers to client about the service
@@ -14,13 +13,12 @@ import (
// Clients will use the Header availability to test which backend engine is in use.
// Note: Additionally handler supports GET and HEAD methods
func Ping(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("API-Version", utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion].String())
+ // Note API-Version and Libpod-API-Version are set in handler_api.go
w.Header().Set("BuildKit-Version", "")
w.Header().Set("Docker-Experimental", "true")
w.Header().Set("Cache-Control", "no-cache")
w.Header().Set("Pragma", "no-cache")
- w.Header().Set("Libpod-API-Version", utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String())
w.Header().Set("Libpod-Buildha-Version", buildah.Version)
w.WriteHeader(http.StatusOK)
diff --git a/pkg/api/handlers/compat/version.go b/pkg/api/handlers/compat/version.go
index e12c7cefa..92900b75d 100644
--- a/pkg/api/handlers/compat/version.go
+++ b/pkg/api/handlers/compat/version.go
@@ -30,6 +30,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "Failed to obtain system memory info"))
return
}
+
components := []docker.ComponentVersion{{
Name: "Podman Engine",
Version: versionInfo.Version,
@@ -46,6 +47,9 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
},
}}
+ apiVersion := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion]
+ minVersion := utils.APIVersion[utils.CompatTree][utils.MinimalAPIVersion]
+
utils.WriteResponse(w, http.StatusOK, entities.ComponentVersion{
Version: docker.Version{
Platform: struct {
@@ -53,7 +57,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
}{
Name: fmt.Sprintf("%s/%s/%s-%s", goRuntime.GOOS, goRuntime.GOARCH, infoData.Host.Distribution.Distribution, infoData.Host.Distribution.Version),
},
- APIVersion: components[0].Details["APIVersion"],
+ APIVersion: fmt.Sprintf("%d.%d", apiVersion.Major, apiVersion.Minor),
Arch: components[0].Details["Arch"],
BuildTime: components[0].Details["BuildTime"],
Components: components,
@@ -61,7 +65,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) {
GitCommit: components[0].Details["GitCommit"],
GoVersion: components[0].Details["GoVersion"],
KernelVersion: components[0].Details["KernelVersion"],
- MinAPIVersion: components[0].Details["MinAPIVersion"],
+ MinAPIVersion: fmt.Sprintf("%d.%d", minVersion.Major, minVersion.Minor),
Os: components[0].Details["Os"],
Version: components[0].Version,
}})
diff --git a/pkg/api/handlers/utils/handler.go b/pkg/api/handlers/utils/handler.go
index 62fdc05dd..517dccad0 100644
--- a/pkg/api/handlers/utils/handler.go
+++ b/pkg/api/handlers/utils/handler.go
@@ -43,8 +43,8 @@ var (
// clients to shop for the Version they wish to support
APIVersion = map[VersionTree]map[VersionLevel]semver.Version{
LibpodTree: {
- CurrentAPIVersion: semver.MustParse("1.0.0"),
- MinimalAPIVersion: semver.MustParse("1.0.0"),
+ CurrentAPIVersion: semver.MustParse("2.0.0"),
+ MinimalAPIVersion: semver.MustParse("2.0.0"),
},
CompatTree: {
CurrentAPIVersion: semver.MustParse("1.40.0"),
diff --git a/pkg/api/server/handler_api.go b/pkg/api/server/handler_api.go
index e47b66bb4..f2ce0301b 100644
--- a/pkg/api/server/handler_api.go
+++ b/pkg/api/server/handler_api.go
@@ -40,6 +40,10 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc {
c = context.WithValue(c, "idletracker", s.idleTracker) //nolint
r = r.WithContext(c)
+ v := utils.APIVersion[utils.CompatTree][utils.CurrentAPIVersion]
+ w.Header().Set("API-Version", fmt.Sprintf("%d.%d", v.Major, v.Minor))
+ w.Header().Set("Libpod-API-Version", utils.APIVersion[utils.LibpodTree][utils.CurrentAPIVersion].String())
+
h(w, r)
}
fn(w, r)