Browse code

fixed:go vetting warning unkeyed fields

Signed-off-by: Aaron.L.Xu <liker.xu@foxmail.com>

liker12134 authored on 2017/03/20 17:27:51
Showing 9 changed files
... ...
@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 func TestCalculateBlockIO(t *testing.T) {
10 10
 	blkio := types.BlkioStats{
11
-		IoServiceBytesRecursive: []types.BlkioStatEntry{{8, 0, "read", 1234}, {8, 1, "read", 4567}, {8, 0, "write", 123}, {8, 1, "write", 456}},
11
+		IoServiceBytesRecursive: []types.BlkioStatEntry{{Major: 8, Minor: 0, Op: "read", Value: 1234}, {Major: 8, Minor: 1, Op: "read", Value: 4567}, {Major: 8, Minor: 0, Op: "write", Value: 123}, {Major: 8, Minor: 1, Op: "write", Value: 456}},
12 12
 	}
13 13
 	blkRead, blkWrite := calculateBlockIO(blkio)
14 14
 	if blkRead != 5801 {
... ...
@@ -24,10 +24,10 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsCreate(c *check.C) {
24 24
 
25 25
 	testName := "test_secret"
26 26
 	id := d.CreateSecret(c, swarm.SecretSpec{
27
-		swarm.Annotations{
27
+		Annotations: swarm.Annotations{
28 28
 			Name: testName,
29 29
 		},
30
-		[]byte("TESTINGDATA"),
30
+		Data: []byte("TESTINGDATA"),
31 31
 	})
32 32
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
33 33
 
... ...
@@ -41,11 +41,10 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsDelete(c *check.C) {
41 41
 	d := s.AddDaemon(c, true, true)
42 42
 
43 43
 	testName := "test_secret"
44
-	id := d.CreateSecret(c, swarm.SecretSpec{
45
-		swarm.Annotations{
46
-			Name: testName,
47
-		},
48
-		[]byte("TESTINGDATA"),
44
+	id := d.CreateSecret(c, swarm.SecretSpec{Annotations: swarm.Annotations{
45
+		Name: testName,
46
+	},
47
+		Data: []byte("TESTINGDATA"),
49 48
 	})
50 49
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
51 50
 
... ...
@@ -63,13 +62,13 @@ func (s *DockerSwarmSuite) TestAPISwarmSecretsUpdate(c *check.C) {
63 63
 
64 64
 	testName := "test_secret"
65 65
 	id := d.CreateSecret(c, swarm.SecretSpec{
66
-		swarm.Annotations{
66
+		Annotations: swarm.Annotations{
67 67
 			Name: testName,
68 68
 			Labels: map[string]string{
69 69
 				"test": "test1",
70 70
 			},
71 71
 		},
72
-		[]byte("TESTINGDATA"),
72
+		Data: []byte("TESTINGDATA"),
73 73
 	})
74 74
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
75 75
 
... ...
@@ -17,10 +17,10 @@ func (s *DockerSwarmSuite) TestSecretCreate(c *check.C) {
17 17
 
18 18
 	testName := "test_secret"
19 19
 	id := d.CreateSecret(c, swarm.SecretSpec{
20
-		swarm.Annotations{
20
+		Annotations: swarm.Annotations{
21 21
 			Name: testName,
22 22
 		},
23
-		[]byte("TESTINGDATA"),
23
+		Data: []byte("TESTINGDATA"),
24 24
 	})
25 25
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
26 26
 
... ...
@@ -33,14 +33,14 @@ func (s *DockerSwarmSuite) TestSecretCreateWithLabels(c *check.C) {
33 33
 
34 34
 	testName := "test_secret"
35 35
 	id := d.CreateSecret(c, swarm.SecretSpec{
36
-		swarm.Annotations{
36
+		Annotations: swarm.Annotations{
37 37
 			Name: testName,
38 38
 			Labels: map[string]string{
39 39
 				"key1": "value1",
40 40
 				"key2": "value2",
41 41
 			},
42 42
 		},
43
-		[]byte("TESTINGDATA"),
43
+		Data: []byte("TESTINGDATA"),
44 44
 	})
45 45
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
46 46
 
... ...
@@ -57,18 +57,18 @@ func (s *DockerSwarmSuite) TestSecretCreateResolve(c *check.C) {
57 57
 
58 58
 	name := "test_secret"
59 59
 	id := d.CreateSecret(c, swarm.SecretSpec{
60
-		swarm.Annotations{
60
+		Annotations: swarm.Annotations{
61 61
 			Name: name,
62 62
 		},
63
-		[]byte("foo"),
63
+		Data: []byte("foo"),
64 64
 	})
65 65
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
66 66
 
67 67
 	fake := d.CreateSecret(c, swarm.SecretSpec{
68
-		swarm.Annotations{
68
+		Annotations: swarm.Annotations{
69 69
 			Name: id,
70 70
 		},
71
-		[]byte("fake foo"),
71
+		Data: []byte("fake foo"),
72 72
 	})
73 73
 	c.Assert(fake, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", fake))
74 74
 
... ...
@@ -15,10 +15,10 @@ func (s *DockerSwarmSuite) TestSecretInspect(c *check.C) {
15 15
 
16 16
 	testName := "test_secret"
17 17
 	id := d.CreateSecret(c, swarm.SecretSpec{
18
-		swarm.Annotations{
18
+		Annotations: swarm.Annotations{
19 19
 			Name: testName,
20 20
 		},
21
-		[]byte("TESTINGDATA"),
21
+		Data: []byte("TESTINGDATA"),
22 22
 	})
23 23
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
24 24
 
... ...
@@ -42,10 +42,10 @@ func (s *DockerSwarmSuite) TestSecretInspectMultiple(c *check.C) {
42 42
 	}
43 43
 	for _, n := range testNames {
44 44
 		id := d.CreateSecret(c, swarm.SecretSpec{
45
-			swarm.Annotations{
45
+			Annotations: swarm.Annotations{
46 46
 				Name: n,
47 47
 			},
48
-			[]byte("TESTINGDATA"),
48
+			Data: []byte("TESTINGDATA"),
49 49
 		})
50 50
 		c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
51 51
 
... ...
@@ -68,10 +68,10 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSimple(c *check.C) {
68 68
 	serviceName := "test-service-secret"
69 69
 	testName := "test_secret"
70 70
 	id := d.CreateSecret(c, swarm.SecretSpec{
71
-		swarm.Annotations{
71
+		Annotations: swarm.Annotations{
72 72
 			Name: testName,
73 73
 		},
74
-		[]byte("TESTINGDATA"),
74
+		Data: []byte("TESTINGDATA"),
75 75
 	})
76 76
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
77 77
 
... ...
@@ -98,10 +98,10 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTarget(c *check.C) {
98 98
 	serviceName := "test-service-secret"
99 99
 	testName := "test_secret"
100 100
 	id := d.CreateSecret(c, swarm.SecretSpec{
101
-		swarm.Annotations{
101
+		Annotations: swarm.Annotations{
102 102
 			Name: testName,
103 103
 		},
104
-		[]byte("TESTINGDATA"),
104
+		Data: []byte("TESTINGDATA"),
105 105
 	})
106 106
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
107 107
 	testTarget := "testing"
... ...
@@ -91,10 +91,10 @@ func (s *DockerSwarmSuite) TestServiceUpdateSecrets(c *check.C) {
91 91
 	d := s.AddDaemon(c, true, true)
92 92
 	testName := "test_secret"
93 93
 	id := d.CreateSecret(c, swarm.SecretSpec{
94
-		swarm.Annotations{
94
+		Annotations: swarm.Annotations{
95 95
 			Name: testName,
96 96
 		},
97
-		[]byte("TESTINGDATA"),
97
+		Data: []byte("TESTINGDATA"),
98 98
 	})
99 99
 	c.Assert(id, checker.Not(checker.Equals), "", check.Commentf("secrets: %s", id))
100 100
 	testTarget := "testing"
... ...
@@ -14,33 +14,33 @@ func TestValidatePrivileges(t *testing.T) {
14 14
 	}{
15 15
 		"diff-len": {
16 16
 			requiredPrivileges: []types.PluginPrivilege{
17
-				{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
17
+				{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
18 18
 			},
19 19
 			privileges: []types.PluginPrivilege{
20
-				{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
21
-				{"Privilege2", "Description", []string{"123", "456", "789"}},
20
+				{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
21
+				{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
22 22
 			},
23 23
 			result: false,
24 24
 		},
25 25
 		"diff-value": {
26 26
 			requiredPrivileges: []types.PluginPrivilege{
27
-				{"Privilege1", "Description", []string{"abc", "def", "GHI"}},
28
-				{"Privilege2", "Description", []string{"123", "456", "***"}},
27
+				{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "GHI"}},
28
+				{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "***"}},
29 29
 			},
30 30
 			privileges: []types.PluginPrivilege{
31
-				{"Privilege1", "Description", []string{"abc", "def", "ghi"}},
32
-				{"Privilege2", "Description", []string{"123", "456", "789"}},
31
+				{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "ghi"}},
32
+				{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
33 33
 			},
34 34
 			result: false,
35 35
 		},
36 36
 		"diff-order-but-same-value": {
37 37
 			requiredPrivileges: []types.PluginPrivilege{
38
-				{"Privilege1", "Description", []string{"abc", "def", "GHI"}},
39
-				{"Privilege2", "Description", []string{"123", "456", "789"}},
38
+				{Name: "Privilege1", Description: "Description", Value: []string{"abc", "def", "GHI"}},
39
+				{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
40 40
 			},
41 41
 			privileges: []types.PluginPrivilege{
42
-				{"Privilege2", "Description", []string{"123", "456", "789"}},
43
-				{"Privilege1", "Description", []string{"GHI", "abc", "def"}},
42
+				{Name: "Privilege2", Description: "Description", Value: []string{"123", "456", "789"}},
43
+				{Name: "Privilege1", Description: "Description", Value: []string{"GHI", "abc", "def"}},
44 44
 			},
45 45
 			result: true,
46 46
 		},
... ...
@@ -9,8 +9,8 @@ import (
9 9
 
10 10
 func TestFilterByCapNeg(t *testing.T) {
11 11
 	p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
12
-	iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
13
-	i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
12
+	iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
13
+	i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
14 14
 	p.PluginObj.Config.Interface = i
15 15
 
16 16
 	_, err := p.FilterByCap("foobar")
... ...
@@ -22,8 +22,8 @@ func TestFilterByCapNeg(t *testing.T) {
22 22
 func TestFilterByCapPos(t *testing.T) {
23 23
 	p := v2.Plugin{PluginObj: types.Plugin{Name: "test:latest"}}
24 24
 
25
-	iType := types.PluginInterfaceType{"volumedriver", "docker", "1.0"}
26
-	i := types.PluginConfigInterface{"plugins.sock", []types.PluginInterfaceType{iType}}
25
+	iType := types.PluginInterfaceType{Capability: "volumedriver", Prefix: "docker", Version: "1.0"}
26
+	i := types.PluginConfigInterface{Socket: "plugins.sock", Types: []types.PluginInterfaceType{iType}}
27 27
 	p.PluginObj.Config.Interface = i
28 28
 
29 29
 	_, err := p.FilterByCap("volumedriver")
... ...
@@ -167,11 +167,11 @@ func TestPidModeTest(t *testing.T) {
167 167
 func TestRestartPolicy(t *testing.T) {
168 168
 	restartPolicies := map[container.RestartPolicy][]bool{
169 169
 		// none, always, failure
170
-		container.RestartPolicy{}:                {true, false, false},
171
-		container.RestartPolicy{"something", 0}:  {false, false, false},
172
-		container.RestartPolicy{"no", 0}:         {true, false, false},
173
-		container.RestartPolicy{"always", 0}:     {false, true, false},
174
-		container.RestartPolicy{"on-failure", 0}: {false, false, true},
170
+		container.RestartPolicy{}:                                         {true, false, false},
171
+		container.RestartPolicy{Name: "something", MaximumRetryCount: 0}:  {false, false, false},
172
+		container.RestartPolicy{Name: "no", MaximumRetryCount: 0}:         {true, false, false},
173
+		container.RestartPolicy{Name: "always", MaximumRetryCount: 0}:     {false, true, false},
174
+		container.RestartPolicy{Name: "on-failure", MaximumRetryCount: 0}: {false, false, true},
175 175
 	}
176 176
 	for restartPolicy, state := range restartPolicies {
177 177
 		if restartPolicy.IsNone() != state[0] {