Browse Source

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 7 years ago
parent
commit
195919d9d6
6 changed files with 15 additions and 3 deletions
  1. 2 1
      Makefile
  2. 7 0
      cmd/dockerd/docker.go
  3. 1 0
      dockerversion/version_lib.go
  4. 1 1
      hack/make.ps1
  5. 1 0
      hack/make/.go-autogen
  6. 3 1
      hack/make/.go-autogen.ps1

+ 2 - 1
Makefile

@@ -56,7 +56,8 @@ DOCKER_ENVS := \
 	-e https_proxy \
 	-e https_proxy \
 	-e no_proxy \
 	-e no_proxy \
 	-e VERSION \
 	-e VERSION \
-	-e PLATFORM
+	-e PLATFORM \
+	-e PRODUCT
 # 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
 # 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
 
 
 # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
 # to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`

+ 7 - 0
cmd/dockerd/docker.go

@@ -10,6 +10,7 @@ import (
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/term"
+	"github.com/moby/buildkit/util/apicaps"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
 	"github.com/spf13/cobra"
 )
 )
@@ -42,6 +43,12 @@ func newDaemonCommand() *cobra.Command {
 	return cmd
 	return cmd
 }
 }
 
 
+func init() {
+	if dockerversion.ProductName != "" {
+		apicaps.ExportedProduct = dockerversion.ProductName
+	}
+}
+
 func main() {
 func main() {
 	if reexec.Init() {
 	if reexec.Init() {
 		return
 		return

+ 1 - 0
dockerversion/version_lib.go

@@ -14,4 +14,5 @@ const (
 	RuncCommitID       = "library-import"
 	RuncCommitID       = "library-import"
 	InitCommitID       = "library-import"
 	InitCommitID       = "library-import"
 	PlatformName       = ""
 	PlatformName       = ""
+	ProductName        = ""
 )
 )

+ 1 - 1
hack/make.ps1

@@ -365,7 +365,7 @@ Try {
     # Run autogen if building binaries or running unit tests.
     # Run autogen if building binaries or running unit tests.
     if ($Client -or $Daemon -or $TestUnit) {
     if ($Client -or $Daemon -or $TestUnit) {
         Write-Host "INFO: Invoking autogen..."
         Write-Host "INFO: Invoking autogen..."
-        Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" }
+        Try { .\hack\make\.go-autogen.ps1 -CommitString $gitCommit -DockerVersion $dockerVersion -Platform "$env:PLATFORM" -Product "$env:PRODUCT" }
         Catch [Exception] { Throw $_ }
         Catch [Exception] { Throw $_ }
     }
     }
 
 

+ 1 - 0
hack/make/.go-autogen

@@ -21,6 +21,7 @@ const (
 	IAmStatic          string = "${IAMSTATIC:-true}"
 	IAmStatic          string = "${IAMSTATIC:-true}"
 	ContainerdCommitID string = "${CONTAINERD_COMMIT}"
 	ContainerdCommitID string = "${CONTAINERD_COMMIT}"
 	PlatformName       string = "${PLATFORM}"
 	PlatformName       string = "${PLATFORM}"
+	ProductName        string = "${PRODUCT}"
 )
 )
 
 
 // AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
 // AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen

+ 3 - 1
hack/make/.go-autogen.ps1

@@ -15,7 +15,8 @@
 param(
 param(
     [Parameter(Mandatory=$true)][string]$CommitString,
     [Parameter(Mandatory=$true)][string]$CommitString,
     [Parameter(Mandatory=$true)][string]$DockerVersion,
     [Parameter(Mandatory=$true)][string]$DockerVersion,
-    [Parameter(Mandatory=$false)][string]$Platform
+    [Parameter(Mandatory=$false)][string]$Platform,
+    [Parameter(Mandatory=$false)][string]$Product
 )
 )
 
 
 $ErrorActionPreference = "Stop"
 $ErrorActionPreference = "Stop"
@@ -45,6 +46,7 @@ const (
     Version            string = "'+$DockerVersion+'"
     Version            string = "'+$DockerVersion+'"
     BuildTime          string = "'+$buildDateTime+'"
     BuildTime          string = "'+$buildDateTime+'"
     PlatformName       string = "'+$Platform+'"
     PlatformName       string = "'+$Platform+'"
+    ProductName        string = "'+$Product+'"
 )
 )
 
 
 // AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
 // AUTOGENERATED FILE; see hack\make\.go-autogen.ps1