Browse code

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 <anusha.ragunathan@docker.com>

Anusha Ragunathan authored on 2017/03/22 06:07:41
Showing 3 changed files
... ...
@@ -1452,6 +1452,10 @@ definitions:
1452 1452
           - Env
1453 1453
           - Args
1454 1454
         properties:
1455
+          DockerVersion:
1456
+            description: "Docker Version used to create the plugin"
1457
+            type: "string"
1458
+            x-nullable: false
1455 1459
           Description:
1456 1460
             type: "string"
1457 1461
             x-nullable: false
... ...
@@ -42,6 +42,9 @@ type PluginConfig struct {
42 42
 	// Required: true
43 43
 	Description string `json:"Description"`
44 44
 
45
+	// Docker Version used to create the plugin
46
+	DockerVersion string `json:"DockerVersion,omitempty"`
47
+
45 48
 	// documentation
46 49
 	// Required: true
47 50
 	Documentation string `json:"Documentation"`
... ...
@@ -24,6 +24,7 @@ import (
24 24
 	"github.com/docker/docker/distribution"
25 25
 	progressutils "github.com/docker/docker/distribution/utils"
26 26
 	"github.com/docker/docker/distribution/xfer"
27
+	"github.com/docker/docker/dockerversion"
27 28
 	"github.com/docker/docker/image"
28 29
 	"github.com/docker/docker/layer"
29 30
 	"github.com/docker/docker/pkg/chrootarchive"
... ...
@@ -758,6 +759,8 @@ func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser,
758 758
 		DiffIds: []string{layerDigester.Digest().String()},
759 759
 	}
760 760
 
761
+	config.DockerVersion = dockerversion.Version
762
+
761 763
 	configBlob, err := pm.blobStore.New()
762 764
 	if err != nil {
763 765
 		return err