Skip to content

Commit 60ae1bb

Browse files
authored
Merge pull request #5910 from thaJeztah/move_service_logs
service/logs: move to cli/internal/logdetails
2 parents 879acd1 + 6bd6b3e commit 60ae1bb

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

cli/command/service/logs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/docker/cli/cli/command"
1414
"github.com/docker/cli/cli/command/completion"
1515
"github.com/docker/cli/cli/command/idresolver"
16-
"github.com/docker/cli/service/logs"
16+
"github.com/docker/cli/cli/internal/logdetails"
1717
"github.com/docker/docker/api/types"
1818
"github.com/docker/docker/api/types/container"
1919
"github.com/docker/docker/api/types/swarm"
@@ -267,7 +267,7 @@ func (lw *logWriter) Write(buf []byte) (int, error) {
267267
return 0, errors.Errorf("invalid context in log message: %v", string(buf))
268268
}
269269
// parse the details out
270-
details, err := logs.ParseLogDetails(string(parts[detailsIndex]))
270+
details, err := logdetails.Parse(string(parts[detailsIndex]))
271271
if err != nil {
272272
return 0, err
273273
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
/*Package logs contains tools for parsing docker log lines.
2-
*/
3-
package logs
1+
// Package logdetails contains tools for parsing docker log lines.
2+
package logdetails
43

54
import (
5+
"errors"
66
"net/url"
77
"strings"
8-
9-
"github.com/pkg/errors"
108
)
119

12-
// ParseLogDetails parses a string of key value pairs in the form
10+
// Parse parses a string of key value pairs in the form
1311
// "k=v,l=w", where the keys and values are url query escaped, and each pair
1412
// is separated by a comma. Returns a map of the key value pairs on success,
1513
// and an error if the details string is not in a valid format.
1614
//
1715
// The details string encoding is implemented in
1816
// github.com/moby/moby/api/server/httputils/write_log_stream.go
19-
func ParseLogDetails(details string) (map[string]string, error) {
17+
func Parse(details string) (map[string]string, error) {
2018
pairs := strings.Split(details, ",")
2119
detailsMap := make(map[string]string, len(pairs))
2220
for _, pair := range pairs {

service/logs/parse_logs_test.go renamed to cli/internal/logdetails/parse_logs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package logs
1+
package logdetails
22

33
import (
44
"testing"
@@ -7,7 +7,7 @@ import (
77
is "gotest.tools/v3/assert/cmp"
88
)
99

10-
func TestParseLogDetails(t *testing.T) {
10+
func TestParse(t *testing.T) {
1111
testCases := []struct {
1212
line string
1313
expected map[string]string
@@ -48,9 +48,9 @@ func TestParseLogDetails(t *testing.T) {
4848
}
4949
for _, tc := range testCases {
5050
t.Run(tc.line, func(t *testing.T) {
51-
actual, err := ParseLogDetails(tc.line)
51+
actual, err := Parse(tc.line)
5252
if tc.expectedErr != "" {
53-
assert.Check(t, is.ErrorContains(err, tc.expectedErr))
53+
assert.Check(t, is.Error(err, tc.expectedErr))
5454
} else {
5555
assert.Check(t, err)
5656
}

0 commit comments

Comments
 (0)