mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
api/types: move Version to api/types/system
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
58
api/types/system/version_response.go
Normal file
58
api/types/system/version_response.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package system
|
||||
|
||||
// VersionResponse contains information about the Docker server host.
|
||||
// GET "/version"
|
||||
type VersionResponse struct {
|
||||
// Platform is the platform (product name) the server is running on.
|
||||
Platform PlatformInfo `json:",omitempty"`
|
||||
|
||||
// Version is the version of the daemon.
|
||||
Version string
|
||||
|
||||
// APIVersion is the highest API version supported by the server.
|
||||
APIVersion string `json:"ApiVersion"`
|
||||
|
||||
// MinAPIVersion is the minimum API version the server supports.
|
||||
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
|
||||
|
||||
// Os is the operating system the server runs on.
|
||||
Os string
|
||||
|
||||
// Arch is the hardware architecture the server runs on.
|
||||
Arch string
|
||||
|
||||
// Components contains version information for the components making
|
||||
// up the server. Information in this field is for informational
|
||||
// purposes, and not part of the API contract.
|
||||
Components []ComponentVersion `json:",omitempty"`
|
||||
|
||||
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
|
||||
|
||||
GitCommit string `json:",omitempty"`
|
||||
GoVersion string `json:",omitempty"`
|
||||
KernelVersion string `json:",omitempty"`
|
||||
Experimental bool `json:",omitempty"`
|
||||
BuildTime string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// PlatformInfo holds information about the platform (product name) the
|
||||
// server is running on.
|
||||
type PlatformInfo struct {
|
||||
// Name is the name of the platform (for example, "Docker Engine - Community",
|
||||
// or "Docker Desktop 4.49.0 (208003)")
|
||||
Name string
|
||||
}
|
||||
|
||||
// ComponentVersion describes the version information for a specific component.
|
||||
type ComponentVersion struct {
|
||||
Name string
|
||||
Version string
|
||||
|
||||
// Details contains Key/value pairs of strings with additional information
|
||||
// about the component. These values are intended for informational purposes
|
||||
// only, and their content is not defined, and not part of the API
|
||||
// specification.
|
||||
//
|
||||
// These messages can be printed by the client as information to the user.
|
||||
Details map[string]string `json:",omitempty"`
|
||||
}
|
||||
@@ -16,30 +16,3 @@ const (
|
||||
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
||||
MediaTypeJSONSequence = "application/json-seq"
|
||||
)
|
||||
|
||||
// ComponentVersion describes the version information for a specific component.
|
||||
type ComponentVersion struct {
|
||||
Name string
|
||||
Version string
|
||||
Details map[string]string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Version contains response of Engine API:
|
||||
// GET "/version"
|
||||
type Version struct {
|
||||
Platform struct{ Name string } `json:",omitempty"`
|
||||
Components []ComponentVersion `json:",omitempty"`
|
||||
|
||||
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
|
||||
|
||||
Version string
|
||||
APIVersion string `json:"ApiVersion"`
|
||||
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
|
||||
GitCommit string
|
||||
GoVersion string
|
||||
Os string
|
||||
Arch string
|
||||
KernelVersion string `json:",omitempty"`
|
||||
Experimental bool `json:",omitempty"`
|
||||
BuildTime string `json:",omitempty"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
)
|
||||
|
||||
// ServerVersionOptions specifies options for the server version request.
|
||||
@@ -41,7 +41,7 @@ type ServerVersionResult struct {
|
||||
// Components contains version information for the components making
|
||||
// up the server. Information in this field is for informational
|
||||
// purposes, and not part of the API contract.
|
||||
Components []types.ComponentVersion
|
||||
Components []system.ComponentVersion
|
||||
}
|
||||
|
||||
// PlatformInfo holds information about the platform (product name) the
|
||||
@@ -60,7 +60,7 @@ func (cli *Client) ServerVersion(ctx context.Context, _ ServerVersionOptions) (S
|
||||
return ServerVersionResult{}, err
|
||||
}
|
||||
|
||||
var v types.Version
|
||||
var v system.VersionResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&v)
|
||||
if err != nil {
|
||||
return ServerVersionResult{}, err
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/v2/pkg/tracing"
|
||||
"github.com/containerd/log"
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/v2/daemon/command/debug"
|
||||
"github.com/moby/moby/v2/daemon/config"
|
||||
@@ -101,14 +100,14 @@ func (daemon *Daemon) SystemInfo(ctx context.Context) (*system.Info, error) {
|
||||
// Anything else should be logged and ignored because this is looking up
|
||||
// multiple things and is often used for debugging.
|
||||
// The only case valid early return is when the caller doesn't want the result anymore (ie context cancelled).
|
||||
func (daemon *Daemon) SystemVersion(ctx context.Context) (types.Version, error) {
|
||||
func (daemon *Daemon) SystemVersion(ctx context.Context) (system.VersionResponse, error) {
|
||||
defer metrics.StartTimer(metrics.HostInfoFunctions.WithValues("system_version"))()
|
||||
|
||||
kernelVer := kernelVersion(ctx)
|
||||
cfg := daemon.config()
|
||||
|
||||
v := types.Version{
|
||||
Components: []types.ComponentVersion{
|
||||
v := system.VersionResponse{
|
||||
Components: []system.ComponentVersion{
|
||||
{
|
||||
Name: "Engine",
|
||||
Version: dockerversion.Version,
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
runcoptions "github.com/containerd/containerd/api/types/runc/options"
|
||||
"github.com/containerd/log"
|
||||
"github.com/moby/moby/api/types"
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/v2/daemon/config"
|
||||
@@ -158,7 +157,7 @@ func (daemon *Daemon) fillPlatformInfo(ctx context.Context, v *system.Info, sysI
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillPlatformVersion(ctx context.Context, v *types.Version, cfg *configStore) error {
|
||||
func (daemon *Daemon) fillPlatformVersion(ctx context.Context, v *system.VersionResponse, cfg *configStore) error {
|
||||
if err := daemon.populateContainerdVersion(ctx, v); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -215,7 +214,7 @@ func (daemon *Daemon) populateInitCommit(ctx context.Context, v *system.Info, cf
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version) error {
|
||||
func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *system.VersionResponse) error {
|
||||
if !rootless.RunningWithRootlessKit() {
|
||||
return nil
|
||||
}
|
||||
@@ -227,7 +226,7 @@ func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to retrieve RootlessKit version")
|
||||
}
|
||||
rlV := types.ComponentVersion{
|
||||
rlV := system.ComponentVersion{
|
||||
Name: "rootlesskit",
|
||||
Version: rlInfo.Version,
|
||||
Details: map[string]string{
|
||||
@@ -266,7 +265,7 @@ func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version)
|
||||
log.G(ctx).WithError(err).Warn("Failed to parse slirp4netns version")
|
||||
return nil
|
||||
}
|
||||
v.Components = append(v.Components, types.ComponentVersion{
|
||||
v.Components = append(v.Components, system.ComponentVersion{
|
||||
Name: "slirp4netns",
|
||||
Version: ver,
|
||||
Details: map[string]string{
|
||||
@@ -288,7 +287,7 @@ func (daemon *Daemon) fillRootlessVersion(ctx context.Context, v *types.Version)
|
||||
log.G(ctx).WithError(err).Warn("Failed to retrieve vpnkit version")
|
||||
return nil
|
||||
}
|
||||
v.Components = append(v.Components, types.ComponentVersion{
|
||||
v.Components = append(v.Components, system.ComponentVersion{
|
||||
Name: "vpnkit",
|
||||
Version: strings.TrimSpace(strings.TrimSpace(string(out))),
|
||||
})
|
||||
@@ -428,7 +427,7 @@ func (daemon *Daemon) populateContainerdCommit(ctx context.Context, v *system.Co
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) populateContainerdVersion(ctx context.Context, v *types.Version) error {
|
||||
func (daemon *Daemon) populateContainerdVersion(ctx context.Context, v *system.VersionResponse) error {
|
||||
rv, err := daemon.containerd.Version(ctx)
|
||||
if err != nil {
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
@@ -438,7 +437,7 @@ func (daemon *Daemon) populateContainerdVersion(ctx context.Context, v *types.Ve
|
||||
return nil
|
||||
}
|
||||
|
||||
v.Components = append(v.Components, types.ComponentVersion{
|
||||
v.Components = append(v.Components, system.ComponentVersion{
|
||||
Name: "containerd",
|
||||
Version: rv.Version,
|
||||
Details: map[string]string{
|
||||
@@ -448,12 +447,12 @@ func (daemon *Daemon) populateContainerdVersion(ctx context.Context, v *types.Ve
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateRuncVersion(cfg *configStore, v *types.Version) error {
|
||||
func populateRuncVersion(cfg *configStore, v *system.VersionResponse) error {
|
||||
_, ver, commit, err := parseDefaultRuntimeVersion(&cfg.Runtimes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Components = append(v.Components, types.ComponentVersion{
|
||||
v.Components = append(v.Components, system.ComponentVersion{
|
||||
Name: cfg.Runtimes.Default,
|
||||
Version: ver,
|
||||
Details: map[string]string{
|
||||
@@ -463,7 +462,7 @@ func populateRuncVersion(cfg *configStore, v *types.Version) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version) error {
|
||||
func populateInitVersion(ctx context.Context, cfg *configStore, v *system.VersionResponse) error {
|
||||
initBinary, err := cfg.LookupInitPath()
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).Warn("Failed to find docker-init")
|
||||
@@ -484,7 +483,7 @@ func populateInitVersion(ctx context.Context, cfg *configStore, v *types.Version
|
||||
log.G(ctx).WithError(err).Warnf("failed to parse %s version", initBinary)
|
||||
return nil
|
||||
}
|
||||
v.Components = append(v.Components, types.ComponentVersion{
|
||||
v.Components = append(v.Components, system.ComponentVersion{
|
||||
Name: filepath.Base(initBinary),
|
||||
Version: ver,
|
||||
Details: map[string]string{
|
||||
|
||||
@@ -3,7 +3,6 @@ package daemon
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/v2/daemon/config"
|
||||
"github.com/moby/moby/v2/pkg/sysinfo"
|
||||
@@ -18,7 +17,7 @@ WARNING: Feature flag "windows-dns-proxy" has been removed, forwarding to extern
|
||||
return nil
|
||||
}
|
||||
|
||||
func (daemon *Daemon) fillPlatformVersion(ctx context.Context, v *types.Version, cfg *configStore) error {
|
||||
func (daemon *Daemon) fillPlatformVersion(ctx context.Context, v *system.VersionResponse, cfg *configStore) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/build"
|
||||
"github.com/moby/moby/api/types/events"
|
||||
"github.com/moby/moby/api/types/registry"
|
||||
@@ -18,7 +17,7 @@ import (
|
||||
// system specific functionality.
|
||||
type Backend interface {
|
||||
SystemInfo(context.Context) (*system.Info, error)
|
||||
SystemVersion(context.Context) (types.Version, error)
|
||||
SystemVersion(context.Context) (system.VersionResponse, error)
|
||||
SystemDiskUsage(ctx context.Context, opts backend.DiskUsageOptions) (*backend.DiskUsage, error)
|
||||
SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan any)
|
||||
UnsubscribeFromEvents(chan any)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/internal/testutil/request"
|
||||
"gotest.tools/v3/assert"
|
||||
@@ -21,7 +21,7 @@ func TestVersion(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, len(version.Components) > 0, "expected at least one component in version.Components")
|
||||
|
||||
var engine types.ComponentVersion
|
||||
var engine system.ComponentVersion
|
||||
var found bool
|
||||
|
||||
for _, comp := range version.Components {
|
||||
|
||||
58
vendor/github.com/moby/moby/api/types/system/version_response.go
generated
vendored
Normal file
58
vendor/github.com/moby/moby/api/types/system/version_response.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
package system
|
||||
|
||||
// VersionResponse contains information about the Docker server host.
|
||||
// GET "/version"
|
||||
type VersionResponse struct {
|
||||
// Platform is the platform (product name) the server is running on.
|
||||
Platform PlatformInfo `json:",omitempty"`
|
||||
|
||||
// Version is the version of the daemon.
|
||||
Version string
|
||||
|
||||
// APIVersion is the highest API version supported by the server.
|
||||
APIVersion string `json:"ApiVersion"`
|
||||
|
||||
// MinAPIVersion is the minimum API version the server supports.
|
||||
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
|
||||
|
||||
// Os is the operating system the server runs on.
|
||||
Os string
|
||||
|
||||
// Arch is the hardware architecture the server runs on.
|
||||
Arch string
|
||||
|
||||
// Components contains version information for the components making
|
||||
// up the server. Information in this field is for informational
|
||||
// purposes, and not part of the API contract.
|
||||
Components []ComponentVersion `json:",omitempty"`
|
||||
|
||||
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
|
||||
|
||||
GitCommit string `json:",omitempty"`
|
||||
GoVersion string `json:",omitempty"`
|
||||
KernelVersion string `json:",omitempty"`
|
||||
Experimental bool `json:",omitempty"`
|
||||
BuildTime string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// PlatformInfo holds information about the platform (product name) the
|
||||
// server is running on.
|
||||
type PlatformInfo struct {
|
||||
// Name is the name of the platform (for example, "Docker Engine - Community",
|
||||
// or "Docker Desktop 4.49.0 (208003)")
|
||||
Name string
|
||||
}
|
||||
|
||||
// ComponentVersion describes the version information for a specific component.
|
||||
type ComponentVersion struct {
|
||||
Name string
|
||||
Version string
|
||||
|
||||
// Details contains Key/value pairs of strings with additional information
|
||||
// about the component. These values are intended for informational purposes
|
||||
// only, and their content is not defined, and not part of the API
|
||||
// specification.
|
||||
//
|
||||
// These messages can be printed by the client as information to the user.
|
||||
Details map[string]string `json:",omitempty"`
|
||||
}
|
||||
27
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
27
vendor/github.com/moby/moby/api/types/types.go
generated
vendored
@@ -16,30 +16,3 @@ const (
|
||||
// MediaTypeJSONSequence is the MIME-Type for JSON Text Sequences (RFC7464).
|
||||
MediaTypeJSONSequence = "application/json-seq"
|
||||
)
|
||||
|
||||
// ComponentVersion describes the version information for a specific component.
|
||||
type ComponentVersion struct {
|
||||
Name string
|
||||
Version string
|
||||
Details map[string]string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Version contains response of Engine API:
|
||||
// GET "/version"
|
||||
type Version struct {
|
||||
Platform struct{ Name string } `json:",omitempty"`
|
||||
Components []ComponentVersion `json:",omitempty"`
|
||||
|
||||
// The following fields are deprecated, they relate to the Engine component and are kept for backwards compatibility
|
||||
|
||||
Version string
|
||||
APIVersion string `json:"ApiVersion"`
|
||||
MinAPIVersion string `json:"MinAPIVersion,omitempty"`
|
||||
GitCommit string
|
||||
GoVersion string
|
||||
Os string
|
||||
Arch string
|
||||
KernelVersion string `json:",omitempty"`
|
||||
Experimental bool `json:",omitempty"`
|
||||
BuildTime string `json:",omitempty"`
|
||||
}
|
||||
|
||||
6
vendor/github.com/moby/moby/client/version.go
generated
vendored
6
vendor/github.com/moby/moby/client/version.go
generated
vendored
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/moby/moby/api/types"
|
||||
"github.com/moby/moby/api/types/system"
|
||||
)
|
||||
|
||||
// ServerVersionOptions specifies options for the server version request.
|
||||
@@ -41,7 +41,7 @@ type ServerVersionResult struct {
|
||||
// Components contains version information for the components making
|
||||
// up the server. Information in this field is for informational
|
||||
// purposes, and not part of the API contract.
|
||||
Components []types.ComponentVersion
|
||||
Components []system.ComponentVersion
|
||||
}
|
||||
|
||||
// PlatformInfo holds information about the platform (product name) the
|
||||
@@ -60,7 +60,7 @@ func (cli *Client) ServerVersion(ctx context.Context, _ ServerVersionOptions) (S
|
||||
return ServerVersionResult{}, err
|
||||
}
|
||||
|
||||
var v types.Version
|
||||
var v system.VersionResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&v)
|
||||
if err != nil {
|
||||
return ServerVersionResult{}, err
|
||||
|
||||
Reference in New Issue
Block a user