Skip to content

Commit 0d3d0c8

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 0d3d0c8

3 files changed

Lines changed: 8 additions & 8 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*Package logs contains tools for parsing docker log lines.
22
*/
3-
package logs
3+
package logdetails
44

55
import (
66
"errors"
77
"net/url"
88
"strings"
99
)
1010

11-
// ParseLogDetails parses a string of key value pairs in the form
11+
// Parse parses a string of key value pairs in the form
1212
// "k=v,l=w", where the keys and values are url query escaped, and each pair
1313
// is separated by a comma. Returns a map of the key value pairs on success,
1414
// and an error if the details string is not in a valid format.
1515
//
1616
// The details string encoding is implemented in
1717
// github.com/moby/moby/api/server/httputils/write_log_stream.go
18-
func ParseLogDetails(details string) (map[string]string, error) {
18+
func Parse(details string) (map[string]string, error) {
1919
pairs := strings.Split(details, ",")
2020
detailsMap := make(map[string]string, len(pairs))
2121
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)