Skip to content

Commit 896d1b1

Browse files
dhiltgentiborvass
authored andcommitted
Expose license status in Info (moby#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 <[email protected]> * Code review comments Signed-off-by: Daniel Hiltgen <[email protected]> * Add windows autogen support Signed-off-by: Daniel Hiltgen <[email protected]>
1 parent 8613b34 commit 896d1b1

10 files changed

Lines changed: 67 additions & 22 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ DOCKER_ENVS := \
5757
-e no_proxy \
5858
-e VERSION \
5959
-e PLATFORM \
60+
-e DEFAULT_PRODUCT_LICENSE \
6061
-e PRODUCT
6162
# 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
6263

api/swagger.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,6 +3896,14 @@ definitions:
38963896
- "name=seccomp,profile=default"
38973897
- "name=selinux"
38983898
- "name=userns"
3899+
ProductLicense:
3900+
description: |
3901+
Reports a summary of the product license on the daemon.
3902+
3903+
If a commercial license has been applied to the daemon, information
3904+
such as number of nodes, and expiration are included.
3905+
type: "string"
3906+
example: "Community Engine"
38993907

39003908

39013909
# PluginsInfo is a temp struct holding Plugins name

api/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ type Info struct {
204204
RuncCommit Commit
205205
InitCommit Commit
206206
SecurityOptions []string
207+
ProductLicense string `json:",omitempty"`
207208
}
208209

209210
// KeyValue holds a key/value pair

daemon/info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
7373
daemon.fillDriverInfo(v)
7474
daemon.fillPluginsInfo(v)
7575
daemon.fillSecurityOptions(v, sysInfo)
76+
daemon.fillLicense(v)
7677

7778
return v, nil
7879
}

daemon/licensing.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package daemon // import "github.com/docker/docker/daemon"
2+
3+
import (
4+
"github.com/docker/docker/api/types"
5+
"github.com/docker/docker/dockerversion"
6+
)
7+
8+
func (daemon *Daemon) fillLicense(v *types.Info) {
9+
v.ProductLicense = dockerversion.DefaultProductLicense
10+
}

daemon/licensing_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package daemon // import "github.com/docker/docker/daemon"
2+
3+
import (
4+
"testing"
5+
6+
"github.com/docker/docker/api/types"
7+
"github.com/docker/docker/dockerversion"
8+
"gotest.tools/assert"
9+
)
10+
11+
func TestfillLicense(t *testing.T) {
12+
v := &types.Info{}
13+
d := &Daemon{
14+
root: "/var/lib/docker/",
15+
}
16+
d.fillLicense(v)
17+
assert.Assert(t, v.ProductLicense == dockerversion.DefaultProductLicense)
18+
}

dockerversion/version_lib.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ package dockerversion // import "github.com/docker/docker/dockerversion"
66
// Default build-time variable for library-import.
77
// This file is overridden on build with build-time informations.
88
const (
9-
GitCommit = "library-import"
10-
Version = "library-import"
11-
BuildTime = "library-import"
12-
IAmStatic = "library-import"
13-
ContainerdCommitID = "library-import"
14-
RuncCommitID = "library-import"
15-
InitCommitID = "library-import"
16-
PlatformName = ""
17-
ProductName = ""
9+
GitCommit = "library-import"
10+
Version = "library-import"
11+
BuildTime = "library-import"
12+
IAmStatic = "library-import"
13+
ContainerdCommitID = "library-import"
14+
RuncCommitID = "library-import"
15+
InitCommitID = "library-import"
16+
PlatformName = ""
17+
ProductName = ""
18+
DefaultProductLicense = ""
1819
)

docs/api/version-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ keywords: "API, Docker, rcli, REST, documentation"
1919

2020
* `GET /info` now returns an empty string, instead of `<unknown>` for `KernelVersion`
2121
and `OperatingSystem` if the daemon was unable to obtain this information.
22+
* `GET /info` now returns information about the product license, if a license
23+
has been applied to the daemon.
2224

2325
## V1.38 API changes
2426

hack/make/.go-autogen

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ package dockerversion
1515
// Default build-time variable for library-import.
1616
// This file is overridden on build with build-time informations.
1717
const (
18-
GitCommit string = "$GITCOMMIT"
19-
Version string = "$VERSION"
20-
BuildTime string = "$BUILDTIME"
21-
IAmStatic string = "${IAMSTATIC:-true}"
22-
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
23-
PlatformName string = "${PLATFORM}"
24-
ProductName string = "${PRODUCT}"
18+
GitCommit string = "$GITCOMMIT"
19+
Version string = "$VERSION"
20+
BuildTime string = "$BUILDTIME"
21+
IAmStatic string = "${IAMSTATIC:-true}"
22+
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
23+
PlatformName string = "${PLATFORM}"
24+
ProductName string = "${PRODUCT}"
25+
DefaultProductLicense string = "${DEFAULT_PRODUCT_LICENSE}"
2526
)
2627
2728
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen

hack/make/.go-autogen.ps1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ param(
1616
[Parameter(Mandatory=$true)][string]$CommitString,
1717
[Parameter(Mandatory=$true)][string]$DockerVersion,
1818
[Parameter(Mandatory=$false)][string]$Platform,
19-
[Parameter(Mandatory=$false)][string]$Product
19+
[Parameter(Mandatory=$false)][string]$Product,
20+
[Parameter(Mandatory=$false)][string]$DefaultProductLicense
2021
)
2122

2223
$ErrorActionPreference = "Stop"
@@ -42,11 +43,12 @@ package dockerversion
4243
// Default build-time variable for library-import.
4344
// This file is overridden on build with build-time informations.
4445
const (
45-
GitCommit string = "'+$CommitString+'"
46-
Version string = "'+$DockerVersion+'"
47-
BuildTime string = "'+$buildDateTime+'"
48-
PlatformName string = "'+$Platform+'"
49-
ProductName string = "'+$Product+'"
46+
GitCommit string = "'+$CommitString+'"
47+
Version string = "'+$DockerVersion+'"
48+
BuildTime string = "'+$buildDateTime+'"
49+
PlatformName string = "'+$Platform+'"
50+
ProductName string = "'+$Product+'"
51+
DefaultProductLicense string = "'+$DefaultProductLicense+'"
5052
)
5153
5254
// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1

0 commit comments

Comments
 (0)