mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-08-15 00:05:57 +08:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
257815a6fb | ||
![]() |
dbccfa60a7 | ||
![]() |
59cb959195 | ||
![]() |
dd0d53efd5 | ||
![]() |
e8ceaad0a8 | ||
![]() |
e5a6b8e140 | ||
![]() |
78c8c28cf5 | ||
![]() |
4173281da3 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -220,6 +220,8 @@ jobs:
|
||||
permissions:
|
||||
# required to write sarif report
|
||||
security-events: write
|
||||
# required to check out the repository
|
||||
contents: read
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
|
@@ -704,7 +704,7 @@ type Target struct {
|
||||
Outputs []string `json:"output,omitempty" hcl:"output,optional" cty:"output"`
|
||||
Pull *bool `json:"pull,omitempty" hcl:"pull,optional" cty:"pull"`
|
||||
NoCache *bool `json:"no-cache,omitempty" hcl:"no-cache,optional" cty:"no-cache"`
|
||||
NetworkMode *string `json:"network" hcl:"network" cty:"network"`
|
||||
NetworkMode *string `json:"network,omitempty" hcl:"network,optional" cty:"network"`
|
||||
NoCacheFilter []string `json:"no-cache-filter,omitempty" hcl:"no-cache-filter,optional" cty:"no-cache-filter"`
|
||||
ShmSize *string `json:"shm-size,omitempty" hcl:"shm-size,optional"`
|
||||
Ulimits []string `json:"ulimits,omitempty" hcl:"ulimits,optional"`
|
||||
|
@@ -435,7 +435,16 @@ func Create(ctx context.Context, txn *store.Txn, dockerCli command.Cli, opts Cre
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buildkitdFlags, err := parseBuildkitdFlags(opts.BuildkitdFlags, driverName, driverOpts)
|
||||
buildkitdConfigFile := opts.BuildkitdConfigFile
|
||||
if buildkitdConfigFile == "" {
|
||||
// if buildkit daemon config is not provided, check if the default one
|
||||
// is available and use it
|
||||
if f, ok := confutil.DefaultConfigFile(dockerCli); ok {
|
||||
buildkitdConfigFile = f
|
||||
}
|
||||
}
|
||||
|
||||
buildkitdFlags, err := parseBuildkitdFlags(opts.BuildkitdFlags, driverName, driverOpts, buildkitdConfigFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -496,15 +505,6 @@ func Create(ctx context.Context, txn *store.Txn, dockerCli command.Cli, opts Cre
|
||||
setEp = false
|
||||
}
|
||||
|
||||
buildkitdConfigFile := opts.BuildkitdConfigFile
|
||||
if buildkitdConfigFile == "" {
|
||||
// if buildkit daemon config is not provided, check if the default one
|
||||
// is available and use it
|
||||
if f, ok := confutil.DefaultConfigFile(dockerCli); ok {
|
||||
buildkitdConfigFile = f
|
||||
}
|
||||
}
|
||||
|
||||
if err := ng.Update(opts.NodeName, ep, opts.Platforms, setEp, opts.Append, buildkitdFlags, buildkitdConfigFile, driverOpts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -641,7 +641,7 @@ func validateBuildkitEndpoint(ep string) (string, error) {
|
||||
}
|
||||
|
||||
// parseBuildkitdFlags parses buildkit flags
|
||||
func parseBuildkitdFlags(inp string, driver string, driverOpts map[string]string) (res []string, err error) {
|
||||
func parseBuildkitdFlags(inp string, driver string, driverOpts map[string]string, buildkitdConfigFile string) (res []string, err error) {
|
||||
if inp != "" {
|
||||
res, err = shlex.Split(inp)
|
||||
if err != nil {
|
||||
@@ -663,10 +663,27 @@ func parseBuildkitdFlags(inp string, driver string, driverOpts map[string]string
|
||||
}
|
||||
}
|
||||
|
||||
var hasNetworkHostEntitlementInConf bool
|
||||
if buildkitdConfigFile != "" {
|
||||
btoml, err := confutil.LoadConfigTree(buildkitdConfigFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if btoml != nil {
|
||||
if ies := btoml.GetArray("insecure-entitlements"); ies != nil {
|
||||
for _, e := range ies.([]string) {
|
||||
if e == "network.host" {
|
||||
hasNetworkHostEntitlementInConf = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := driverOpts["network"]; ok && v == "host" && !hasNetworkHostEntitlement && driver == "docker-container" {
|
||||
// always set network.host entitlement if user has set network=host
|
||||
res = append(res, "--allow-insecure-entitlement=network.host")
|
||||
} else if len(allowInsecureEntitlements) == 0 && (driver == "kubernetes" || driver == "docker-container") {
|
||||
} else if len(allowInsecureEntitlements) == 0 && !hasNetworkHostEntitlementInConf && (driver == "kubernetes" || driver == "docker-container") {
|
||||
// set network.host entitlement if user does not provide any as
|
||||
// network is isolated for container drivers.
|
||||
res = append(res, "--allow-insecure-entitlement=network.host")
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -27,19 +29,34 @@ func TestCsvToMap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseBuildkitdFlags(t *testing.T) {
|
||||
buildkitdConf := `
|
||||
# debug enables additional debug logging
|
||||
debug = true
|
||||
# insecure-entitlements allows insecure entitlements, disabled by default.
|
||||
insecure-entitlements = [ "network.host", "security.insecure" ]
|
||||
[log]
|
||||
# log formatter: json or text
|
||||
format = "text"
|
||||
`
|
||||
dirConf := t.TempDir()
|
||||
buildkitdConfPath := path.Join(dirConf, "buildkitd-conf.toml")
|
||||
require.NoError(t, os.WriteFile(buildkitdConfPath, []byte(buildkitdConf), 0644))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
flags string
|
||||
driver string
|
||||
driverOpts map[string]string
|
||||
expected []string
|
||||
wantErr bool
|
||||
name string
|
||||
flags string
|
||||
driver string
|
||||
driverOpts map[string]string
|
||||
buildkitdConfigFile string
|
||||
expected []string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
"docker-container no flags",
|
||||
"",
|
||||
"docker-container",
|
||||
nil,
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
},
|
||||
@@ -50,6 +67,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"",
|
||||
"kubernetes",
|
||||
nil,
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
},
|
||||
@@ -60,6 +78,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"",
|
||||
"remote",
|
||||
nil,
|
||||
"",
|
||||
nil,
|
||||
false,
|
||||
},
|
||||
@@ -68,6 +87,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"--allow-insecure-entitlement=security.insecure",
|
||||
"docker-container",
|
||||
nil,
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=security.insecure",
|
||||
},
|
||||
@@ -78,6 +98,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"--allow-insecure-entitlement=network.host --allow-insecure-entitlement=security.insecure",
|
||||
"docker-container",
|
||||
nil,
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
"--allow-insecure-entitlement=security.insecure",
|
||||
@@ -89,6 +110,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"",
|
||||
"docker-container",
|
||||
map[string]string{"network": "host"},
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
},
|
||||
@@ -99,6 +121,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
"docker-container",
|
||||
map[string]string{"network": "host"},
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
},
|
||||
@@ -109,17 +132,28 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
"--allow-insecure-entitlement=network.host --allow-insecure-entitlement=security.insecure",
|
||||
"docker-container",
|
||||
map[string]string{"network": "host"},
|
||||
"",
|
||||
[]string{
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
"--allow-insecure-entitlement=security.insecure",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"docker-container with buildkitd conf setting network.host entitlement",
|
||||
"",
|
||||
"docker-container",
|
||||
nil,
|
||||
buildkitdConfPath,
|
||||
nil,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"error parsing flags",
|
||||
"foo'",
|
||||
"docker-container",
|
||||
nil,
|
||||
"",
|
||||
nil,
|
||||
true,
|
||||
},
|
||||
@@ -127,7 +161,7 @@ func TestParseBuildkitdFlags(t *testing.T) {
|
||||
for _, tt := range testCases {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
flags, err := parseBuildkitdFlags(tt.flags, tt.driver, tt.driverOpts)
|
||||
flags, err := parseBuildkitdFlags(tt.flags, tt.driver, tt.driverOpts, tt.buildkitdConfigFile)
|
||||
if tt.wantErr {
|
||||
require.Error(t, err)
|
||||
return
|
||||
|
6
go.mod
6
go.mod
@@ -16,9 +16,9 @@ require (
|
||||
github.com/containerd/typeurl/v2 v2.2.0
|
||||
github.com/creack/pty v1.1.21
|
||||
github.com/distribution/reference v0.6.0
|
||||
github.com/docker/cli v27.2.0+incompatible
|
||||
github.com/docker/cli v27.2.2-0.20240913085431-48a2cdff970d+incompatible
|
||||
github.com/docker/cli-docs-tool v0.8.0
|
||||
github.com/docker/docker v27.2.0+incompatible
|
||||
github.com/docker/docker v27.2.1+incompatible
|
||||
github.com/docker/go-units v0.5.0
|
||||
github.com/gofrs/flock v0.12.1
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
@@ -29,7 +29,7 @@ require (
|
||||
github.com/hashicorp/hcl/v2 v2.20.1
|
||||
github.com/in-toto/in-toto-golang v0.5.0
|
||||
github.com/mitchellh/hashstructure/v2 v2.0.2
|
||||
github.com/moby/buildkit v0.16.0-rc2
|
||||
github.com/moby/buildkit v0.16.0
|
||||
github.com/moby/sys/mountinfo v0.7.2
|
||||
github.com/moby/sys/signal v0.7.1
|
||||
github.com/morikuni/aec v1.0.0
|
||||
|
12
go.sum
12
go.sum
@@ -124,15 +124,15 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
||||
github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||
github.com/docker/cli v27.2.0+incompatible h1:yHD1QEB1/0vr5eBNpu8tncu8gWxg8EydFPOSKHzXSMM=
|
||||
github.com/docker/cli v27.2.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli v27.2.2-0.20240913085431-48a2cdff970d+incompatible h1:jbTJwvM0LKQUti9X1KfPCnRasE5894IGaqs5Y90YeXM=
|
||||
github.com/docker/cli v27.2.2-0.20240913085431-48a2cdff970d+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
|
||||
github.com/docker/cli-docs-tool v0.8.0 h1:YcDWl7rQJC3lJ7WVZRwSs3bc9nka97QLWfyJQli8yJU=
|
||||
github.com/docker/cli-docs-tool v0.8.0/go.mod h1:8TQQ3E7mOXoYUs811LiPdUnAhXrcVsBIrW21a5pUbdk=
|
||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4=
|
||||
github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI=
|
||||
github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo=
|
||||
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
|
||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||
@@ -307,8 +307,8 @@ github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/z
|
||||
github.com/mitchellh/mapstructure v0.0.0-20150613213606-2caf8efc9366/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/moby/buildkit v0.16.0-rc2 h1:5uFWrGujJOWHu0duIcz0tBagS97xddogZ3OxNEfezrU=
|
||||
github.com/moby/buildkit v0.16.0-rc2/go.mod h1:9STuyLZDJNGenp/smTiR01mnvqlO5u5ZW/0/aWHQcio=
|
||||
github.com/moby/buildkit v0.16.0 h1:wOVBj1o5YNVad/txPQNXUXdelm7Hs/i0PUFjzbK0VKE=
|
||||
github.com/moby/buildkit v0.16.0/go.mod h1:Xqx/5GlrqE1yIRORk0NSCVDFpQAU1WjlT6KHYZdisIQ=
|
||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
|
||||
|
@@ -103,6 +103,26 @@ target "build" {
|
||||
require.Equal(t, ".", *def.Target["build"].Context)
|
||||
require.Equal(t, "Dockerfile", *def.Target["build"].Dockerfile)
|
||||
require.Equal(t, map[string]*string{"HELLO": ptrstr("foo")}, def.Target["build"].Args)
|
||||
|
||||
require.Equal(t, `{
|
||||
"group": {
|
||||
"default": {
|
||||
"targets": [
|
||||
"build"
|
||||
]
|
||||
}
|
||||
},
|
||||
"target": {
|
||||
"build": {
|
||||
"context": ".",
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
"HELLO": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, stdout.String())
|
||||
}
|
||||
|
||||
func testBakeLocal(t *testing.T, sb integration.Sandbox) {
|
||||
|
@@ -34,8 +34,8 @@ func DefaultConfigFile(dockerCli command.Cli) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// loadConfigTree loads BuildKit config toml tree
|
||||
func loadConfigTree(fp string) (*toml.Tree, error) {
|
||||
// LoadConfigTree loads BuildKit config toml tree
|
||||
func LoadConfigTree(fp string) (*toml.Tree, error) {
|
||||
f, err := os.Open(fp)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
|
@@ -32,7 +32,7 @@ func LoadConfigFiles(bkconfig string) (map[string][]byte, error) {
|
||||
}
|
||||
|
||||
// Load config tree
|
||||
btoml, err := loadConfigTree(bkconfig)
|
||||
btoml, err := LoadConfigTree(bkconfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
11
vendor/github.com/docker/cli/cli/command/registry.go
generated
vendored
11
vendor/github.com/docker/cli/cli/command/registry.go
generated
vendored
@@ -124,17 +124,6 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
|
||||
cli.SetIn(streams.NewIn(os.Stdin))
|
||||
}
|
||||
|
||||
// Some links documenting this:
|
||||
// - https://code.google.com/archive/p/mintty/issues/56
|
||||
// - https://github.com/docker/docker/issues/15272
|
||||
// - https://mintty.github.io/ (compatibility)
|
||||
// Linux will hit this if you attempt `cat | docker login`, and Windows
|
||||
// will hit this if you attempt docker login from mintty where stdin
|
||||
// is a pipe, not a character based console.
|
||||
if argPassword == "" && !cli.In().IsTerminal() {
|
||||
return authConfig, errors.Errorf("Error: Cannot perform an interactive login from a non TTY device")
|
||||
}
|
||||
|
||||
isDefaultRegistry := serverAddress == registry.IndexServer
|
||||
defaultUsername = strings.TrimSpace(defaultUsername)
|
||||
|
||||
|
120
vendor/github.com/docker/cli/cli/command/telemetry_docker.go
generated
vendored
120
vendor/github.com/docker/cli/cli/command/telemetry_docker.go
generated
vendored
@@ -5,9 +5,14 @@ package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"go.opentelemetry.io/otel"
|
||||
@@ -77,14 +82,7 @@ func dockerExporterOTLPEndpoint(cli Cli) (endpoint string, secure bool) {
|
||||
|
||||
switch u.Scheme {
|
||||
case "unix":
|
||||
// Unix sockets are a bit weird. OTEL seems to imply they
|
||||
// can be used as an environment variable and are handled properly,
|
||||
// but they don't seem to be as the behavior of the environment variable
|
||||
// is to strip the scheme from the endpoint, but the underlying implementation
|
||||
// needs the scheme to use the correct resolver.
|
||||
//
|
||||
// We'll just handle this in a special way and add the unix:// back to the endpoint.
|
||||
endpoint = "unix://" + path.Join(u.Host, u.Path)
|
||||
endpoint = unixSocketEndpoint(u)
|
||||
case "https":
|
||||
secure = true
|
||||
fallthrough
|
||||
@@ -135,3 +133,109 @@ func dockerMetricExporter(ctx context.Context, cli Cli) []sdkmetric.Option {
|
||||
}
|
||||
return []sdkmetric.Option{sdkmetric.WithReader(newCLIReader(exp))}
|
||||
}
|
||||
|
||||
// unixSocketEndpoint converts the unix scheme from URL to
|
||||
// an OTEL endpoint that can be used with the OTLP exporter.
|
||||
//
|
||||
// The OTLP exporter handles unix sockets in a strange way.
|
||||
// It seems to imply they can be used as an environment variable
|
||||
// and are handled properly, but they don't seem to be as the behavior
|
||||
// of the environment variable is to strip the scheme from the endpoint
|
||||
// while the underlying implementation needs the scheme to use the
|
||||
// correct resolver.
|
||||
func unixSocketEndpoint(u *url.URL) string {
|
||||
// GRPC does not allow host to be used.
|
||||
socketPath := u.Path
|
||||
|
||||
// If we are on windows and we have an absolute path
|
||||
// that references a letter drive, check to see if the
|
||||
// WSL equivalent path exists and we should use that instead.
|
||||
if isWsl() {
|
||||
if p := wslSocketPath(socketPath, os.DirFS("/")); p != "" {
|
||||
socketPath = p
|
||||
}
|
||||
}
|
||||
// Enforce that we are using forward slashes.
|
||||
return "unix://" + filepath.ToSlash(socketPath)
|
||||
}
|
||||
|
||||
// wslSocketPath will convert the referenced URL to a WSL-compatible
|
||||
// path and check if that path exists. If the path exists, it will
|
||||
// be returned.
|
||||
func wslSocketPath(s string, f fs.FS) string {
|
||||
if p := toWslPath(s); p != "" {
|
||||
if _, err := stat(p, f); err == nil {
|
||||
return "/" + p
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// toWslPath converts the referenced URL to a WSL-compatible
|
||||
// path if this looks like a Windows absolute path.
|
||||
//
|
||||
// If no drive is in the URL, defaults to the C drive.
|
||||
func toWslPath(s string) string {
|
||||
drive, p, ok := parseUNCPath(s)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("mnt/%s%s", drive, p)
|
||||
}
|
||||
|
||||
func parseUNCPath(s string) (drive, p string, ok bool) {
|
||||
// UNC paths use backslashes but we're using forward slashes
|
||||
// so also enforce that here.
|
||||
//
|
||||
// In reality, this should have been enforced much earlier
|
||||
// than here since backslashes aren't allowed in URLs, but
|
||||
// we're going to code defensively here.
|
||||
s = filepath.ToSlash(s)
|
||||
|
||||
const uncPrefix = "//./"
|
||||
if !strings.HasPrefix(s, uncPrefix) {
|
||||
// Not a UNC path.
|
||||
return "", "", false
|
||||
}
|
||||
s = s[len(uncPrefix):]
|
||||
|
||||
parts := strings.SplitN(s, "/", 2)
|
||||
if len(parts) != 2 {
|
||||
// Not enough components.
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
drive, ok = splitWindowsDrive(parts[0])
|
||||
if !ok {
|
||||
// Not a windows drive.
|
||||
return "", "", false
|
||||
}
|
||||
return drive, "/" + parts[1], true
|
||||
}
|
||||
|
||||
// splitWindowsDrive checks if the string references a windows
|
||||
// drive (such as c:) and returns the drive letter if it is.
|
||||
func splitWindowsDrive(s string) (string, bool) {
|
||||
if b := []rune(s); len(b) == 2 && unicode.IsLetter(b[0]) && b[1] == ':' {
|
||||
return string(b[0]), true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func stat(p string, f fs.FS) (fs.FileInfo, error) {
|
||||
if f, ok := f.(fs.StatFS); ok {
|
||||
return f.Stat(p)
|
||||
}
|
||||
|
||||
file, err := f.Open(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
return file.Stat()
|
||||
}
|
||||
|
||||
func isWsl() bool {
|
||||
return os.Getenv("WSL_DISTRO_NAME") != ""
|
||||
}
|
||||
|
4
vendor/github.com/docker/cli/cli/connhelper/connhelper.go
generated
vendored
4
vendor/github.com/docker/cli/cli/connhelper/connhelper.go
generated
vendored
@@ -45,14 +45,14 @@ func getConnectionHelper(daemonURL string, sshFlags []string) (*ConnectionHelper
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ssh host connection is not valid")
|
||||
}
|
||||
sshFlags = addSSHTimeout(sshFlags)
|
||||
sshFlags = disablePseudoTerminalAllocation(sshFlags)
|
||||
return &ConnectionHelper{
|
||||
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
args := []string{"docker"}
|
||||
if sp.Path != "" {
|
||||
args = append(args, "--host", "unix://"+sp.Path)
|
||||
}
|
||||
sshFlags = addSSHTimeout(sshFlags)
|
||||
sshFlags = disablePseudoTerminalAllocation(sshFlags)
|
||||
args = append(args, "system", "dial-stdio")
|
||||
return commandconn.New(ctx, "ssh", append(sshFlags, sp.Args(args...)...)...)
|
||||
},
|
||||
|
2
vendor/github.com/docker/docker/api/swagger.yaml
generated
vendored
2
vendor/github.com/docker/docker/api/swagger.yaml
generated
vendored
@@ -5347,7 +5347,7 @@ definitions:
|
||||
The version Go used to compile the daemon, and the version of the Go
|
||||
runtime in use.
|
||||
type: "string"
|
||||
example: "go1.21.13"
|
||||
example: "go1.22.7"
|
||||
Os:
|
||||
description: |
|
||||
The operating system that the daemon is running on ("linux" or "windows")
|
||||
|
5
vendor/github.com/docker/docker/api/types/container/hostconfig.go
generated
vendored
5
vendor/github.com/docker/docker/api/types/container/hostconfig.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package container // import "github.com/docker/docker/api/types/container"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -325,12 +326,12 @@ func ValidateRestartPolicy(policy RestartPolicy) error {
|
||||
if policy.MaximumRetryCount < 0 {
|
||||
msg += " and cannot be negative"
|
||||
}
|
||||
return &errInvalidParameter{fmt.Errorf(msg)}
|
||||
return &errInvalidParameter{errors.New(msg)}
|
||||
}
|
||||
return nil
|
||||
case RestartPolicyOnFailure:
|
||||
if policy.MaximumRetryCount < 0 {
|
||||
return &errInvalidParameter{fmt.Errorf("invalid restart policy: maximum retry count cannot be negative")}
|
||||
return &errInvalidParameter{errors.New("invalid restart policy: maximum retry count cannot be negative")}
|
||||
}
|
||||
return nil
|
||||
case "":
|
||||
|
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@@ -218,7 +218,7 @@ github.com/davecgh/go-spew/spew
|
||||
# github.com/distribution/reference v0.6.0
|
||||
## explicit; go 1.20
|
||||
github.com/distribution/reference
|
||||
# github.com/docker/cli v27.2.0+incompatible
|
||||
# github.com/docker/cli v27.2.2-0.20240913085431-48a2cdff970d+incompatible
|
||||
## explicit
|
||||
github.com/docker/cli/cli
|
||||
github.com/docker/cli/cli-plugins/hooks
|
||||
@@ -270,7 +270,7 @@ github.com/docker/distribution/registry/client/transport
|
||||
github.com/docker/distribution/registry/storage/cache
|
||||
github.com/docker/distribution/registry/storage/cache/memory
|
||||
github.com/docker/distribution/uuid
|
||||
# github.com/docker/docker v27.2.0+incompatible
|
||||
# github.com/docker/docker v27.2.1+incompatible
|
||||
## explicit
|
||||
github.com/docker/docker/api
|
||||
github.com/docker/docker/api/types
|
||||
@@ -515,7 +515,7 @@ github.com/mitchellh/go-wordwrap
|
||||
github.com/mitchellh/hashstructure/v2
|
||||
# github.com/mitchellh/mapstructure v1.5.0
|
||||
## explicit; go 1.14
|
||||
# github.com/moby/buildkit v0.16.0-rc2
|
||||
# github.com/moby/buildkit v0.16.0
|
||||
## explicit; go 1.21.0
|
||||
github.com/moby/buildkit/api/services/control
|
||||
github.com/moby/buildkit/api/types
|
||||
|
Reference in New Issue
Block a user