Skip to content

Commit 61f12fa

Browse files
committed
feat: config add client version
1 parent c2cf550 commit 61f12fa

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

internal/command/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func WithClientConfig(dockerConfig config.DockerConfig) DebugCliOption {
121121
}
122122
clientOpts := []client.Opt{
123123
client.WithHost(host),
124-
client.WithVersion(""),
124+
client.WithVersion(dockerConfig.Version),
125125
}
126126
if dockerConfig.TLS {
127127
clientOpts = append(clientOpts, client.WithTLSClientConfig(

internal/config/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"github.com/BurntSushi/toml"
7+
"github.com/docker/docker/api"
78
"github.com/mitchellh/go-homedir"
89
"github.com/pkg/errors"
910
"github.com/zeromake/docker-debug/pkg/opts"
@@ -47,6 +48,7 @@ func init() {
4748

4849
// DockerConfig docker 配置
4950
type DockerConfig struct {
51+
Version string `toml:"version"`
5052
Host string `toml:"host"`
5153
TLS bool `toml:"tls"`
5254
CertDir string `toml:"cert_dir"`
@@ -128,7 +130,8 @@ func InitConfig() (*Config, error) {
128130
}
129131
}
130132
dc := DockerConfig{
131-
Host: host,
133+
Host: host,
134+
Version: api.DefaultVersion,
132135
}
133136
certPath := os.Getenv("DOCKER_CERT_PATH")
134137
if tlsVerify && certPath != "" {

internal/config/migration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type migration struct {
1212
Version semver.Version
1313
}
1414

15-
var migrationArr = []*migration{}
15+
var migrationArr []*migration
1616

1717
// MigrationConfig migration config version
1818
func MigrationConfig(conf *Config) error {

internal/config/version-0.7.2.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package config
2+
3+
import (
4+
"github.com/blang/semver"
5+
"github.com/docker/docker/api"
6+
)
7+
8+
// Up000702 update version 0.7.2
9+
func Up000702(conf *Config) error {
10+
for _, c := range conf.DockerConfig {
11+
if c.Version == "" {
12+
c.Version = api.DefaultVersion
13+
}
14+
}
15+
return nil
16+
}
17+
18+
func init() {
19+
v, err := semver.Parse("0.7.2")
20+
if err != nil {
21+
return
22+
}
23+
migrationArr = append(migrationArr, &migration{
24+
Up: Up000702,
25+
Version: v,
26+
})
27+
}

0 commit comments

Comments
 (0)