Browse code

Change mount-types to lowercase

these values were changed to lowercase in
https://github.com/docker/engine-api/commit/690cb2d08cfcca31cd02e68b23915b75386beecd,
but not changed accordingly in docker/docker.

this changes the mounttypes to lowercase

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 8f93128cd619e1d11be1bc0ae21f1362b1e3f9ad)
Signed-off-by: Tibor Vass <tibor@docker.com>

Sebastiaan van Stijn authored on 2016/07/21 08:04:51
Showing 5 changed files
... ...
@@ -196,7 +196,7 @@ func (m *MountOpt) Set(value string) error {
196 196
 		key, value := parts[0], parts[1]
197 197
 		switch strings.ToLower(key) {
198 198
 		case "type":
199
-			mount.Type = swarm.MountType(strings.ToUpper(value))
199
+			mount.Type = swarm.MountType(strings.ToLower(value))
200 200
 		case "source":
201 201
 			mount.Source = value
202 202
 		case "target":
... ...
@@ -208,7 +208,7 @@ func (m *MountOpt) Set(value string) error {
208 208
 			}
209 209
 			mount.ReadOnly = ro
210 210
 		case "bind-propagation":
211
-			bindOptions().Propagation = swarm.MountPropagation(strings.ToUpper(value))
211
+			bindOptions().Propagation = swarm.MountPropagation(strings.ToLower(value))
212 212
 		case "volume-nocopy":
213 213
 			volumeOptions().NoCopy, err = strconv.ParseBool(value)
214 214
 			if err != nil {
... ...
@@ -240,10 +240,10 @@ func (m *MountOpt) Set(value string) error {
240 240
 		return fmt.Errorf("source is required when specifying volume-* options")
241 241
 	}
242 242
 
243
-	if mount.Type == swarm.MountType("BIND") && mount.VolumeOptions != nil {
243
+	if mount.Type == swarm.MountTypeBind && mount.VolumeOptions != nil {
244 244
 		return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", swarm.MountTypeBind)
245 245
 	}
246
-	if mount.Type == swarm.MountType("VOLUME") && mount.BindOptions != nil {
246
+	if mount.Type == swarm.MountTypeVolume && mount.BindOptions != nil {
247 247
 		return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", swarm.MountTypeVolume)
248 248
 	}
249 249
 
... ...
@@ -61,18 +61,18 @@ func TestMountOptString(t *testing.T) {
61 61
 	mount := MountOpt{
62 62
 		values: []swarm.Mount{
63 63
 			{
64
-				Type:   swarm.MountType("BIND"),
64
+				Type:   swarm.MountTypeBind,
65 65
 				Source: "/home/path",
66 66
 				Target: "/target",
67 67
 			},
68 68
 			{
69
-				Type:   swarm.MountType("VOLUME"),
69
+				Type:   swarm.MountTypeVolume,
70 70
 				Source: "foo",
71 71
 				Target: "/target/foo",
72 72
 			},
73 73
 		},
74 74
 	}
75
-	expected := "BIND /home/path /target, VOLUME foo /target/foo"
75
+	expected := "bind /home/path /target, volume foo /target/foo"
76 76
 	assert.Equal(t, mount.String(), expected)
77 77
 }
78 78
 
... ...
@@ -83,7 +83,7 @@ func TestMountOptSetNoError(t *testing.T) {
83 83
 	mounts := mount.Value()
84 84
 	assert.Equal(t, len(mounts), 1)
85 85
 	assert.Equal(t, mounts[0], swarm.Mount{
86
-		Type:   swarm.MountType("BIND"),
86
+		Type:   swarm.MountTypeBind,
87 87
 		Source: "/foo",
88 88
 		Target: "/target",
89 89
 	})
... ...
@@ -96,22 +96,22 @@ func TestMountOptSetErrorNoType(t *testing.T) {
96 96
 
97 97
 func TestMountOptSetErrorNoTarget(t *testing.T) {
98 98
 	var mount MountOpt
99
-	assert.Error(t, mount.Set("type=VOLUME,source=/foo"), "target is required")
99
+	assert.Error(t, mount.Set("type=volume,source=/foo"), "target is required")
100 100
 }
101 101
 
102 102
 func TestMountOptSetErrorInvalidKey(t *testing.T) {
103 103
 	var mount MountOpt
104
-	assert.Error(t, mount.Set("type=VOLUME,bogus=foo"), "unexpected key 'bogus'")
104
+	assert.Error(t, mount.Set("type=volume,bogus=foo"), "unexpected key 'bogus'")
105 105
 }
106 106
 
107 107
 func TestMountOptSetErrorInvalidField(t *testing.T) {
108 108
 	var mount MountOpt
109
-	assert.Error(t, mount.Set("type=VOLUME,bogus"), "invalid field 'bogus'")
109
+	assert.Error(t, mount.Set("type=volume,bogus"), "invalid field 'bogus'")
110 110
 }
111 111
 
112 112
 func TestMountOptSetErrorInvalidWritable(t *testing.T) {
113 113
 	var mount MountOpt
114
-	assert.Error(t, mount.Set("type=VOLUME,readonly=no"), "invalid value for readonly: no")
114
+	assert.Error(t, mount.Set("type=volume,readonly=no"), "invalid value for readonly: no")
115 115
 }
116 116
 
117 117
 func TestMountOptDefaultEnableWritable(t *testing.T) {
... ...
@@ -90,8 +90,8 @@ func TestUpdateMounts(t *testing.T) {
90 90
 	flags.Set("mount-rm", "/toremove")
91 91
 
92 92
 	mounts := []swarm.Mount{
93
-		{Target: "/toremove", Type: swarm.MountType("BIND")},
94
-		{Target: "/tokeep", Type: swarm.MountType("BIND")},
93
+		{Target: "/toremove", Type: swarm.MountTypeBind},
94
+		{Target: "/tokeep", Type: swarm.MountTypeBind},
95 95
 	}
96 96
 
97 97
 	updateMounts(flags, &mounts)
... ...
@@ -122,7 +122,7 @@ func TestUpdatePorts(t *testing.T) {
122 122
 	flags.Set("publish-rm", "333/udp")
123 123
 
124 124
 	portConfigs := []swarm.PortConfig{
125
-		{TargetPort: 333, Protocol: swarm.PortConfigProtocol("udp")},
125
+		{TargetPort: 333, Protocol: swarm.PortConfigProtocolUDP},
126 126
 		{TargetPort: 555},
127 127
 	}
128 128
 
... ...
@@ -3936,7 +3936,7 @@ Create a service
3936 3936
               "ReadOnly": true,
3937 3937
               "Source": "web-data",
3938 3938
               "Target": "/usr/share/nginx/html",
3939
-              "Type": "VOLUME",
3939
+              "Type": "volume",
3940 3940
               "VolumeOptions": {
3941 3941
                 "DriverConfig": {
3942 3942
                 },
... ...
@@ -143,12 +143,12 @@ func (m *MountPoint) Path() string {
143 143
 // Type returns the type of mount point
144 144
 func (m *MountPoint) Type() string {
145 145
 	if m.Name != "" {
146
-		return "VOLUME"
146
+		return "volume"
147 147
 	}
148 148
 	if m.Source != "" {
149
-		return "BIND"
149
+		return "bind"
150 150
 	}
151
-	return "EPHEMERAL"
151
+	return "ephemeral"
152 152
 }
153 153
 
154 154
 // ParseVolumesFrom ensures that the supplied volumes-from is valid.