From 428beb7ae55a70aa79ab6c15804b05e0b9b5fde6 Mon Sep 17 00:00:00 2001 From: lujian Date: Fri, 10 Apr 2020 12:16:01 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feature:secret=E5=92=8Cyml=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0secret=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- secret.go | 16 ++++++++++++++ secret_complex.go | 25 +++++++++++++++++++++ secret_simple.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++ service.go | 6 +++--- yml.go | 10 ++++----- yml_secret.go | 18 ++++++++++++++++ 6 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 secret.go create mode 100644 secret_complex.go create mode 100644 secret_simple.go create mode 100644 yml_secret.go diff --git a/secret.go b/secret.go new file mode 100644 index 0000000..3a3404c --- /dev/null +++ b/secret.go @@ -0,0 +1,16 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +// 暴露的映射的公共接口 +type Secret interface { + IsSecret() bool +} diff --git a/secret_complex.go b/secret_complex.go new file mode 100644 index 0000000..be491f0 --- /dev/null +++ b/secret_complex.go @@ -0,0 +1,25 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +// 密钥(Long Syntax) +type SecretComplex struct { + Source string `yaml:"source"` // 名称 + Target string `yaml:"target,omitempty"` // 文件名 + Uid string `yaml:"uid,omitempty"` // 文件UID + Gid string `yaml:"gid,omitempty"` // 文件GID + Mode string `yaml:"mode,omitempty"` // 文件权限 +} + +// 实现公共接口 +func (SecretComplex) IsSecret() bool { + return true +} diff --git a/secret_simple.go b/secret_simple.go new file mode 100644 index 0000000..b003342 --- /dev/null +++ b/secret_simple.go @@ -0,0 +1,55 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +import ( + "errors" +) + +// 密钥(Short Syntax) +type SecretSimple struct { + Source string // 名称 +} + +// 新建一个密钥 +func NewSecretSimple(source string) SecretSimple { + return SecretSimple{ + Source: source, + } +} + +// 实现公共接口 +func (SecretSimple) IsSecret() bool { + return true +} + +func (m SecretSimple) MarshalYAML() (result interface{}, err error) { + if len(m.Source) == 0 { + err = errors.New("docker: simple-secret source can not be empty") + return + } + result = m.Source + return +} + +func (m *SecretSimple) UnmarshalYAML(unmarshal func(interface{}) error) (err error) { + var origin string + if err = unmarshal(&origin); err != nil { + return + } + m.Source = origin + // 校验 + if len(m.Source) == 0 { + err = errors.New("docker: simple-secret format error") + return + } + return +} diff --git a/service.go b/service.go index 12714b7..2443830 100644 --- a/service.go +++ b/service.go @@ -41,9 +41,9 @@ type Service struct { // TODO network_mode Networks map[string]NetworkMap `yaml:"networks,omitempty"` // 加入的网络 // TODO pid - Ports []Port `yaml:"ports,omitempty"` // 暴露的端口号 - Restart string `yaml:"restart,omitempty"` // 重启策略 - // TODO secrets + Ports []Port `yaml:"ports,omitempty"` // 暴露的端口号 + Restart string `yaml:"restart,omitempty"` // 重启策略 + Secrets []Secret `yaml:"secrets,omitempty"` // 密钥 // TODO security_opt // TODO stop_grace_period // TODO stop_signal diff --git a/yml.go b/yml.go index 372912c..6b39aa2 100644 --- a/yml.go +++ b/yml.go @@ -12,12 +12,12 @@ package docker // 完整的配置文件 type Yml struct { - Version string `yaml:"version"` // 版本号 - Services map[string]Service `yaml:"services"` // 服务配置 - Volumes map[string]Volume `yaml:"volumes,omitempty"` // 挂载卷配置 - Networks map[string]Network `yaml:"networks,omitempty"` // 网络配置 + Version string `yaml:"version"` // 版本号 + Services map[string]Service `yaml:"services"` // 服务配置 + Volumes map[string]Volume `yaml:"volumes,omitempty"` // 挂载卷配置 + Networks map[string]Network `yaml:"networks,omitempty"` // 网络配置 + Secrets map[string]YmlSecret `yaml:"secrets,omitempty"` // 密钥 // TODO configs - // TODO secrets // TODO Variable substitution // TODO Extension fields } diff --git a/yml_secret.go b/yml_secret.go new file mode 100644 index 0000000..d7967e9 --- /dev/null +++ b/yml_secret.go @@ -0,0 +1,18 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +// 暴露的映射的公共接口 +type YmlSecret struct { + File string `yaml:"file,omitempty"` // 文件路径 + External string `yaml:"external,omitempty"` // 是否已存在,存在不需要再创建。 + Name string `yaml:"name,omitempty"` // (v3.5+) 名称 +} -- Gitee From a82f4ba09812dcbf8a10bc9182f0997b639f11ed Mon Sep 17 00:00:00 2001 From: lujian Date: Fri, 10 Apr 2020 13:04:29 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feature=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E5=8D=B7=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- volume_map.go | 13 ++----- volume_map_complex.go | 28 ++++++++++++++ volume_map_simple.go | 88 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 volume_map_complex.go create mode 100644 volume_map_simple.go diff --git a/volume_map.go b/volume_map.go index b329a7a..d0c4ec4 100644 --- a/volume_map.go +++ b/volume_map.go @@ -10,14 +10,7 @@ package docker -// 挂载卷 -type VolumeMap struct { - Type string `yaml:"type"` // 挂载类型 - Source string `yaml:"source"` // 外部的源地址 - Target string `yaml:"target"` // 容器内的目标地址 - ReadOnly string `yaml:"read_only,omitempty"` // 只读标志 - // TODO bind - // TODO volume - // TODO tmpfs - // TODO consistency +// 暴露的路径映射的公共接口 +type VolumeMap interface { + IsVolumeMap() bool } diff --git a/volume_map_complex.go b/volume_map_complex.go new file mode 100644 index 0000000..e8c25f6 --- /dev/null +++ b/volume_map_complex.go @@ -0,0 +1,28 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +// 挂载卷 +type VolumeMapComplex struct { + Type string `yaml:"type"` // 挂载类型 + Source string `yaml:"source"` // 外部的源地址 + Target string `yaml:"target"` // 容器内的目标地址 + ReadOnly string `yaml:"read_only,omitempty"` // 只读标志 + // TODO bind + // TODO volume + // TODO tmpfs + // TODO consistency +} + +// 实现公共接口 +func (VolumeMapComplex) IsVolumeMap() bool { + return true +} diff --git a/volume_map_simple.go b/volume_map_simple.go new file mode 100644 index 0000000..bd74923 --- /dev/null +++ b/volume_map_simple.go @@ -0,0 +1,88 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +import ( + "errors" + "fmt" + "strings" +) + +// 路径(Short Syntax) +type VolumeMapSimple struct { + Host string // 外部主机的路径 + Container string // 内部容器的路径 + Mode string // 权限 +} + +// 新建一个路径A到路径B的映射 +func NewVolumeMapSimple(hostVolumeMap string, containerVolumeMap string) VolumeMapSimple { + return VolumeMapSimple{ + Host: hostVolumeMap, + Container: containerVolumeMap, + } +} + +// 新建一个相同的路径映射 +func NewVolumeMapSimpleSame(volumeMap string) VolumeMapSimple { + return NewVolumeMapSimple(volumeMap, volumeMap) +} + +// 实现公共接口 +func (VolumeMapSimple) IsVolumeMap() bool { + return true +} + +func (m VolumeMapSimple) MarshalYAML() (result interface{}, err error) { + if len(m.Host) == 0 { + err = errors.New("docker: simple-volume-map host can not be empty") + return + } + tmp := m.Host + if len(m.Container) > 0 { + tmp += fmt.Sprintf(":%s", m.Container) + if len(m.Mode) > 0 { + tmp += fmt.Sprintf(":%s", m.Mode) + } + } + result = tmp + return +} + +func (m *VolumeMapSimple) UnmarshalYAML(unmarshal func(interface{}) error) (err error) { + var origin string + if err = unmarshal(&origin); err != nil { + return + } + // 拆分 + parts := strings.Split(origin, ":") + if len(parts) > 3 { + err = errors.New("docker: simple-volume-map format error") + return + } + m.Host = parts[0] + if len(parts) > 1 { + m.Container = parts[1] + } + if len(parts) > 2 { + m.Mode = parts[2] + } + // 校验 + if len(m.Host) == 0 { + err = errors.New("docker: simple-volume-map format error") + return + } + if len(m.Container) == 0 && len(m.Mode) > 0 { + err = errors.New("docker: simple-volume-map format error") + return + } + return +} -- Gitee From efb0aa650e1947ef98c50773a3f022e2470a5abb Mon Sep 17 00:00:00 2001 From: lujian Date: Fri, 10 Apr 2020 13:07:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feature:image=E6=B7=BB=E5=8A=A0NewImage?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- image.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/image.go b/image.go index fb3c03c..c66ec77 100644 --- a/image.go +++ b/image.go @@ -22,6 +22,14 @@ type Image struct { Tag string } +// 新建一个镜像 +func NewImage(name string, tag string) Image { + return Image{ + Name: name, + Tag: tag, + } +} + func (m Image) MarshalYAML() (result interface{}, err error) { if len(m.Name) == 0 { err = errors.New("docker: image name can not be empty") -- Gitee From 97a2b555e2b284da75947be5df357ffc1f6a0e11 Mon Sep 17 00:00:00 2001 From: lujian Date: Fri, 10 Apr 2020 15:15:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feature:=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- secret_simple.go | 3 +- secret_simple_test.go | 52 +++++++++++++++++++++++++++++ volume_map_simple.go | 5 +-- volume_map_simple_test.go | 70 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 secret_simple_test.go create mode 100644 volume_map_simple_test.go diff --git a/secret_simple.go b/secret_simple.go index b003342..caad950 100644 --- a/secret_simple.go +++ b/secret_simple.go @@ -12,6 +12,7 @@ package docker import ( "errors" + "fmt" ) // 密钥(Short Syntax) @@ -36,7 +37,7 @@ func (m SecretSimple) MarshalYAML() (result interface{}, err error) { err = errors.New("docker: simple-secret source can not be empty") return } - result = m.Source + result = fmt.Sprintf("%s", m.Source) return } diff --git a/secret_simple_test.go b/secret_simple_test.go new file mode 100644 index 0000000..b1dcfb1 --- /dev/null +++ b/secret_simple_test.go @@ -0,0 +1,52 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +import ( + "fmt" + "testing" +) + +func TestSecretSimple(t *testing.T) { + tests := []struct { + item string + wantSource string + wantErr bool + }{ + {item: "my_secret", wantSource: "my_secret", wantErr: false}, + } + for i, tt := range tests { + t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + // MarshalYaml + if !tt.wantErr { + item := SecretSimple{Source: tt.wantSource} + result, _ := item.MarshalYAML() + content := fmt.Sprintf("%s", result) + if content != tt.item { + t.Logf("%d %d", len(content), len(tt.item)) + t.Errorf("SecretSimple.MarshalYAML() content = %v, wantContent %v", content, tt.item) + return + } + } + // UnmarshalYaml + var item SecretSimple + err := UnmarshalYaml(tt.item, &item) + if (err != nil) != tt.wantErr { + t.Errorf("SecretSimple.UnarshalYAML() error = %v, wantErr %v", err, tt.wantErr) + return + } + if item.Source != tt.wantSource { + t.Errorf("SecretSimple.UnarshalYAML() source = %v, wantSouce %v", item.Source, tt.wantSource) + return + } + }) + } +} diff --git a/volume_map_simple.go b/volume_map_simple.go index bd74923..001aad4 100644 --- a/volume_map_simple.go +++ b/volume_map_simple.go @@ -24,16 +24,17 @@ type VolumeMapSimple struct { } // 新建一个路径A到路径B的映射 -func NewVolumeMapSimple(hostVolumeMap string, containerVolumeMap string) VolumeMapSimple { +func NewVolumeMapSimple(hostVolumeMap string, containerVolumeMap string, mode string) VolumeMapSimple { return VolumeMapSimple{ Host: hostVolumeMap, Container: containerVolumeMap, + Mode: mode, } } // 新建一个相同的路径映射 func NewVolumeMapSimpleSame(volumeMap string) VolumeMapSimple { - return NewVolumeMapSimple(volumeMap, volumeMap) + return NewVolumeMapSimple(volumeMap, volumeMap, VolumeReadOnly) } // 实现公共接口 diff --git a/volume_map_simple_test.go b/volume_map_simple_test.go new file mode 100644 index 0000000..a929613 --- /dev/null +++ b/volume_map_simple_test.go @@ -0,0 +1,70 @@ +/* + Copyright (c) 2020 XiaochengTech + gitee.com/xiaochengtech/docker is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. +*/ + +package docker + +import ( + "fmt" + "strings" + "testing" +) + +func TestVolumeMapSimple(t *testing.T) { + tests := []struct { + item string + wantHost string + wantContainer string + wantMode string + wantErr bool + }{ + {item: "/var/lib/mysql", wantHost: "/var/lib/mysql", wantErr: false}, + {item: "/opt/data:/var/lib/mysql", wantHost: "/opt/data", wantContainer: "/var/lib/mysql", wantErr: false}, + {item: "./cache:/tmp/cache", wantHost: "./cache", wantContainer: "/tmp/cache", wantErr: false}, + {item: "~/configs:/udp", wantHost: "~/configs", wantContainer: "/udp", wantErr: false}, + {item: "~/configs:/etc/configs/:ro", wantHost: "~/configs", wantContainer: "/etc/configs/", wantMode: "ro", wantErr: false}, + {item: "datavolume:/var/lib/mysql", wantHost: "datavolume", wantContainer: "/var/lib/mysql", wantErr: false}, + {item: "dtavolume::ro", wantHost: "datavolume", wantContainer: "", wantMode: "ro", wantErr: true}, + {item: ":/var/lib/mysql", wantHost: "", wantContainer: "/var/lib/mysql", wantMode: "", wantErr: true}, + } + for i, tt := range tests { + t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + // MarshalYaml + if !tt.wantErr { + item := VolumeMapSimple{Host: tt.wantHost, Container: tt.wantContainer, Mode: tt.wantMode} + content := MarshalYaml(item) + content = strings.TrimRight(content, "\n") + if content != tt.item { + t.Logf("%d %d", len(content), len(tt.item)) + t.Errorf("VolumeMapSimple.MarshalYAML() content = %v, wantContent %v", content, tt.item) + return + } + } + // UnmarshalYaml + var item VolumeMapSimple + err := UnmarshalYaml(tt.item, &item) + if (err != nil) != tt.wantErr { + t.Errorf("VolumeMapSimple.UnarshalYAML() error = %v, wantErr %v", err, tt.wantErr) + return + } + if item.Host != tt.wantHost { + t.Errorf("VolumeMapSimple.UnarshalYAML() host = %v, wantHost %v", item.Host, tt.wantHost) + return + } + if item.Container != tt.wantContainer { + t.Errorf("Image.UnarshalYAML() container = %v, wantContainer %v", item.Container, tt.wantContainer) + return + } + if item.Mode != tt.wantMode { + t.Errorf("VolumeMapSimple.UnarshalYAML() mode = %v, wantMode %v", item.Mode, tt.wantMode) + return + } + }) + } +} -- Gitee From c6c737c0992e48838d49f4a30efa5939026af9db Mon Sep 17 00:00:00 2001 From: lujian Date: Fri, 10 Apr 2020 15:23:56 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=E8=BF=98=E5=8E=9FNewVolumeMapSimple?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- secret_simple.go | 3 +-- volume_map_simple.go | 7 ++++--- volume_map_simple_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/secret_simple.go b/secret_simple.go index caad950..b003342 100644 --- a/secret_simple.go +++ b/secret_simple.go @@ -12,7 +12,6 @@ package docker import ( "errors" - "fmt" ) // 密钥(Short Syntax) @@ -37,7 +36,7 @@ func (m SecretSimple) MarshalYAML() (result interface{}, err error) { err = errors.New("docker: simple-secret source can not be empty") return } - result = fmt.Sprintf("%s", m.Source) + result = m.Source return } diff --git a/volume_map_simple.go b/volume_map_simple.go index 001aad4..b196ae3 100644 --- a/volume_map_simple.go +++ b/volume_map_simple.go @@ -24,17 +24,18 @@ type VolumeMapSimple struct { } // 新建一个路径A到路径B的映射 -func NewVolumeMapSimple(hostVolumeMap string, containerVolumeMap string, mode string) VolumeMapSimple { +func NewVolumeMapSimple(hostVolumeMap string, containerVolumeMap string) VolumeMapSimple { return VolumeMapSimple{ Host: hostVolumeMap, Container: containerVolumeMap, - Mode: mode, } } // 新建一个相同的路径映射 func NewVolumeMapSimpleSame(volumeMap string) VolumeMapSimple { - return NewVolumeMapSimple(volumeMap, volumeMap, VolumeReadOnly) + volumeMapSimple := NewVolumeMapSimple(volumeMap, volumeMap) + volumeMapSimple.Mode = VolumeReadOnly + return volumeMapSimple } // 实现公共接口 diff --git a/volume_map_simple_test.go b/volume_map_simple_test.go index a929613..538e12b 100644 --- a/volume_map_simple_test.go +++ b/volume_map_simple_test.go @@ -30,7 +30,7 @@ func TestVolumeMapSimple(t *testing.T) { {item: "~/configs:/udp", wantHost: "~/configs", wantContainer: "/udp", wantErr: false}, {item: "~/configs:/etc/configs/:ro", wantHost: "~/configs", wantContainer: "/etc/configs/", wantMode: "ro", wantErr: false}, {item: "datavolume:/var/lib/mysql", wantHost: "datavolume", wantContainer: "/var/lib/mysql", wantErr: false}, - {item: "dtavolume::ro", wantHost: "datavolume", wantContainer: "", wantMode: "ro", wantErr: true}, + {item: "datavolume::ro", wantHost: "datavolume", wantContainer: "", wantMode: "ro", wantErr: true}, {item: ":/var/lib/mysql", wantHost: "", wantContainer: "/var/lib/mysql", wantMode: "", wantErr: true}, } for i, tt := range tests { -- Gitee