Skip to content

Commit

Permalink
builder: set buildkit's exported product variable via PRODUCT
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Tibor Vass committed Jul 16, 2018
1 parent 0ab7c1c commit 195919d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ DOCKER_ENVS := \
-e https_proxy \
-e no_proxy \
-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

# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
Expand Down
7 changes: 7 additions & 0 deletions cmd/dockerd/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/term"
"github.com/moby/buildkit/util/apicaps"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -42,6 +43,12 @@ func newDaemonCommand() *cobra.Command {
return cmd
}

func init() {
if dockerversion.ProductName != "" {
apicaps.ExportedProduct = dockerversion.ProductName
}
}

func main() {
if reexec.Init() {
return
Expand Down
1 change: 1 addition & 0 deletions dockerversion/version_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ const (
RuncCommitID = "library-import"
InitCommitID = "library-import"
PlatformName = ""
ProductName = ""
)
2 changes: 1 addition & 1 deletion hack/make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Try {
# Run autogen if building binaries or running unit tests.
if ($Client -or $Daemon -or $TestUnit) {
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 $_ }
}

Expand Down
1 change: 1 addition & 0 deletions hack/make/.go-autogen
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
IAmStatic string = "${IAMSTATIC:-true}"
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
PlatformName string = "${PLATFORM}"
ProductName string = "${PRODUCT}"
)
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
Expand Down
4 changes: 3 additions & 1 deletion hack/make/.go-autogen.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
param(
[Parameter(Mandatory=$true)][string]$CommitString,
[Parameter(Mandatory=$true)][string]$DockerVersion,
[Parameter(Mandatory=$false)][string]$Platform
[Parameter(Mandatory=$false)][string]$Platform,
[Parameter(Mandatory=$false)][string]$Product
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -45,6 +46,7 @@ const (
Version string = "'+$DockerVersion+'"
BuildTime string = "'+$buildDateTime+'"
PlatformName string = "'+$Platform+'"
ProductName string = "'+$Product+'"
)
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
Expand Down

0 comments on commit 195919d

Please sign in to comment.