Merge pull request #3136 from thaJeztah/remove_clientinfo
Remove ClientInfo as it is not practically used.
This commit is contained in:
commit
6745f62a0b
@ -51,7 +51,6 @@ type Cli interface {
|
|||||||
Apply(ops ...DockerCliOption) error
|
Apply(ops ...DockerCliOption) error
|
||||||
ConfigFile() *configfile.ConfigFile
|
ConfigFile() *configfile.ConfigFile
|
||||||
ServerInfo() ServerInfo
|
ServerInfo() ServerInfo
|
||||||
ClientInfo() ClientInfo
|
|
||||||
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
|
NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
|
||||||
DefaultVersion() string
|
DefaultVersion() string
|
||||||
ManifestStore() manifeststore.Store
|
ManifestStore() manifeststore.Store
|
||||||
@ -72,7 +71,6 @@ type DockerCli struct {
|
|||||||
err io.Writer
|
err io.Writer
|
||||||
client client.APIClient
|
client client.APIClient
|
||||||
serverInfo ServerInfo
|
serverInfo ServerInfo
|
||||||
clientInfo *ClientInfo
|
|
||||||
contentTrust bool
|
contentTrust bool
|
||||||
contextStore store.Store
|
contextStore store.Store
|
||||||
currentContext string
|
currentContext string
|
||||||
@ -80,9 +78,9 @@ type DockerCli struct {
|
|||||||
contextStoreConfig store.Config
|
contextStoreConfig store.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultVersion returns api.defaultVersion or DOCKER_API_VERSION if specified.
|
// DefaultVersion returns api.defaultVersion.
|
||||||
func (cli *DockerCli) DefaultVersion() string {
|
func (cli *DockerCli) DefaultVersion() string {
|
||||||
return cli.ClientInfo().DefaultVersion
|
return api.DefaultVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client returns the APIClient
|
// Client returns the APIClient
|
||||||
@ -137,30 +135,6 @@ func (cli *DockerCli) ServerInfo() ServerInfo {
|
|||||||
return cli.serverInfo
|
return cli.serverInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientInfo returns the client details for the cli
|
|
||||||
func (cli *DockerCli) ClientInfo() ClientInfo {
|
|
||||||
if cli.clientInfo == nil {
|
|
||||||
if err := cli.loadClientInfo(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *cli.clientInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cli *DockerCli) loadClientInfo() error {
|
|
||||||
var v string
|
|
||||||
if cli.client != nil {
|
|
||||||
v = cli.client.ClientVersion()
|
|
||||||
} else {
|
|
||||||
v = api.DefaultVersion
|
|
||||||
}
|
|
||||||
cli.clientInfo = &ClientInfo{
|
|
||||||
DefaultVersion: v,
|
|
||||||
HasExperimental: true,
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContentTrustEnabled returns whether content trust has been enabled by an
|
// ContentTrustEnabled returns whether content trust has been enabled by an
|
||||||
// environment variable.
|
// environment variable.
|
||||||
func (cli *DockerCli) ContentTrustEnabled() bool {
|
func (cli *DockerCli) ContentTrustEnabled() bool {
|
||||||
@ -259,11 +233,6 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cli.initializeFromClient()
|
cli.initializeFromClient()
|
||||||
|
|
||||||
if err := cli.loadClientInfo(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,14 +378,6 @@ type ServerInfo struct {
|
|||||||
BuildkitVersion types.BuilderVersion
|
BuildkitVersion types.BuilderVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientInfo stores details about the supported features of the client
|
|
||||||
type ClientInfo struct {
|
|
||||||
// Deprecated: experimental CLI features always enabled. This field is kept
|
|
||||||
// for backward-compatibility, and is always "true".
|
|
||||||
HasExperimental bool
|
|
||||||
DefaultVersion string
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewDockerCli returns a DockerCli instance with all operators applied on it.
|
// NewDockerCli returns a DockerCli instance with all operators applied on it.
|
||||||
// It applies by default the standard streams, and the content trust from
|
// It applies by default the standard streams, and the content trust from
|
||||||
// environment.
|
// environment.
|
||||||
|
@ -202,8 +202,6 @@ func TestExperimentalCLI(t *testing.T) {
|
|||||||
config.SetDir(dir.Path())
|
config.SetDir(dir.Path())
|
||||||
err := cli.Initialize(flags.NewClientOptions())
|
err := cli.Initialize(flags.NewClientOptions())
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
// For backward-compatibility, HasExperimental will always be "true"
|
|
||||||
assert.Equal(t, cli.ClientInfo().HasExperimental, true)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,6 @@ func main() {
|
|||||||
|
|
||||||
type versionDetails interface {
|
type versionDetails interface {
|
||||||
Client() client.APIClient
|
Client() client.APIClient
|
||||||
ClientInfo() command.ClientInfo
|
|
||||||
ServerInfo() command.ServerInfo
|
ServerInfo() command.ServerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
// NotaryClientFuncType defines a function that returns a fake notary client
|
// NotaryClientFuncType defines a function that returns a fake notary client
|
||||||
type NotaryClientFuncType func(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
|
type NotaryClientFuncType func(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (notaryclient.Repository, error)
|
||||||
type clientInfoFuncType func() command.ClientInfo
|
|
||||||
|
|
||||||
// FakeCli emulates the default DockerCli
|
// FakeCli emulates the default DockerCli
|
||||||
type FakeCli struct {
|
type FakeCli struct {
|
||||||
@ -32,7 +31,6 @@ type FakeCli struct {
|
|||||||
err *bytes.Buffer
|
err *bytes.Buffer
|
||||||
in *streams.In
|
in *streams.In
|
||||||
server command.ServerInfo
|
server command.ServerInfo
|
||||||
clientInfoFunc clientInfoFuncType
|
|
||||||
notaryClientFunc NotaryClientFuncType
|
notaryClientFunc NotaryClientFuncType
|
||||||
manifestStore manifeststore.Store
|
manifestStore manifeststore.Store
|
||||||
registryClient registryclient.RegistryClient
|
registryClient registryclient.RegistryClient
|
||||||
@ -143,19 +141,6 @@ func (c *FakeCli) ServerInfo() command.ServerInfo {
|
|||||||
return c.server
|
return c.server
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientInfo returns client information
|
|
||||||
func (c *FakeCli) ClientInfo() command.ClientInfo {
|
|
||||||
if c.clientInfoFunc != nil {
|
|
||||||
return c.clientInfoFunc()
|
|
||||||
}
|
|
||||||
return c.DockerCli.ClientInfo()
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetClientInfo sets the internal getter for retrieving a ClientInfo
|
|
||||||
func (c *FakeCli) SetClientInfo(clientInfoFunc clientInfoFuncType) {
|
|
||||||
c.clientInfoFunc = clientInfoFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
// OutBuffer returns the stdout buffer
|
// OutBuffer returns the stdout buffer
|
||||||
func (c *FakeCli) OutBuffer() *bytes.Buffer {
|
func (c *FakeCli) OutBuffer() *bytes.Buffer {
|
||||||
return c.outBuffer
|
return c.outBuffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user