Skip to content

Commit 6bd6b3e

Browse files
committed
service/logs: move to cli/internal/logdetails
This package is only used by cli/command/service, and has no external consumers. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 1bd58b0 commit 6bd6b3e

3 files changed

Lines changed: 9 additions & 10 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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +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 (
65
"errors"
76
"net/url"
87
"strings"
98
)
109

11-
// ParseLogDetails parses a string of key value pairs in the form
10+
// Parse parses a string of key value pairs in the form
1211
// "k=v,l=w", where the keys and values are url query escaped, and each pair
1312
// is separated by a comma. Returns a map of the key value pairs on success,
1413
// and an error if the details string is not in a valid format.
1514
//
1615
// The details string encoding is implemented in
1716
// github.com/moby/moby/api/server/httputils/write_log_stream.go
18-
func ParseLogDetails(details string) (map[string]string, error) {
17+
func Parse(details string) (map[string]string, error) {
1918
pairs := strings.Split(details, ",")
2019
detailsMap := make(map[string]string, len(pairs))
2120
for _, pair := range pairs {

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

Lines changed: 3 additions & 3 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,7 +48,7 @@ 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 != "" {
5353
assert.Check(t, is.Error(err, tc.expectedErr))
5454
} else {

0 commit comments

Comments
 (0)