From 8bea0988dd4aa6e8687e7cd01953da84cb59067a Mon Sep 17 00:00:00 2001 From: William Date: Wed, 29 Jan 2020 17:36:28 +1300 Subject: [PATCH] fix(api): lower Docker client API version for backwards support (#3534) --- api/docker/client.go | 4 ++-- api/http/proxy/factory/docker/configs.go | 6 +++--- api/http/proxy/factory/docker/secrets.go | 7 +++---- api/http/proxy/factory/docker/transport.go | 14 +++++++------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/api/docker/client.go b/api/docker/client.go index 9b63484e9..e063ad984 100644 --- a/api/docker/client.go +++ b/api/docker/client.go @@ -7,14 +7,14 @@ import ( "time" "github.com/docker/docker/client" - "github.com/portainer/portainer/api" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/crypto" ) const ( unsupportedEnvironmentType = portainer.Error("Environment not supported") defaultDockerRequestTimeout = 60 - dockerClientVersion = "1.40" + dockerClientVersion = "1.37" ) // ClientFactory is used to create Docker clients diff --git a/api/http/proxy/factory/docker/configs.go b/api/http/proxy/factory/docker/configs.go index e9092dc3f..540bbdef9 100644 --- a/api/http/proxy/factory/docker/configs.go +++ b/api/http/proxy/factory/docker/configs.go @@ -6,7 +6,7 @@ import ( "github.com/docker/docker/client" - "github.com/portainer/portainer/api" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/proxy/factory/responseutils" ) @@ -74,8 +74,8 @@ func (transport *Transport) configInspectOperation(response *http.Response, exec // selectorConfigLabels retrieve the labels object associated to the config object. // Labels are available under the "Spec.Labels" property. // API schema references: -// https://docs.docker.com/engine/api/v1.40/#operation/ConfigList -// https://docs.docker.com/engine/api/v1.40/#operation/ConfigInspect +// https://docs.docker.com/engine/api/v1.37/#operation/ConfigList +// https://docs.docker.com/engine/api/v1.37/#operation/ConfigInspect func selectorConfigLabels(responseObject map[string]interface{}) map[string]interface{} { secretSpec := responseutils.GetJSONObject(responseObject, "Spec") if secretSpec != nil { diff --git a/api/http/proxy/factory/docker/secrets.go b/api/http/proxy/factory/docker/secrets.go index 08a4045cf..522597bdb 100644 --- a/api/http/proxy/factory/docker/secrets.go +++ b/api/http/proxy/factory/docker/secrets.go @@ -6,9 +6,8 @@ import ( "github.com/docker/docker/client" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/proxy/factory/responseutils" - - "github.com/portainer/portainer/api" ) const ( @@ -75,8 +74,8 @@ func (transport *Transport) secretInspectOperation(response *http.Response, exec // selectorSecretLabels retrieve the labels object associated to the secret object. // Labels are available under the "Spec.Labels" property. // API schema references: -// https://docs.docker.com/engine/api/v1.40/#operation/SecretList -// https://docs.docker.com/engine/api/v1.40/#operation/SecretInspect +// https://docs.docker.com/engine/api/v1.37/#operation/SecretList +// https://docs.docker.com/engine/api/v1.37/#operation/SecretInspect func selectorSecretLabels(responseObject map[string]interface{}) map[string]interface{} { secretSpec := responseutils.GetJSONObject(responseObject, "Spec") if secretSpec != nil { diff --git a/api/http/proxy/factory/docker/transport.go b/api/http/proxy/factory/docker/transport.go index 469e3f67d..961a98223 100644 --- a/api/http/proxy/factory/docker/transport.go +++ b/api/http/proxy/factory/docker/transport.go @@ -13,7 +13,7 @@ import ( "github.com/portainer/portainer/api/docker" "github.com/docker/docker/client" - "github.com/portainer/portainer/api" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/proxy/factory/responseutils" "github.com/portainer/portainer/api/http/security" ) @@ -549,12 +549,12 @@ func (transport *Transport) interceptAndRewriteRequest(request *http.Request, op // on the resourceIdentifierAttribute parameter then generate a new resource control associated to that resource // with a random token and rewrites the response by decorating the original response with a ResourceControl object. // The generic Docker API response format is JSON object: -// https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate -// https://docs.docker.com/engine/api/v1.40/#operation/NetworkCreate -// https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate -// https://docs.docker.com/engine/api/v1.40/#operation/ServiceCreate -// https://docs.docker.com/engine/api/v1.40/#operation/SecretCreate -// https://docs.docker.com/engine/api/v1.40/#operation/ConfigCreate +// https://docs.docker.com/engine/api/v1.37/#operation/ContainerCreate +// https://docs.docker.com/engine/api/v1.37/#operation/NetworkCreate +// https://docs.docker.com/engine/api/v1.37/#operation/VolumeCreate +// https://docs.docker.com/engine/api/v1.37/#operation/ServiceCreate +// https://docs.docker.com/engine/api/v1.37/#operation/SecretCreate +// https://docs.docker.com/engine/api/v1.37/#operation/ConfigCreate func (transport *Transport) decorateGenericResourceCreationResponse(response *http.Response, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType, userID portainer.UserID) error { responseObject, err := responseutils.GetResponseAsJSONOBject(response) if err != nil {