mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-03 09:57:41 +08:00
Merge pull request #1054 from thaJeztah/test_cli_update
vendor: v20.10.3-0.20220803220330-418ca3b4d46f (v22.06.0-dev)
This commit is contained in:
commit
18023d7f32
@ -5,18 +5,15 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
|
||||||
cliflags "github.com/docker/cli/cli/flags"
|
cliflags "github.com/docker/cli/cli/flags"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDefaultContextInitializer(t *testing.T) {
|
func TestDefaultContextInitializer(t *testing.T) {
|
||||||
cli, err := command.NewDockerCli()
|
|
||||||
require.NoError(t, err)
|
|
||||||
os.Setenv("KUBECONFIG", "./fixtures/test-kubeconfig")
|
os.Setenv("KUBECONFIG", "./fixtures/test-kubeconfig")
|
||||||
defer os.Unsetenv("KUBECONFIG")
|
defer os.Unsetenv("KUBECONFIG")
|
||||||
ctx, err := command.ResolveDefaultContext(&cliflags.CommonOptions{}, &configfile.ConfigFile{}, command.DefaultContextStoreConfig(), cli.Err())
|
ctx, err := command.ResolveDefaultContext(&cliflags.CommonOptions{}, command.DefaultContextStoreConfig())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "default", ctx.Meta.Name)
|
assert.Equal(t, "default", ctx.Meta.Name)
|
||||||
assert.Equal(t, "zoinx", ctx.Meta.Endpoints[KubernetesEndpoint].(EndpointMeta).DefaultNamespace)
|
assert.Equal(t, "zoinx", ctx.Meta.Endpoints[KubernetesEndpoint].(EndpointMeta).DefaultNamespace)
|
||||||
|
2
go.mod
2
go.mod
@ -155,7 +155,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
replace (
|
replace (
|
||||||
github.com/docker/cli => github.com/docker/cli v20.10.3-0.20220721163225-f1615facb1ca+incompatible // master (v22.06-dev)
|
github.com/docker/cli => github.com/docker/cli v20.10.3-0.20220803220330-418ca3b4d46f+incompatible // master (v22.06-dev)
|
||||||
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220720171342-a60b458179aa+incompatible // 22.06 branch (v22.06-dev)
|
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220720171342-a60b458179aa+incompatible // 22.06 branch (v22.06-dev)
|
||||||
k8s.io/api => k8s.io/api v0.22.4
|
k8s.io/api => k8s.io/api v0.22.4
|
||||||
k8s.io/apimachinery => k8s.io/apimachinery v0.22.4
|
k8s.io/apimachinery => k8s.io/apimachinery v0.22.4
|
||||||
|
4
go.sum
4
go.sum
@ -157,8 +157,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
|
|||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
github.com/distribution/distribution/v3 v3.0.0-20220725133111-4bf3547399eb h1:oCCuuU3kMO3sjZH/p7LamvQNW9SWoT4yQuMGcdSxGAE=
|
github.com/distribution/distribution/v3 v3.0.0-20220725133111-4bf3547399eb h1:oCCuuU3kMO3sjZH/p7LamvQNW9SWoT4yQuMGcdSxGAE=
|
||||||
github.com/distribution/distribution/v3 v3.0.0-20220725133111-4bf3547399eb/go.mod h1:28YO/VJk9/64+sTGNuYaBjWxrXTPrj0C0XmgTIOjxX4=
|
github.com/distribution/distribution/v3 v3.0.0-20220725133111-4bf3547399eb/go.mod h1:28YO/VJk9/64+sTGNuYaBjWxrXTPrj0C0XmgTIOjxX4=
|
||||||
github.com/docker/cli v20.10.3-0.20220721163225-f1615facb1ca+incompatible h1:Dd/CSOpM6U0thw3xNPlw6m+5/4VOexEcgKlL38haGgk=
|
github.com/docker/cli v20.10.3-0.20220803220330-418ca3b4d46f+incompatible h1:iKanFYBu6Cum7d9j8JGTw2s/d7hUAcXRkEcp2m8b6Qc=
|
||||||
github.com/docker/cli v20.10.3-0.20220721163225-f1615facb1ca+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
github.com/docker/cli v20.10.3-0.20220803220330-418ca3b4d46f+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||||
github.com/docker/cli-docs-tool v0.5.0 h1:EjGwI6EyB7YemHCC7R8mwXszJTbuq0T0pFuDC5bMhcE=
|
github.com/docker/cli-docs-tool v0.5.0 h1:EjGwI6EyB7YemHCC7R8mwXszJTbuq0T0pFuDC5bMhcE=
|
||||||
github.com/docker/cli-docs-tool v0.5.0/go.mod h1:zMjqTFCU361PRh8apiXzeAZ1Q/xupbIwTusYpzCXS/o=
|
github.com/docker/cli-docs-tool v0.5.0/go.mod h1:zMjqTFCU361PRh8apiXzeAZ1Q/xupbIwTusYpzCXS/o=
|
||||||
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
|
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
|
||||||
|
22
vendor/github.com/docker/cli/cli/command/cli.go
generated
vendored
22
vendor/github.com/docker/cli/cli/command/cli.go
generated
vendored
@ -35,6 +35,8 @@ import (
|
|||||||
notaryclient "github.com/theupdateframework/notary/client"
|
notaryclient "github.com/theupdateframework/notary/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultInitTimeout = 2 * time.Second
|
||||||
|
|
||||||
// Streams is an interface which exposes the standard input and output streams
|
// Streams is an interface which exposes the standard input and output streams
|
||||||
type Streams interface {
|
type Streams interface {
|
||||||
In() *streams.In
|
In() *streams.In
|
||||||
@ -77,6 +79,7 @@ type DockerCli struct {
|
|||||||
currentContext string
|
currentContext string
|
||||||
dockerEndpoint docker.Endpoint
|
dockerEndpoint docker.Endpoint
|
||||||
contextStoreConfig store.Config
|
contextStoreConfig store.Config
|
||||||
|
initTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultVersion returns api.defaultVersion.
|
// DefaultVersion returns api.defaultVersion.
|
||||||
@ -216,7 +219,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize
|
|||||||
cli.contextStore = &ContextStoreWithDefault{
|
cli.contextStore = &ContextStoreWithDefault{
|
||||||
Store: baseContextStore,
|
Store: baseContextStore,
|
||||||
Resolver: func() (*DefaultContext, error) {
|
Resolver: func() (*DefaultContext, error) {
|
||||||
return ResolveDefaultContext(opts.Common, cli.ConfigFile(), cli.contextStoreConfig, cli.Err())
|
return ResolveDefaultContext(opts.Common, cli.contextStoreConfig)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cli.currentContext, err = resolveContextName(opts.Common, cli.configFile, cli.contextStore)
|
cli.currentContext, err = resolveContextName(opts.Common, cli.configFile, cli.contextStore)
|
||||||
@ -244,7 +247,7 @@ func NewAPIClientFromFlags(opts *cliflags.CommonOptions, configFile *configfile.
|
|||||||
contextStore := &ContextStoreWithDefault{
|
contextStore := &ContextStoreWithDefault{
|
||||||
Store: store.New(config.ContextStoreDir(), storeConfig),
|
Store: store.New(config.ContextStoreDir(), storeConfig),
|
||||||
Resolver: func() (*DefaultContext, error) {
|
Resolver: func() (*DefaultContext, error) {
|
||||||
return ResolveDefaultContext(opts, configFile, storeConfig, io.Discard)
|
return ResolveDefaultContext(opts, storeConfig)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
contextName, err := resolveContextName(opts, configFile, contextStore)
|
contextName, err := resolveContextName(opts, configFile, contextStore)
|
||||||
@ -313,13 +316,20 @@ func resolveDefaultDockerEndpoint(opts *cliflags.CommonOptions) (docker.Endpoint
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cli *DockerCli) getInitTimeout() time.Duration {
|
||||||
|
if cli.initTimeout != 0 {
|
||||||
|
return cli.initTimeout
|
||||||
|
}
|
||||||
|
return defaultInitTimeout
|
||||||
|
}
|
||||||
|
|
||||||
func (cli *DockerCli) initializeFromClient() {
|
func (cli *DockerCli) initializeFromClient() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
if strings.HasPrefix(cli.DockerEndpoint().Host, "tcp://") {
|
if !strings.HasPrefix(cli.DockerEndpoint().Host, "ssh://") {
|
||||||
// @FIXME context.WithTimeout doesn't work with connhelper / ssh connections
|
// @FIXME context.WithTimeout doesn't work with connhelper / ssh connections
|
||||||
// time="2020-04-10T10:16:26Z" level=warning msg="commandConn.CloseWrite: commandconn: failed to wait: signal: killed"
|
// time="2020-04-10T10:16:26Z" level=warning msg="commandConn.CloseWrite: commandconn: failed to wait: signal: killed"
|
||||||
var cancel func()
|
var cancel func()
|
||||||
ctx, cancel = context.WithTimeout(ctx, 2*time.Second)
|
ctx, cancel = context.WithTimeout(ctx, cli.getInitTimeout())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,10 +466,10 @@ func resolveContextName(opts *cliflags.CommonOptions, config *configfile.ConfigF
|
|||||||
if len(opts.Hosts) > 0 {
|
if len(opts.Hosts) > 0 {
|
||||||
return DefaultContextName, nil
|
return DefaultContextName, nil
|
||||||
}
|
}
|
||||||
if _, present := os.LookupEnv(client.EnvOverrideHost); present {
|
if os.Getenv(client.EnvOverrideHost) != "" {
|
||||||
return DefaultContextName, nil
|
return DefaultContextName, nil
|
||||||
}
|
}
|
||||||
if ctxName, ok := os.LookupEnv("DOCKER_CONTEXT"); ok {
|
if ctxName := os.Getenv("DOCKER_CONTEXT"); ctxName != "" {
|
||||||
return ctxName, nil
|
return ctxName, nil
|
||||||
}
|
}
|
||||||
if config != nil && config.CurrentContext != "" {
|
if config != nil && config.CurrentContext != "" {
|
||||||
|
16
vendor/github.com/docker/cli/cli/command/cli_options.go
generated
vendored
16
vendor/github.com/docker/cli/cli/command/cli_options.go
generated
vendored
@ -1,13 +1,10 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/context/docker"
|
|
||||||
"github.com/docker/cli/cli/context/store"
|
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/moby/term"
|
"github.com/moby/term"
|
||||||
)
|
)
|
||||||
@ -82,19 +79,6 @@ func WithContentTrust(enabled bool) DockerCliOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithContextEndpointType add support for an additional typed endpoint in the context store
|
|
||||||
// Plugins should use this to store additional endpoints configuration in the context store
|
|
||||||
func WithContextEndpointType(endpointName string, endpointType store.TypeGetter) DockerCliOption {
|
|
||||||
return func(cli *DockerCli) error {
|
|
||||||
switch endpointName {
|
|
||||||
case docker.DockerEndpoint:
|
|
||||||
return fmt.Errorf("cannot change %q endpoint type", endpointName)
|
|
||||||
}
|
|
||||||
cli.contextStoreConfig.SetEndpoint(endpointName, endpointType)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithDefaultContextStoreConfig configures the cli to use the default context store configuration.
|
// WithDefaultContextStoreConfig configures the cli to use the default context store configuration.
|
||||||
func WithDefaultContextStoreConfig() DockerCliOption {
|
func WithDefaultContextStoreConfig() DockerCliOption {
|
||||||
return func(cli *DockerCli) error {
|
return func(cli *DockerCli) error {
|
||||||
|
6
vendor/github.com/docker/cli/cli/command/defaultcontextstore.go
generated
vendored
6
vendor/github.com/docker/cli/cli/command/defaultcontextstore.go
generated
vendored
@ -2,9 +2,7 @@ package command
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
|
||||||
"github.com/docker/cli/cli/context/docker"
|
"github.com/docker/cli/cli/context/docker"
|
||||||
"github.com/docker/cli/cli/context/store"
|
"github.com/docker/cli/cli/context/store"
|
||||||
cliflags "github.com/docker/cli/cli/flags"
|
cliflags "github.com/docker/cli/cli/flags"
|
||||||
@ -45,7 +43,7 @@ type EndpointDefaultResolver interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResolveDefaultContext creates a Metadata for the current CLI invocation parameters
|
// ResolveDefaultContext creates a Metadata for the current CLI invocation parameters
|
||||||
func ResolveDefaultContext(opts *cliflags.CommonOptions, config *configfile.ConfigFile, storeconfig store.Config, stderr io.Writer) (*DefaultContext, error) {
|
func ResolveDefaultContext(opts *cliflags.CommonOptions, config store.Config) (*DefaultContext, error) {
|
||||||
contextTLSData := store.ContextTLSData{
|
contextTLSData := store.ContextTLSData{
|
||||||
Endpoints: make(map[string]store.EndpointTLSData),
|
Endpoints: make(map[string]store.EndpointTLSData),
|
||||||
}
|
}
|
||||||
@ -66,7 +64,7 @@ func ResolveDefaultContext(opts *cliflags.CommonOptions, config *configfile.Conf
|
|||||||
contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerEP.TLSData.ToStoreTLSData()
|
contextTLSData.Endpoints[docker.DockerEndpoint] = *dockerEP.TLSData.ToStoreTLSData()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := storeconfig.ForeachEndpointType(func(n string, get store.TypeGetter) error {
|
if err := config.ForeachEndpointType(func(n string, get store.TypeGetter) error {
|
||||||
if n == docker.DockerEndpoint { // handled above
|
if n == docker.DockerEndpoint { // handled above
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -117,7 +117,7 @@ github.com/davecgh/go-spew/spew
|
|||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
github.com/distribution/distribution/v3/digestset
|
github.com/distribution/distribution/v3/digestset
|
||||||
github.com/distribution/distribution/v3/reference
|
github.com/distribution/distribution/v3/reference
|
||||||
# github.com/docker/cli v20.10.17+incompatible => github.com/docker/cli v20.10.3-0.20220721163225-f1615facb1ca+incompatible
|
# github.com/docker/cli v20.10.17+incompatible => github.com/docker/cli v20.10.3-0.20220803220330-418ca3b4d46f+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/cli/cli
|
github.com/docker/cli/cli
|
||||||
github.com/docker/cli/cli-plugins/manager
|
github.com/docker/cli/cli-plugins/manager
|
||||||
@ -1010,7 +1010,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
|||||||
# sigs.k8s.io/yaml v1.2.0
|
# sigs.k8s.io/yaml v1.2.0
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
sigs.k8s.io/yaml
|
sigs.k8s.io/yaml
|
||||||
# github.com/docker/cli => github.com/docker/cli v20.10.3-0.20220721163225-f1615facb1ca+incompatible
|
# github.com/docker/cli => github.com/docker/cli v20.10.3-0.20220803220330-418ca3b4d46f+incompatible
|
||||||
# github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220720171342-a60b458179aa+incompatible
|
# github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220720171342-a60b458179aa+incompatible
|
||||||
# k8s.io/api => k8s.io/api v0.22.4
|
# k8s.io/api => k8s.io/api v0.22.4
|
||||||
# k8s.io/apimachinery => k8s.io/apimachinery v0.22.4
|
# k8s.io/apimachinery => k8s.io/apimachinery v0.22.4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user