Expose license status in Info (#37612)
* Expose license status in Info This wires up a new field in the Info payload that exposes the license. For moby this is hardcoded to always report a community edition. Downstream enterprise dockerd will have additional licensing logic wired into this function to report details about the current license status. Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com> * Code review comments Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com> * Add windows autogen support Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
This commit is contained in:
parent
8613b34a7e
commit
896d1b1c61
10 changed files with 67 additions and 22 deletions
1
Makefile
1
Makefile
|
@ -57,6 +57,7 @@ DOCKER_ENVS := \
|
|||
-e no_proxy \
|
||||
-e VERSION \
|
||||
-e PLATFORM \
|
||||
-e DEFAULT_PRODUCT_LICENSE \
|
||||
-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
|
||||
|
||||
|
|
|
@ -3896,6 +3896,14 @@ definitions:
|
|||
- "name=seccomp,profile=default"
|
||||
- "name=selinux"
|
||||
- "name=userns"
|
||||
ProductLicense:
|
||||
description: |
|
||||
Reports a summary of the product license on the daemon.
|
||||
|
||||
If a commercial license has been applied to the daemon, information
|
||||
such as number of nodes, and expiration are included.
|
||||
type: "string"
|
||||
example: "Community Engine"
|
||||
|
||||
|
||||
# PluginsInfo is a temp struct holding Plugins name
|
||||
|
|
|
@ -204,6 +204,7 @@ type Info struct {
|
|||
RuncCommit Commit
|
||||
InitCommit Commit
|
||||
SecurityOptions []string
|
||||
ProductLicense string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// KeyValue holds a key/value pair
|
||||
|
|
|
@ -73,6 +73,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
|||
daemon.fillDriverInfo(v)
|
||||
daemon.fillPluginsInfo(v)
|
||||
daemon.fillSecurityOptions(v, sysInfo)
|
||||
daemon.fillLicense(v)
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
|
10
daemon/licensing.go
Normal file
10
daemon/licensing.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package daemon // import "github.com/docker/docker/daemon"
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/dockerversion"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) fillLicense(v *types.Info) {
|
||||
v.ProductLicense = dockerversion.DefaultProductLicense
|
||||
}
|
18
daemon/licensing_test.go
Normal file
18
daemon/licensing_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package daemon // import "github.com/docker/docker/daemon"
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/dockerversion"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
func TestfillLicense(t *testing.T) {
|
||||
v := &types.Info{}
|
||||
d := &Daemon{
|
||||
root: "/var/lib/docker/",
|
||||
}
|
||||
d.fillLicense(v)
|
||||
assert.Assert(t, v.ProductLicense == dockerversion.DefaultProductLicense)
|
||||
}
|
|
@ -6,13 +6,14 @@ package dockerversion // import "github.com/docker/docker/dockerversion"
|
|||
// Default build-time variable for library-import.
|
||||
// This file is overridden on build with build-time informations.
|
||||
const (
|
||||
GitCommit = "library-import"
|
||||
Version = "library-import"
|
||||
BuildTime = "library-import"
|
||||
IAmStatic = "library-import"
|
||||
ContainerdCommitID = "library-import"
|
||||
RuncCommitID = "library-import"
|
||||
InitCommitID = "library-import"
|
||||
PlatformName = ""
|
||||
ProductName = ""
|
||||
GitCommit = "library-import"
|
||||
Version = "library-import"
|
||||
BuildTime = "library-import"
|
||||
IAmStatic = "library-import"
|
||||
ContainerdCommitID = "library-import"
|
||||
RuncCommitID = "library-import"
|
||||
InitCommitID = "library-import"
|
||||
PlatformName = ""
|
||||
ProductName = ""
|
||||
DefaultProductLicense = ""
|
||||
)
|
||||
|
|
|
@ -19,6 +19,8 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||
|
||||
* `GET /info` now returns an empty string, instead of `<unknown>` for `KernelVersion`
|
||||
and `OperatingSystem` if the daemon was unable to obtain this information.
|
||||
* `GET /info` now returns information about the product license, if a license
|
||||
has been applied to the daemon.
|
||||
|
||||
## V1.38 API changes
|
||||
|
||||
|
|
|
@ -15,13 +15,14 @@ package dockerversion
|
|||
// Default build-time variable for library-import.
|
||||
// This file is overridden on build with build-time informations.
|
||||
const (
|
||||
GitCommit string = "$GITCOMMIT"
|
||||
Version string = "$VERSION"
|
||||
BuildTime string = "$BUILDTIME"
|
||||
IAmStatic string = "${IAMSTATIC:-true}"
|
||||
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
|
||||
PlatformName string = "${PLATFORM}"
|
||||
ProductName string = "${PRODUCT}"
|
||||
GitCommit string = "$GITCOMMIT"
|
||||
Version string = "$VERSION"
|
||||
BuildTime string = "$BUILDTIME"
|
||||
IAmStatic string = "${IAMSTATIC:-true}"
|
||||
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
|
||||
PlatformName string = "${PLATFORM}"
|
||||
ProductName string = "${PRODUCT}"
|
||||
DefaultProductLicense string = "${DEFAULT_PRODUCT_LICENSE}"
|
||||
)
|
||||
|
||||
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
|
||||
|
|
|
@ -16,7 +16,8 @@ param(
|
|||
[Parameter(Mandatory=$true)][string]$CommitString,
|
||||
[Parameter(Mandatory=$true)][string]$DockerVersion,
|
||||
[Parameter(Mandatory=$false)][string]$Platform,
|
||||
[Parameter(Mandatory=$false)][string]$Product
|
||||
[Parameter(Mandatory=$false)][string]$Product,
|
||||
[Parameter(Mandatory=$false)][string]$DefaultProductLicense
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
@ -42,11 +43,12 @@ package dockerversion
|
|||
// Default build-time variable for library-import.
|
||||
// This file is overridden on build with build-time informations.
|
||||
const (
|
||||
GitCommit string = "'+$CommitString+'"
|
||||
Version string = "'+$DockerVersion+'"
|
||||
BuildTime string = "'+$buildDateTime+'"
|
||||
PlatformName string = "'+$Platform+'"
|
||||
ProductName string = "'+$Product+'"
|
||||
GitCommit string = "'+$CommitString+'"
|
||||
Version string = "'+$DockerVersion+'"
|
||||
BuildTime string = "'+$buildDateTime+'"
|
||||
PlatformName string = "'+$Platform+'"
|
||||
ProductName string = "'+$Product+'"
|
||||
DefaultProductLicense string = "'+$DefaultProductLicense+'"
|
||||
)
|
||||
|
||||
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
|
||||
|
|
Loading…
Reference in a new issue