Skip to content

Commit

Permalink
fix: config version migration
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromake committed May 8, 2020
1 parent 7681c53 commit 3c8d2ff
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/command/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion internal/command/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3c8d2ff

Please sign in to comment.