From e82f1456b47b226da987f5c1cf852c9f31772f41 Mon Sep 17 00:00:00 2001 From: Anusha Ragunathan Date: Tue, 21 Mar 2017 14:07:41 -0700 Subject: [PATCH] Embed DockerVersion in plugin config. Embedding DockerVersion in plugin config when the plugin is created, enables users to do a docker plugin inspect and know which version the plugin was built on. This is helpful in cases where users are running a new plugin on older docker releases and confused at unexpected behavior. By embedding DockerVersion in the config, we claim that there's no guarantee that if the plugin config's DockerVersion is greater that the version of the docker engine the plugin is executed against, the plugin will work as expected. For example, lets say: - in 17.03, a plugin was released as johndoe/foo:v1 - in 17.05, the plugin uses the new ipchost config setting and author publishes johndoe/foo:v2 In this case, johndoe/foo:v2 was built on 17.05 using ipchost, but is running on docker-engine version 17.03. Since 17.05 > 17.03, there's no guarantee that the plugin will work as expected. Ofcourse, if the plugin did not use newly added config settings (ipchost in this case) in 17.05, it would work fine in 17.03. Signed-off-by: Anusha Ragunathan Upstream-commit: 342ed107bc6283cfc9b3301142e71f20aae0aaca Component: engine --- components/engine/api/swagger.yaml | 4 ++++ components/engine/api/types/plugin.go | 3 +++ components/engine/plugin/backend_linux.go | 3 +++ 3 files changed, 10 insertions(+) diff --git a/components/engine/api/swagger.yaml b/components/engine/api/swagger.yaml index 3991437e67..a8b4b553c0 100644 --- a/components/engine/api/swagger.yaml +++ b/components/engine/api/swagger.yaml @@ -1452,6 +1452,10 @@ definitions: - Env - Args properties: + DockerVersion: + description: "Docker Version used to create the plugin" + type: "string" + x-nullable: false Description: type: "string" x-nullable: false diff --git a/components/engine/api/types/plugin.go b/components/engine/api/types/plugin.go index 14f0f956be..ed3c2c26e4 100644 --- a/components/engine/api/types/plugin.go +++ b/components/engine/api/types/plugin.go @@ -42,6 +42,9 @@ type PluginConfig struct { // Required: true Description string `json:"Description"` + // Docker Version used to create the plugin + DockerVersion string `json:"DockerVersion,omitempty"` + // documentation // Required: true Documentation string `json:"Documentation"` diff --git a/components/engine/plugin/backend_linux.go b/components/engine/plugin/backend_linux.go index 31587efbe6..8924daa996 100644 --- a/components/engine/plugin/backend_linux.go +++ b/components/engine/plugin/backend_linux.go @@ -24,6 +24,7 @@ import ( "github.com/docker/docker/distribution" progressutils "github.com/docker/docker/distribution/utils" "github.com/docker/docker/distribution/xfer" + "github.com/docker/docker/dockerversion" "github.com/docker/docker/image" "github.com/docker/docker/layer" "github.com/docker/docker/pkg/chrootarchive" @@ -758,6 +759,8 @@ func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, DiffIds: []string{layerDigester.Digest().String()}, } + config.DockerVersion = dockerversion.Version + configBlob, err := pm.blobStore.New() if err != nil { return err