Compare commits

..

1 Commits

Author SHA1 Message Date
MicahKimel 75619555fb
Merge dd8059925e into a4619f3676 2024-09-17 11:17:56 +01:00
5 changed files with 18 additions and 51 deletions

View File

@ -67,7 +67,7 @@ jobs:
name: Update Go name: Update Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version: 1.22.7 go-version: '1.21'
- -
name: Initialize CodeQL name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3

View File

@ -180,7 +180,7 @@ func toWslPath(s string) string {
if !ok { if !ok {
return "" return ""
} }
return fmt.Sprintf("mnt/%s%s", strings.ToLower(drive), p) return fmt.Sprintf("mnt/%s%s", drive, p)
} }
func parseUNCPath(s string) (drive, p string, ok bool) { func parseUNCPath(s string) (drive, p string, ok bool) {

View File

@ -1,7 +1,6 @@
package command package command
import ( import (
"io/fs"
"net/url" "net/url"
"testing" "testing"
"testing/fstest" "testing/fstest"
@ -10,48 +9,21 @@ import (
) )
func TestWslSocketPath(t *testing.T) { func TestWslSocketPath(t *testing.T) {
testCases := []struct { u, err := url.Parse("unix:////./c:/my/file/path")
doc string assert.NilError(t, err)
fs fs.FS
url string // Ensure host is empty.
expected string assert.Equal(t, u.Host, "")
}{
{ // Use a filesystem where the WSL path exists.
doc: "filesystem where WSL path does not exist", fs := fstest.MapFS{
fs: fstest.MapFS{ "mnt/c/my/file/path": {},
"my/file/path": {},
},
url: "unix:////./c:/my/file/path",
expected: "",
},
{
doc: "filesystem where WSL path exists",
fs: fstest.MapFS{
"mnt/c/my/file/path": {},
},
url: "unix:////./c:/my/file/path",
expected: "/mnt/c/my/file/path",
},
{
doc: "filesystem where WSL path exists uppercase URL",
fs: fstest.MapFS{
"mnt/c/my/file/path": {},
},
url: "unix:////./C:/my/file/path",
expected: "/mnt/c/my/file/path",
},
} }
assert.Equal(t, wslSocketPath(u.Path, fs), "/mnt/c/my/file/path")
for _, tc := range testCases { // Use a filesystem where the WSL path doesn't exist.
t.Run(tc.doc, func(t *testing.T) { fs = fstest.MapFS{
u, err := url.Parse(tc.url) "my/file/path": {},
assert.NilError(t, err)
// Ensure host is empty.
assert.Equal(t, u.Host, "")
result := wslSocketPath(u.Path, tc.fs)
assert.Equal(t, result, tc.expected)
})
} }
assert.Equal(t, wslSocketPath(u.Path, fs), "")
} }

View File

@ -9,7 +9,6 @@ import (
"github.com/docker/cli/cli/version" "github.com/docker/cli/cli/version"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric"
) )
@ -95,9 +94,7 @@ func startCobraCommandTimer(mp metric.MeterProvider, attrs []attribute.KeyValue)
metric.WithAttributes(cmdStatusAttrs...), metric.WithAttributes(cmdStatusAttrs...),
) )
if mp, ok := mp.(MeterProvider); ok { if mp, ok := mp.(MeterProvider); ok {
if err := mp.ForceFlush(ctx); err != nil { mp.ForceFlush(ctx)
otel.Handle(err)
}
} }
} }
} }

View File

@ -358,9 +358,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
mp := dockerCli.MeterProvider() mp := dockerCli.MeterProvider()
if mp, ok := mp.(command.MeterProvider); ok { if mp, ok := mp.(command.MeterProvider); ok {
if err := mp.Shutdown(ctx); err != nil { defer mp.Shutdown(ctx)
otel.Handle(err)
}
} else { } else {
fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed") fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed")
} }