fix(api): lower Docker client API version for backwards support (#3534)

pull/3537/head
William 2020-01-29 17:36:28 +13:00 committed by GitHub
parent 8dda67c8d0
commit 8bea0988dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 16 deletions

View File

@ -7,14 +7,14 @@ import (
"time" "time"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/portainer/portainer/api" portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/crypto" "github.com/portainer/portainer/api/crypto"
) )
const ( const (
unsupportedEnvironmentType = portainer.Error("Environment not supported") unsupportedEnvironmentType = portainer.Error("Environment not supported")
defaultDockerRequestTimeout = 60 defaultDockerRequestTimeout = 60
dockerClientVersion = "1.40" dockerClientVersion = "1.37"
) )
// ClientFactory is used to create Docker clients // ClientFactory is used to create Docker clients

View File

@ -6,7 +6,7 @@ import (
"github.com/docker/docker/client" "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/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. // selectorConfigLabels retrieve the labels object associated to the config object.
// Labels are available under the "Spec.Labels" property. // Labels are available under the "Spec.Labels" property.
// API schema references: // API schema references:
// https://docs.docker.com/engine/api/v1.40/#operation/ConfigList // https://docs.docker.com/engine/api/v1.37/#operation/ConfigList
// https://docs.docker.com/engine/api/v1.40/#operation/ConfigInspect // https://docs.docker.com/engine/api/v1.37/#operation/ConfigInspect
func selectorConfigLabels(responseObject map[string]interface{}) map[string]interface{} { func selectorConfigLabels(responseObject map[string]interface{}) map[string]interface{} {
secretSpec := responseutils.GetJSONObject(responseObject, "Spec") secretSpec := responseutils.GetJSONObject(responseObject, "Spec")
if secretSpec != nil { if secretSpec != nil {

View File

@ -6,9 +6,8 @@ import (
"github.com/docker/docker/client" "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/http/proxy/factory/responseutils"
"github.com/portainer/portainer/api"
) )
const ( const (
@ -75,8 +74,8 @@ func (transport *Transport) secretInspectOperation(response *http.Response, exec
// selectorSecretLabels retrieve the labels object associated to the secret object. // selectorSecretLabels retrieve the labels object associated to the secret object.
// Labels are available under the "Spec.Labels" property. // Labels are available under the "Spec.Labels" property.
// API schema references: // API schema references:
// https://docs.docker.com/engine/api/v1.40/#operation/SecretList // https://docs.docker.com/engine/api/v1.37/#operation/SecretList
// https://docs.docker.com/engine/api/v1.40/#operation/SecretInspect // https://docs.docker.com/engine/api/v1.37/#operation/SecretInspect
func selectorSecretLabels(responseObject map[string]interface{}) map[string]interface{} { func selectorSecretLabels(responseObject map[string]interface{}) map[string]interface{} {
secretSpec := responseutils.GetJSONObject(responseObject, "Spec") secretSpec := responseutils.GetJSONObject(responseObject, "Spec")
if secretSpec != nil { if secretSpec != nil {

View File

@ -13,7 +13,7 @@ import (
"github.com/portainer/portainer/api/docker" "github.com/portainer/portainer/api/docker"
"github.com/docker/docker/client" "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/proxy/factory/responseutils"
"github.com/portainer/portainer/api/http/security" "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 // 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. // 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: // 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.37/#operation/ContainerCreate
// https://docs.docker.com/engine/api/v1.40/#operation/NetworkCreate // https://docs.docker.com/engine/api/v1.37/#operation/NetworkCreate
// https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate // https://docs.docker.com/engine/api/v1.37/#operation/VolumeCreate
// https://docs.docker.com/engine/api/v1.40/#operation/ServiceCreate // https://docs.docker.com/engine/api/v1.37/#operation/ServiceCreate
// https://docs.docker.com/engine/api/v1.40/#operation/SecretCreate // https://docs.docker.com/engine/api/v1.37/#operation/SecretCreate
// https://docs.docker.com/engine/api/v1.40/#operation/ConfigCreate // 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 { func (transport *Transport) decorateGenericResourceCreationResponse(response *http.Response, resourceIdentifierAttribute string, resourceType portainer.ResourceControlType, userID portainer.UserID) error {
responseObject, err := responseutils.GetResponseAsJSONOBject(response) responseObject, err := responseutils.GetResponseAsJSONOBject(response)
if err != nil { if err != nil {