Remove cli/flags package

- Moving the `common*.go` files in `cmd/dockerd` directly (it's the
  only place it's getting used)
- Rename `cli/flags` to `cli/config` because it's the only thing left
  in that package 👼

Now, `integration-cli` does *truly* not depend on `cobra` stuff.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2017-06-01 13:34:31 -07:00
parent 75e685d620
commit 9ff9a91ab7
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
11 changed files with 84 additions and 106 deletions

View file

@ -1,4 +1,4 @@
package flags package config
import ( import (
"os" "os"
@ -12,9 +12,9 @@ var (
configFileDir = ".docker" configFileDir = ".docker"
) )
// ConfigurationDir returns the path to the configuration directory as specified by the DOCKER_CONFIG environment variable. // Dir returns the path to the configuration directory as specified by the DOCKER_CONFIG environment variable.
// TODO: this was copied from cli/config/configfile and should be removed once cmd/dockerd moves // TODO: this was copied from cli/config/configfile and should be removed once cmd/dockerd moves
func ConfigurationDir() string { func Dir() string {
return configDir return configDir
} }

View file

@ -1,13 +0,0 @@
package flags
// ClientOptions are the options used to configure the client cli
type ClientOptions struct {
Common *CommonOptions
ConfigDir string
Version bool
}
// NewClientOptions returns a new ClientOptions
func NewClientOptions() *ClientOptions {
return &ClientOptions{Common: NewCommonOptions()}
}

View file

@ -27,7 +27,6 @@ import (
systemrouter "github.com/docker/docker/api/server/router/system" systemrouter "github.com/docker/docker/api/server/router/system"
"github.com/docker/docker/api/server/router/volume" "github.com/docker/docker/api/server/router/volume"
"github.com/docker/docker/cli/debug" "github.com/docker/docker/cli/debug"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/daemon" "github.com/docker/docker/daemon"
"github.com/docker/docker/daemon/cluster" "github.com/docker/docker/daemon/cluster"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
@ -65,14 +64,14 @@ func NewDaemonCli() *DaemonCli {
return &DaemonCli{} return &DaemonCli{}
} }
func (cli *DaemonCli) start(opts daemonOptions) (err error) { func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
stopc := make(chan bool) stopc := make(chan bool)
defer close(stopc) defer close(stopc)
// warn from uuid package when running the daemon // warn from uuid package when running the daemon
uuid.Loggerf = logrus.Warnf uuid.Loggerf = logrus.Warnf
opts.common.SetDefaultOptions(opts.flags) opts.SetDefaultOptions(opts.flags)
if cli.Config, err = loadDaemonCliConfig(opts); err != nil { if cli.Config, err = loadDaemonCliConfig(opts); err != nil {
return err return err
@ -358,20 +357,20 @@ func shutdownDaemon(d *daemon.Daemon) {
} }
} }
func loadDaemonCliConfig(opts daemonOptions) (*config.Config, error) { func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
conf := opts.daemonConfig conf := opts.daemonConfig
flags := opts.flags flags := opts.flags
conf.Debug = opts.common.Debug conf.Debug = opts.Debug
conf.Hosts = opts.common.Hosts conf.Hosts = opts.Hosts
conf.LogLevel = opts.common.LogLevel conf.LogLevel = opts.LogLevel
conf.TLS = opts.common.TLS conf.TLS = opts.TLS
conf.TLSVerify = opts.common.TLSVerify conf.TLSVerify = opts.TLSVerify
conf.CommonTLSOptions = config.CommonTLSOptions{} conf.CommonTLSOptions = config.CommonTLSOptions{}
if opts.common.TLSOptions != nil { if opts.TLSOptions != nil {
conf.CommonTLSOptions.CAFile = opts.common.TLSOptions.CAFile conf.CommonTLSOptions.CAFile = opts.TLSOptions.CAFile
conf.CommonTLSOptions.CertFile = opts.common.TLSOptions.CertFile conf.CommonTLSOptions.CertFile = opts.TLSOptions.CertFile
conf.CommonTLSOptions.KeyFile = opts.common.TLSOptions.KeyFile conf.CommonTLSOptions.KeyFile = opts.TLSOptions.KeyFile
} }
if conf.TrustKeyPath == "" { if conf.TrustKeyPath == "" {
@ -425,12 +424,12 @@ func loadDaemonCliConfig(opts daemonOptions) (*config.Config, error) {
// Regardless of whether the user sets it to true or false, if they // Regardless of whether the user sets it to true or false, if they
// specify TLSVerify at all then we need to turn on TLS // specify TLSVerify at all then we need to turn on TLS
if conf.IsValueSet(cliflags.FlagTLSVerify) { if conf.IsValueSet(FlagTLSVerify) {
conf.TLS = true conf.TLS = true
} }
// ensure that the log level is the one set after merging configurations // ensure that the log level is the one set after merging configurations
cliflags.SetLogLevel(conf.LogLevel) setLogLevel(conf.LogLevel)
return conf, nil return conf, nil
} }

View file

@ -4,7 +4,6 @@ import (
"testing" "testing"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
"github.com/docker/docker/pkg/testutil" "github.com/docker/docker/pkg/testutil"
"github.com/docker/docker/pkg/testutil/tempfile" "github.com/docker/docker/pkg/testutil/tempfile"
@ -13,13 +12,10 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func defaultOptions(configFile string) daemonOptions { func defaultOptions(configFile string) *daemonOptions {
opts := daemonOptions{ opts := newDaemonOptions(&config.Config{})
daemonConfig: &config.Config{}, opts.flags = &pflag.FlagSet{}
flags: &pflag.FlagSet{}, opts.InstallFlags(opts.flags)
common: cliflags.NewCommonOptions(),
}
opts.common.InstallFlags(opts.flags)
installConfigFlags(opts.daemonConfig, opts.flags) installConfigFlags(opts.daemonConfig, opts.flags)
opts.flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "") opts.flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "")
opts.configFile = configFile opts.configFile = configFile
@ -28,7 +24,7 @@ func defaultOptions(configFile string) daemonOptions {
func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) { func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
opts := defaultOptions("") opts := defaultOptions("")
opts.common.Debug = true opts.Debug = true
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)
require.NoError(t, err) require.NoError(t, err)
@ -40,8 +36,8 @@ func TestLoadDaemonCliConfigWithoutOverriding(t *testing.T) {
func TestLoadDaemonCliConfigWithTLS(t *testing.T) { func TestLoadDaemonCliConfigWithTLS(t *testing.T) {
opts := defaultOptions("") opts := defaultOptions("")
opts.common.TLSOptions.CAFile = "/tmp/ca.pem" opts.TLSOptions.CAFile = "/tmp/ca.pem"
opts.common.TLS = true opts.TLS = true
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)
require.NoError(t, err) require.NoError(t, err)
@ -70,7 +66,7 @@ func TestLoadDaemonCliConfigWithTLSVerify(t *testing.T) {
defer tempFile.Remove() defer tempFile.Remove()
opts := defaultOptions(tempFile.Name()) opts := defaultOptions(tempFile.Name())
opts.common.TLSOptions.CAFile = "/tmp/ca.pem" opts.TLSOptions.CAFile = "/tmp/ca.pem"
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)
require.NoError(t, err) require.NoError(t, err)
@ -83,7 +79,7 @@ func TestLoadDaemonCliConfigWithExplicitTLSVerifyFalse(t *testing.T) {
defer tempFile.Remove() defer tempFile.Remove()
opts := defaultOptions(tempFile.Name()) opts := defaultOptions(tempFile.Name())
opts.common.TLSOptions.CAFile = "/tmp/ca.pem" opts.TLSOptions.CAFile = "/tmp/ca.pem"
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)
require.NoError(t, err) require.NoError(t, err)
@ -96,7 +92,7 @@ func TestLoadDaemonCliConfigWithoutTLSVerify(t *testing.T) {
defer tempFile.Remove() defer tempFile.Remove()
opts := defaultOptions(tempFile.Name()) opts := defaultOptions(tempFile.Name())
opts.common.TLSOptions.CAFile = "/tmp/ca.pem" opts.TLSOptions.CAFile = "/tmp/ca.pem"
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)
require.NoError(t, err) require.NoError(t, err)

View file

@ -20,8 +20,8 @@ func TestLoadDaemonCliConfigWithDaemonFlags(t *testing.T) {
defer tempFile.Remove() defer tempFile.Remove()
opts := defaultOptions(tempFile.Name()) opts := defaultOptions(tempFile.Name())
opts.common.Debug = true opts.Debug = true
opts.common.LogLevel = "info" opts.LogLevel = "info"
assert.NoError(t, opts.flags.Set("selinux-enabled", "true")) assert.NoError(t, opts.flags.Set("selinux-enabled", "true"))
loadedConfig, err := loadDaemonCliConfig(opts) loadedConfig, err := loadDaemonCliConfig(opts)

View file

@ -8,28 +8,15 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/cli" "github.com/docker/docker/cli"
cliflags "github.com/docker/docker/cli/flags"
"github.com/docker/docker/daemon/config" "github.com/docker/docker/daemon/config"
"github.com/docker/docker/dockerversion" "github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
"github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/term"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag"
) )
type daemonOptions struct {
version bool
configFile string
daemonConfig *config.Config
common *cliflags.CommonOptions
flags *pflag.FlagSet
}
func newDaemonCommand() *cobra.Command { func newDaemonCommand() *cobra.Command {
opts := daemonOptions{ opts := newDaemonOptions(config.New())
daemonConfig: config.New(),
common: cliflags.NewCommonOptions(),
}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "dockerd [OPTIONS]", Use: "dockerd [OPTIONS]",
@ -47,14 +34,14 @@ func newDaemonCommand() *cobra.Command {
flags := cmd.Flags() flags := cmd.Flags()
flags.BoolVarP(&opts.version, "version", "v", false, "Print version information and quit") flags.BoolVarP(&opts.version, "version", "v", false, "Print version information and quit")
flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "Daemon configuration file") flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "Daemon configuration file")
opts.common.InstallFlags(flags) opts.InstallFlags(flags)
installConfigFlags(opts.daemonConfig, flags) installConfigFlags(opts.daemonConfig, flags)
installServiceFlags(flags) installServiceFlags(flags)
return cmd return cmd
} }
func runDaemon(opts daemonOptions) error { func runDaemon(opts *daemonOptions) error {
if opts.version { if opts.version {
showVersion() showVersion()
return nil return nil

View file

@ -1,4 +1,4 @@
package flags package main
import ( import (
"fmt" "fmt"
@ -6,6 +6,8 @@ import (
"path/filepath" "path/filepath"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
cliconfig "github.com/docker/docker/cli/config"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
"github.com/docker/go-connections/tlsconfig" "github.com/docker/go-connections/tlsconfig"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -27,8 +29,11 @@ var (
dockerTLSVerify = os.Getenv("DOCKER_TLS_VERIFY") != "" dockerTLSVerify = os.Getenv("DOCKER_TLS_VERIFY") != ""
) )
// CommonOptions are options common to both the client and the daemon. type daemonOptions struct {
type CommonOptions struct { version bool
configFile string
daemonConfig *config.Config
flags *pflag.FlagSet
Debug bool Debug bool
Hosts []string Hosts []string
LogLevel string LogLevel string
@ -37,54 +42,56 @@ type CommonOptions struct {
TLSOptions *tlsconfig.Options TLSOptions *tlsconfig.Options
} }
// NewCommonOptions returns a new CommonOptions // newDaemonOptions returns a new daemonFlags
func NewCommonOptions() *CommonOptions { func newDaemonOptions(config *config.Config) *daemonOptions {
return &CommonOptions{} return &daemonOptions{
daemonConfig: config,
}
} }
// InstallFlags adds flags for the common options on the FlagSet // InstallFlags adds flags for the common options on the FlagSet
func (commonOpts *CommonOptions) InstallFlags(flags *pflag.FlagSet) { func (o *daemonOptions) InstallFlags(flags *pflag.FlagSet) {
if dockerCertPath == "" { if dockerCertPath == "" {
dockerCertPath = ConfigurationDir() dockerCertPath = cliconfig.Dir()
} }
flags.BoolVarP(&commonOpts.Debug, "debug", "D", false, "Enable debug mode") flags.BoolVarP(&o.Debug, "debug", "D", false, "Enable debug mode")
flags.StringVarP(&commonOpts.LogLevel, "log-level", "l", "info", `Set the logging level ("debug"|"info"|"warn"|"error"|"fatal")`) flags.StringVarP(&o.LogLevel, "log-level", "l", "info", `Set the logging level ("debug"|"info"|"warn"|"error"|"fatal")`)
flags.BoolVar(&commonOpts.TLS, "tls", false, "Use TLS; implied by --tlsverify") flags.BoolVar(&o.TLS, "tls", false, "Use TLS; implied by --tlsverify")
flags.BoolVar(&commonOpts.TLSVerify, FlagTLSVerify, dockerTLSVerify, "Use TLS and verify the remote") flags.BoolVar(&o.TLSVerify, FlagTLSVerify, dockerTLSVerify, "Use TLS and verify the remote")
// TODO use flag flags.String("identity"}, "i", "", "Path to libtrust key file") // TODO use flag flags.String("identity"}, "i", "", "Path to libtrust key file")
commonOpts.TLSOptions = &tlsconfig.Options{ o.TLSOptions = &tlsconfig.Options{
CAFile: filepath.Join(dockerCertPath, DefaultCaFile), CAFile: filepath.Join(dockerCertPath, DefaultCaFile),
CertFile: filepath.Join(dockerCertPath, DefaultCertFile), CertFile: filepath.Join(dockerCertPath, DefaultCertFile),
KeyFile: filepath.Join(dockerCertPath, DefaultKeyFile), KeyFile: filepath.Join(dockerCertPath, DefaultKeyFile),
} }
tlsOptions := commonOpts.TLSOptions tlsOptions := o.TLSOptions
flags.Var(opts.NewQuotedString(&tlsOptions.CAFile), "tlscacert", "Trust certs signed only by this CA") flags.Var(opts.NewQuotedString(&tlsOptions.CAFile), "tlscacert", "Trust certs signed only by this CA")
flags.Var(opts.NewQuotedString(&tlsOptions.CertFile), "tlscert", "Path to TLS certificate file") flags.Var(opts.NewQuotedString(&tlsOptions.CertFile), "tlscert", "Path to TLS certificate file")
flags.Var(opts.NewQuotedString(&tlsOptions.KeyFile), "tlskey", "Path to TLS key file") flags.Var(opts.NewQuotedString(&tlsOptions.KeyFile), "tlskey", "Path to TLS key file")
hostOpt := opts.NewNamedListOptsRef("hosts", &commonOpts.Hosts, opts.ValidateHost) hostOpt := opts.NewNamedListOptsRef("hosts", &o.Hosts, opts.ValidateHost)
flags.VarP(hostOpt, "host", "H", "Daemon socket(s) to connect to") flags.VarP(hostOpt, "host", "H", "Daemon socket(s) to connect to")
} }
// SetDefaultOptions sets default values for options after flag parsing is // SetDefaultOptions sets default values for options after flag parsing is
// complete // complete
func (commonOpts *CommonOptions) SetDefaultOptions(flags *pflag.FlagSet) { func (o *daemonOptions) SetDefaultOptions(flags *pflag.FlagSet) {
// Regardless of whether the user sets it to true or false, if they // Regardless of whether the user sets it to true or false, if they
// specify --tlsverify at all then we need to turn on TLS // specify --tlsverify at all then we need to turn on TLS
// TLSVerify can be true even if not set due to DOCKER_TLS_VERIFY env var, so we need // TLSVerify can be true even if not set due to DOCKER_TLS_VERIFY env var, so we need
// to check that here as well // to check that here as well
if flags.Changed(FlagTLSVerify) || commonOpts.TLSVerify { if flags.Changed(FlagTLSVerify) || o.TLSVerify {
commonOpts.TLS = true o.TLS = true
} }
if !commonOpts.TLS { if !o.TLS {
commonOpts.TLSOptions = nil o.TLSOptions = nil
} else { } else {
tlsOptions := commonOpts.TLSOptions tlsOptions := o.TLSOptions
tlsOptions.InsecureSkipVerify = !commonOpts.TLSVerify tlsOptions.InsecureSkipVerify = !o.TLSVerify
// Reset CertFile and KeyFile to empty string if the user did not specify // Reset CertFile and KeyFile to empty string if the user did not specify
// the respective flags and the respective default files were not found. // the respective flags and the respective default files were not found.
@ -101,8 +108,8 @@ func (commonOpts *CommonOptions) SetDefaultOptions(flags *pflag.FlagSet) {
} }
} }
// SetLogLevel sets the logrus logging level // setLogLevel sets the logrus logging level
func SetLogLevel(logLevel string) { func setLogLevel(logLevel string) {
if logLevel != "" { if logLevel != "" {
lvl, err := logrus.ParseLevel(logLevel) lvl, err := logrus.ParseLevel(logLevel)
if err != nil { if err != nil {

View file

@ -1,16 +1,18 @@
package flags package main
import ( import (
"path/filepath" "path/filepath"
"testing" "testing"
cliconfig "github.com/docker/docker/cli/config"
"github.com/docker/docker/daemon/config"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestCommonOptionsInstallFlags(t *testing.T) { func TestCommonOptionsInstallFlags(t *testing.T) {
flags := pflag.NewFlagSet("testing", pflag.ContinueOnError) flags := pflag.NewFlagSet("testing", pflag.ContinueOnError)
opts := NewCommonOptions() opts := newDaemonOptions(&config.Config{})
opts.InstallFlags(flags) opts.InstallFlags(flags)
err := flags.Parse([]string{ err := flags.Parse([]string{
@ -25,12 +27,12 @@ func TestCommonOptionsInstallFlags(t *testing.T) {
} }
func defaultPath(filename string) string { func defaultPath(filename string) string {
return filepath.Join(ConfigurationDir(), filename) return filepath.Join(cliconfig.Dir(), filename)
} }
func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) { func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) {
flags := pflag.NewFlagSet("testing", pflag.ContinueOnError) flags := pflag.NewFlagSet("testing", pflag.ContinueOnError)
opts := NewCommonOptions() opts := newDaemonOptions(&config.Config{})
opts.InstallFlags(flags) opts.InstallFlags(flags)
err := flags.Parse([]string{}) err := flags.Parse([]string{})

View file

@ -12,7 +12,7 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/cli/flags" "github.com/docker/docker/cli/config"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build/fakestorage" "github.com/docker/docker/integration-cli/cli/build/fakestorage"
"github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/integration-cli/daemon"
@ -406,7 +406,7 @@ func (s *DockerTrustSuite) TearDownTest(c *check.C) {
} }
// Remove trusted keys and metadata after test // Remove trusted keys and metadata after test
os.RemoveAll(filepath.Join(flags.ConfigurationDir(), "trust")) os.RemoveAll(filepath.Join(config.Dir(), "trust"))
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }

View file

@ -12,7 +12,7 @@ import (
"sync" "sync"
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/docker/docker/cli/flags" "github.com/docker/docker/cli/config"
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build" "github.com/docker/docker/integration-cli/cli/build"
@ -294,7 +294,7 @@ func (s *DockerTrustSuite) TestTrustedPush(c *check.C) {
}) })
// Assert that we rotated the snapshot key to the server by checking our local keystore // Assert that we rotated the snapshot key to the server by checking our local keystore
contents, err := ioutil.ReadDir(filepath.Join(flags.ConfigurationDir(), "trust/private/tuf_keys", privateRegistryURL, "dockerclitrusted/pushtest")) contents, err := ioutil.ReadDir(filepath.Join(config.Dir(), "trust/private/tuf_keys", privateRegistryURL, "dockerclitrusted/pushtest"))
c.Assert(err, check.IsNil, check.Commentf("Unable to read local tuf key files")) c.Assert(err, check.IsNil, check.Commentf("Unable to read local tuf key files"))
// Check that we only have 1 key (targets key) // Check that we only have 1 key (targets key)
c.Assert(contents, checker.HasLen, 1) c.Assert(contents, checker.HasLen, 1)
@ -399,7 +399,7 @@ func (s *DockerTrustSuite) TestTrustedPushWithReleasesDelegationOnly(c *check.C)
s.assertTargetNotInRoles(c, repoName, "latest", "targets") s.assertTargetNotInRoles(c, repoName, "latest", "targets")
// Try pull after push // Try pull after push
os.RemoveAll(filepath.Join(flags.ConfigurationDir(), "trust")) os.RemoveAll(filepath.Join(config.Dir(), "trust"))
cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{ cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{
Out: "Status: Image is up to date", Out: "Status: Image is up to date",
@ -436,7 +436,7 @@ func (s *DockerTrustSuite) TestTrustedPushSignsAllFirstLevelRolesWeHaveKeysFor(c
s.assertTargetNotInRoles(c, repoName, "latest", "targets") s.assertTargetNotInRoles(c, repoName, "latest", "targets")
// Try pull after push // Try pull after push
os.RemoveAll(filepath.Join(flags.ConfigurationDir(), "trust")) os.RemoveAll(filepath.Join(config.Dir(), "trust"))
// pull should fail because none of these are the releases role // pull should fail because none of these are the releases role
cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{ cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{
@ -472,7 +472,7 @@ func (s *DockerTrustSuite) TestTrustedPushSignsForRolesWithKeysAndValidPaths(c *
s.assertTargetNotInRoles(c, repoName, "latest", "targets") s.assertTargetNotInRoles(c, repoName, "latest", "targets")
// Try pull after push // Try pull after push
os.RemoveAll(filepath.Join(flags.ConfigurationDir(), "trust")) os.RemoveAll(filepath.Join(config.Dir(), "trust"))
// pull should fail because none of these are the releases role // pull should fail because none of these are the releases role
cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{ cli.Docker(cli.Args("pull", targetName), trustedCmd).Assert(c, icmd.Expected{

View file

@ -11,7 +11,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/docker/docker/cli/flags" cliconfig "github.com/docker/docker/cli/config"
"github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli"
icmd "github.com/docker/docker/pkg/testutil/cmd" icmd "github.com/docker/docker/pkg/testutil/cmd"
@ -108,7 +108,7 @@ func newTestNotary(c *check.C) (*testNotary, error) {
"skipTLSVerify": true "skipTLSVerify": true
} }
}` }`
if _, err = fmt.Fprintf(clientConfig, template, filepath.Join(flags.ConfigurationDir(), "trust"), notaryURL); err != nil { if _, err = fmt.Fprintf(clientConfig, template, filepath.Join(cliconfig.Dir(), "trust"), notaryURL); err != nil {
os.RemoveAll(tmp) os.RemoveAll(tmp)
return nil, err return nil, err
} }