From 3c8d2ff91dd6c143099b29c9467d6723e6ed2ccc Mon Sep 17 00:00:00 2001 From: zeromake Date: Fri, 8 May 2020 16:54:01 +0800 Subject: [PATCH] fix: config version migration --- internal/command/cli.go | 2 +- internal/command/config.go | 2 +- internal/command/root.go | 2 +- internal/config/config.go | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/command/cli.go b/internal/command/cli.go index 59b9486..b4fd682 100644 --- a/internal/command/cli.go +++ b/internal/command/cli.go @@ -103,7 +103,7 @@ func WithConfig(config *config.Config) DebugCliOption { } // WithClientConfig set docker config -func WithClientConfig(dockerConfig config.DockerConfig) DebugCliOption { +func WithClientConfig(dockerConfig *config.DockerConfig) DebugCliOption { return func(cli *DebugCli) error { if cli.client != nil { err := cli.client.Close() diff --git a/internal/command/config.go b/internal/command/config.go index 47bddcd..c7ecac7 100644 --- a/internal/command/config.go +++ b/internal/command/config.go @@ -27,7 +27,7 @@ func init() { } return errors.Errorf("not find %s config", name) } - conf.DockerConfig[name] = *cfg + conf.DockerConfig[name] = cfg return conf.Save() }, } diff --git a/internal/command/root.go b/internal/command/root.go index 04b065d..4593c45 100644 --- a/internal/command/root.go +++ b/internal/command/root.go @@ -84,7 +84,7 @@ func buildCli(options execOptions) (*DebugCli, error) { return nil, errors.New("not set image") } if options.host != "" { - dockerConfig := config.DockerConfig{ + dockerConfig := &config.DockerConfig{ Host: options.host, } if options.certDir != "" { diff --git a/internal/config/config.go b/internal/config/config.go index c548700..29bee53 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -67,7 +67,7 @@ type Config struct { Image string `toml:"image"` Timeout time.Duration `toml:"timeout"` DockerConfigDefault string `toml:"config_default"` - DockerConfig map[string]DockerConfig `toml:"config"` + DockerConfig map[string]*DockerConfig `toml:"config"` } // Save save to default file @@ -144,8 +144,8 @@ func InitConfig() (*Config, error) { Timeout: time.Second * 10, MountDir: "/mnt/container", DockerConfigDefault: "default", - DockerConfig: map[string]DockerConfig{ - "default": dc, + DockerConfig: map[string]*DockerConfig{ + "default": &dc, }, } file, err := os.OpenFile(ConfigFile, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)