mirror of https://github.com/docker/cli.git
Compare commits
9 Commits
75619555fb
...
4e094e8eba
Author | SHA1 | Date |
---|---|---|
MicahKimel | 4e094e8eba | |
Sebastiaan van Stijn | a5fb752ecf | |
Laura Brehm | 4e64c59d64 | |
Jonathan A. Sternberg | 3472bbc28a | |
Laura Brehm | 649e564ee0 | |
Sebastiaan van Stijn | e1213edcc6 | |
Jonathan A. Sternberg | b1956f5073 | |
MicahKimel | dd8059925e | |
MicahKimel | 7098aaf6fc |
|
@ -67,7 +67,7 @@ jobs:
|
|||
name: Update Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: 1.22.7
|
||||
-
|
||||
name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
|
|
|
@ -180,7 +180,7 @@ func toWslPath(s string) string {
|
|||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("mnt/%s%s", drive, p)
|
||||
return fmt.Sprintf("mnt/%s%s", strings.ToLower(drive), p)
|
||||
}
|
||||
|
||||
func parseUNCPath(s string) (drive, p string, ok bool) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
@ -9,21 +10,48 @@ import (
|
|||
)
|
||||
|
||||
func TestWslSocketPath(t *testing.T) {
|
||||
u, err := url.Parse("unix:////./c:/my/file/path")
|
||||
assert.NilError(t, err)
|
||||
|
||||
// Ensure host is empty.
|
||||
assert.Equal(t, u.Host, "")
|
||||
|
||||
// Use a filesystem where the WSL path exists.
|
||||
fs := fstest.MapFS{
|
||||
"mnt/c/my/file/path": {},
|
||||
testCases := []struct {
|
||||
doc string
|
||||
fs fs.FS
|
||||
url string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
doc: "filesystem where WSL path does not exist",
|
||||
fs: fstest.MapFS{
|
||||
"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")
|
||||
|
||||
// Use a filesystem where the WSL path doesn't exist.
|
||||
fs = fstest.MapFS{
|
||||
"my/file/path": {},
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.doc, func(t *testing.T) {
|
||||
u, err := url.Parse(tc.url)
|
||||
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), "")
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/cli/cli/version"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
@ -94,7 +95,9 @@ func startCobraCommandTimer(mp metric.MeterProvider, attrs []attribute.KeyValue)
|
|||
metric.WithAttributes(cmdStatusAttrs...),
|
||||
)
|
||||
if mp, ok := mp.(MeterProvider); ok {
|
||||
mp.ForceFlush(ctx)
|
||||
if err := mp.ForceFlush(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -358,7 +358,9 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
|
|||
|
||||
mp := dockerCli.MeterProvider()
|
||||
if mp, ok := mp.(command.MeterProvider); ok {
|
||||
defer mp.Shutdown(ctx)
|
||||
if err := mp.Shutdown(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprint(dockerCli.Err(), "Warning: Unexpected OTEL error, metrics may not be flushed")
|
||||
}
|
||||
|
|
|
@ -963,7 +963,7 @@ This starts an `ubuntu` container with access to the specified CDI device,
|
|||
- A valid CDI specification (JSON or YAML file) for the requested device is
|
||||
available on the system running the daemon, in one of the configured CDI
|
||||
specification directories.
|
||||
- The CDI feature has been enabled in the daemon; see [Enable CDI
|
||||
- The CDI feature has been enabled in the daemon. See [Enable CDI
|
||||
devices](https://docs.docker.com/reference/cli/dockerd/#enable-cdi-devices).
|
||||
|
||||
### <a name="attach"></a> Attach to STDIN/STDOUT/STDERR (-a, --attach)
|
||||
|
@ -1572,4 +1572,4 @@ The `docker run` command is equivalent to the following API calls:
|
|||
- If that call returns a 404 (image not found), and depending on the `--pull` option ("always", "missing", "never") the call can trigger a `docker pull <image>`.
|
||||
- `/containers/create` again after pulling the image.
|
||||
- `/containers/(id)/start` to start the container.
|
||||
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.
|
||||
- `/containers/(id)/attach` to attach to the container when starting with the `-it` flags for interactive containers.
|
|
@ -87,6 +87,25 @@ func TestParseEnvFileNonExistentFile(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// Test TestParseEnvFile for a badly formatted header
|
||||
func TestParseEnvFileFormattedWithSpace(t *testing.T) {
|
||||
content := `
|
||||
[config 1]
|
||||
foo=bar
|
||||
f=quux
|
||||
`
|
||||
tmpFile := tmpFileWithContent(t, content)
|
||||
|
||||
_, err := ParseEnvFile(tmpFile)
|
||||
if _, ok := err.(ErrBadKey); !ok {
|
||||
t.Fatalf("Expected an ErrBadKey, got [%v]", err)
|
||||
}
|
||||
expectedMessage := "poorly formatted environment: variable '[config 1]' contains whitespaces"
|
||||
if err.Error() != expectedMessage {
|
||||
t.Fatalf("Expected [%v], got [%v]", expectedMessage, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Test ParseEnvFile for a badly formatted file
|
||||
func TestParseEnvFileBadlyFormattedFile(t *testing.T) {
|
||||
content := `foo=bar
|
||||
|
|
Loading…
Reference in New Issue