Browse code

builder: set buildkit's exported product variable via PRODUCT

This introduces a PRODUCT environment variable that is used to set a constant
at dockerversion.ProductName.

That is then used to set BuildKit's ExportedProduct variable in order to show
useful error messages to users when a certain version of the product doesn't
support a BuildKit feature.

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2018/07/12 07:25:38
Showing 6 changed files
... ...
@@ -56,7 +56,8 @@ DOCKER_ENVS := \
56 56
 	-e https_proxy \
57 57
 	-e no_proxy \
58 58
 	-e VERSION \
59
-	-e PLATFORM
59
+	-e PLATFORM \
60
+	-e PRODUCT
60 61
 # note: we _cannot_ add "-e DOCKER_BUILDTAGS" here because even if it's unset in the shell, that would shadow the "ENV DOCKER_BUILDTAGS" set in our Dockerfile, which is very important for our official builds
61 62
 
62 63
 # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"github.com/docker/docker/dockerversion"
11 11
 	"github.com/docker/docker/pkg/reexec"
12 12
 	"github.com/docker/docker/pkg/term"
13
+	"github.com/moby/buildkit/util/apicaps"
13 14
 	"github.com/sirupsen/logrus"
14 15
 	"github.com/spf13/cobra"
15 16
 )
... ...
@@ -42,6 +43,12 @@ func newDaemonCommand() *cobra.Command {
42 42
 	return cmd
43 43
 }
44 44
 
45
+func init() {
46
+	if dockerversion.ProductName != "" {
47
+		apicaps.ExportedProduct = dockerversion.ProductName
48
+	}
49
+}
50
+
45 51
 func main() {
46 52
 	if reexec.Init() {
47 53
 		return
... ...
@@ -14,4 +14,5 @@ const (
14 14
 	RuncCommitID       = "library-import"
15 15
 	InitCommitID       = "library-import"
16 16
 	PlatformName       = ""
17
+	ProductName        = ""
17 18
 )
... ...
@@ -365,7 +365,7 @@ Try {
365 365
     # Run autogen if building binaries or running unit tests.
366 366
     if ($Client -or $Daemon -or $TestUnit) {
367 367
         Write-Host "INFO: Invoking autogen..."
368
-        Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" }
368
+        Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" -Product "$env:PRODUCT" }
369 369
         Catch [Exception] { Throw $_ }
370 370
     }
371 371
 
... ...
@@ -21,6 +21,7 @@ const (
21 21
 	IAmStatic          string = "${IAMSTATIC:-true}"
22 22
 	ContainerdCommitID string = "${CONTAINERD_COMMIT}"
23 23
 	PlatformName       string = "${PLATFORM}"
24
+	ProductName        string = "${PRODUCT}"
24 25
 )
25 26
 
26 27
 // AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
... ...
@@ -15,7 +15,8 @@
15 15
 param(
16 16
     [Parameter(Mandatory=$true)][string]$CommitString,
17 17
     [Parameter(Mandatory=$true)][string]$DockerVersion,
18
-    [Parameter(Mandatory=$false)][string]$Platform
18
+    [Parameter(Mandatory=$false)][string]$Platform,
19
+    [Parameter(Mandatory=$false)][string]$Product
19 20
 )
20 21
 
21 22
 $ErrorActionPreference = "Stop"
... ...
@@ -45,6 +46,7 @@ const (
45 45
     Version            string = "'+$DockerVersion+'"
46 46
     BuildTime          string = "'+$buildDateTime+'"
47 47
     PlatformName       string = "'+$Platform+'"
48
+    ProductName        string = "'+$Product+'"
48 49
 )
49 50
 
50 51
 // AUTOGENERATED FILE; see hack\make\.go-autogen.ps1