Browse code

Merge pull request #25144 from dnephin/remove-extraneous-aliases.bump

[bump_v1.12.0] Remove extraneous mount aliases

Tibor Vass authored on 2016/07/28 06:13:49
Showing 2 changed files
... ...
@@ -178,12 +178,11 @@ func (m *MountOpt) Set(value string) error {
178 178
 		key := strings.ToLower(parts[0])
179 179
 
180 180
 		if len(parts) == 1 {
181
-			if key == "readonly" || key == "ro" {
181
+			switch key {
182
+			case "readonly", "ro":
182 183
 				mount.ReadOnly = true
183 184
 				continue
184
-			}
185
-
186
-			if key == "volume-nocopy" {
185
+			case "volume-nocopy":
187 186
 				volumeOptions().NoCopy = true
188 187
 				continue
189 188
 			}
... ...
@@ -197,16 +196,15 @@ func (m *MountOpt) Set(value string) error {
197 197
 		switch key {
198 198
 		case "type":
199 199
 			mount.Type = swarm.MountType(strings.ToLower(value))
200
-		case "source", "name", "src":
200
+		case "source", "src":
201 201
 			mount.Source = value
202
-		case "target", "dst", "dest", "destination", "path":
202
+		case "target", "dst", "destination":
203 203
 			mount.Target = value
204 204
 		case "readonly", "ro":
205
-			ro, err := strconv.ParseBool(value)
205
+			mount.ReadOnly, err = strconv.ParseBool(value)
206 206
 			if err != nil {
207
-				return fmt.Errorf("invalid value for readonly: %s", value)
207
+				return fmt.Errorf("invalid value for %s: %s", key, value)
208 208
 			}
209
-			mount.ReadOnly = ro
210 209
 		case "bind-propagation":
211 210
 			bindOptions().Propagation = swarm.MountPropagation(strings.ToLower(value))
212 211
 		case "volume-nocopy":
... ...
@@ -81,8 +81,8 @@ func TestMountOptSetNoError(t *testing.T) {
81 81
 		// tests several aliases that should have same result.
82 82
 		"type=bind,target=/target,source=/source",
83 83
 		"type=bind,src=/source,dst=/target",
84
-		"type=bind,name=/source,dst=/target",
85
-		"type=bind,name=/source,path=/target",
84
+		"type=bind,source=/source,dst=/target",
85
+		"type=bind,src=/source,target=/target",
86 86
 	} {
87 87
 		var mount MountOpt
88 88