Skip to content

Commit e427a64

Browse files
committed
delete the useless 'error'
1 parent da06fd0 commit e427a64

File tree

4 files changed

+5
-21
lines changed

4 files changed

+5
-21
lines changed

apis/opts/labels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import (
55
)
66

77
// ParseLabels parses the labels params of container.
8-
func ParseLabels(labels []string) (map[string]string, error) {
8+
func ParseLabels(labels []string) map[string]string {
99
results := make(map[string]string)
1010
for _, label := range labels {
1111
fields := parseLabel(label)
1212
k, v := fields[0], fields[1]
1313
results[k] = v
1414
}
15-
return results, nil
15+
return results
1616
}
1717

1818
func parseLabel(label string) []string {

apis/opts/labels_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
func TestParseLabels(t *testing.T) {
1010
type result struct {
1111
labels map[string]string
12-
err error
1312
}
1413

1514
type TestCase struct {
@@ -24,7 +23,6 @@ func TestParseLabels(t *testing.T) {
2423
labels: map[string]string{
2524
"a": "b",
2625
},
27-
err: nil,
2826
},
2927
},
3028
{
@@ -33,7 +31,6 @@ func TestParseLabels(t *testing.T) {
3331
labels: map[string]string{
3432
"a": "b",
3533
},
36-
err: nil,
3734
},
3835
},
3936
{
@@ -43,7 +40,6 @@ func TestParseLabels(t *testing.T) {
4340
labels: map[string]string{
4441
"a": "bb",
4542
},
46-
err: nil,
4743
},
4844
},
4945
// only input key
@@ -53,7 +49,6 @@ func TestParseLabels(t *testing.T) {
5349
labels: map[string]string{
5450
"a": "",
5551
},
56-
err: nil,
5752
},
5853
},
5954
{
@@ -62,7 +57,6 @@ func TestParseLabels(t *testing.T) {
6257
labels: map[string]string{
6358
"a": "",
6459
},
65-
err: nil,
6660
},
6761
},
6862
{
@@ -71,28 +65,24 @@ func TestParseLabels(t *testing.T) {
7165
labels: map[string]string{
7266
"a": "b=c",
7367
},
74-
err: nil,
7568
},
7669
},
7770
{
7871
input: []string{},
7972
expected: result{
8073
labels: map[string]string{},
81-
err: nil,
8274
},
8375
},
8476
{
8577
input: nil,
8678
expected: result{
8779
labels: map[string]string{},
88-
err: nil,
8980
},
9081
},
9182
}
9283

9384
for _, testCase := range testCases {
94-
labels, err := ParseLabels(testCase.input)
85+
labels := ParseLabels(testCase.input)
9586
assert.Equal(t, testCase.expected.labels, labels)
96-
assert.Equal(t, testCase.expected.err, err)
9787
}
9888
}

cli/container.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ type container struct {
9797
}
9898

9999
func (c *container) config() (*types.ContainerCreateConfig, error) {
100-
labels, err := opts.ParseLabels(c.labels)
101-
if err != nil {
102-
return nil, err
103-
}
100+
labels := opts.ParseLabels(c.labels)
104101

105102
memory, err := opts.ParseMemory(c.memory)
106103
if err != nil {

daemon/mgr/container.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,10 +1149,7 @@ func (mgr *ContainerManager) Update(ctx context.Context, name string, config *ty
11491149
// but ContainerConfig.Labels is map[string]string
11501150
if len(config.Label) != 0 {
11511151
// support remove some labels
1152-
newLabels, err := opts.ParseLabels(config.Label)
1153-
if err != nil {
1154-
return errors.Wrapf(err, "failed to parse labels")
1155-
}
1152+
newLabels := opts.ParseLabels(config.Label)
11561153

11571154
for k, v := range newLabels {
11581155
if v == "" {

0 commit comments

Comments
 (0)