Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad6c667034 | |||
| 5cef8fc8e5 | |||
| 9597e681cb | |||
| c050ae7fb1 | |||
| aa45ea366c | |||
| df5c7130df | |||
| a90e5598a4 | |||
| 66f8d279c1 | |||
| c4e5fd7e53 | |||
| 57332bcea3 | |||
| 2fe281d170 | |||
| 69f0132397 | |||
| 9447d7431b | |||
| c70ce79adc | |||
| 667bd9a1b8 | |||
| 6c66c799c7 | |||
| 8a9e86c728 | |||
| e176053a3f | |||
| f38bea4ac3 | |||
| 379470969b | |||
| 2355349d8b | |||
| 73d513e56a | |||
| 9fd5604d80 | |||
| 82ac89901f | |||
| 29e3a70b04 | |||
| 3fb239756d | |||
| ff72c27a7a | |||
| ed54e85144 | |||
| 0bc3d1fd2d | |||
| 50bb8c70f3 | |||
| 25168137bd | |||
| 3af5c3f8c6 | |||
| 3143ba5700 | |||
| a89484e338 | |||
| 2ac9213069 | |||
| 578ab52ece | |||
| c8e9c04d19 | |||
| 2fead2a50f | |||
| df1fe15cf6 | |||
| be9adbd5c1 | |||
| 2907276eca | |||
| 59b02c04bf | |||
| 6a3eb417d5 | |||
| c30ccb308d | |||
| 1572845a2f | |||
| caad34cf58 | |||
| bf683dfe52 | |||
| 307befd7e2 | |||
| b58270ba69 | |||
| 0ecfcb5997 | |||
| 0ea69840c6 | |||
| 208de55a17 | |||
| 1a8077b814 | |||
| fa0e2597e6 | |||
| f357def036 | |||
| 792ce891be | |||
| d473c60571 | |||
| b020a36d10 | |||
| d2e8ff9e20 | |||
| 10a899b6bd | |||
| 41718b98f6 | |||
| caf21526a0 | |||
| 94b98bfa21 | |||
| 87e400e44e | |||
| 8cb2456248 | |||
| 11b15544c5 | |||
| e803e487c3 | |||
| 296e10c0c5 |
+5
-1
@@ -1,2 +1,6 @@
|
||||
.dockerignore
|
||||
.git
|
||||
build
|
||||
.gitignore
|
||||
appveyor.yml
|
||||
build
|
||||
circle.yml
|
||||
|
||||
Vendored
+2
-1
@@ -5,8 +5,9 @@ wrappedNode(label: 'linux && x86_64', cleanWorkspace: true) {
|
||||
|
||||
stage "Run end-to-end test suite"
|
||||
sh "docker version"
|
||||
sh "docker info"
|
||||
sh "E2E_UNIQUE_ID=clie2e${BUILD_NUMBER} \
|
||||
IMAGE_TAG=clie2e${BUILD_NUMBER} \
|
||||
make -f docker.Makefile test-e2e"
|
||||
DOCKER_BUILDKIT=1 make -f docker.Makefile test-e2e"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[](https://circleci.com/gh/docker/cli/tree/master) [](https://jenkins.dockerproject.org/job/docker/job/cli/job/master/)
|
||||
[](https://circleci.com/gh/docker/cli/tree/master)
|
||||
[](https://ci.docker.com/public/job/cli/job/master)
|
||||
|
||||
docker/cli
|
||||
==========
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ clone_folder: c:\gopath\src\github.com\docker\cli
|
||||
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
GOVERSION: 1.12.5
|
||||
GOVERSION: 1.12.12
|
||||
DEPVERSION: v0.4.1
|
||||
|
||||
install:
|
||||
|
||||
+35
-25
@@ -4,35 +4,39 @@ jobs:
|
||||
|
||||
lint:
|
||||
working_directory: /work
|
||||
docker: [{image: 'docker:18.03-git'}]
|
||||
docker: [{image: 'docker:18.09-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 18.03.1-ce
|
||||
reusable: true
|
||||
exclusive: false
|
||||
version: 18.09.3
|
||||
reusable: true
|
||||
exclusive: false
|
||||
- run:
|
||||
command: docker version
|
||||
- run:
|
||||
name: "Lint"
|
||||
command: |
|
||||
docker build -f dockerfiles/Dockerfile.lint --tag cli-linter:$CIRCLE_BUILD_NUM .
|
||||
docker build --progress=plain -f dockerfiles/Dockerfile.lint --tag cli-linter:$CIRCLE_BUILD_NUM .
|
||||
docker run --rm cli-linter:$CIRCLE_BUILD_NUM
|
||||
|
||||
cross:
|
||||
working_directory: /work
|
||||
docker: [{image: 'docker:18.03-git'}]
|
||||
docker: [{image: 'docker:18.09-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
parallelism: 3
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 18.03.1-ce
|
||||
reusable: true
|
||||
exclusive: false
|
||||
version: 18.09.3
|
||||
reusable: true
|
||||
exclusive: false
|
||||
- run:
|
||||
name: "Cross"
|
||||
command: |
|
||||
docker build -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM .
|
||||
docker build --progress=plain -f dockerfiles/Dockerfile.cross --tag cli-builder:$CIRCLE_BUILD_NUM .
|
||||
name=cross-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX
|
||||
docker run \
|
||||
-e CROSS_GROUP=$CIRCLE_NODE_INDEX \
|
||||
@@ -46,18 +50,20 @@ jobs:
|
||||
|
||||
test:
|
||||
working_directory: /work
|
||||
docker: [{image: 'docker:18.03-git'}]
|
||||
docker: [{image: 'docker:18.09-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 18.03.1-ce
|
||||
reusable: true
|
||||
exclusive: false
|
||||
version: 18.09.3
|
||||
reusable: true
|
||||
exclusive: false
|
||||
- run:
|
||||
name: "Unit Test with Coverage"
|
||||
command: |
|
||||
mkdir -p test-results/unit-tests
|
||||
docker build -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM .
|
||||
docker build --progress=plain -f dockerfiles/Dockerfile.dev --tag cli-builder:$CIRCLE_BUILD_NUM .
|
||||
docker run \
|
||||
-e GOTESTSUM_JUNITFILE=/tmp/junit.xml \
|
||||
--name \
|
||||
@@ -82,34 +88,38 @@ jobs:
|
||||
|
||||
validate:
|
||||
working_directory: /work
|
||||
docker: [{image: 'docker:18.03-git'}]
|
||||
docker: [{image: 'docker:18.09-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 18.03.1-ce
|
||||
reusable: true
|
||||
exclusive: false
|
||||
version: 18.09.3
|
||||
reusable: true
|
||||
exclusive: false
|
||||
- run:
|
||||
name: "Validate Vendor, Docs, and Code Generation"
|
||||
command: |
|
||||
rm -f .dockerignore # include .git
|
||||
docker build -f dockerfiles/Dockerfile.dev --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
|
||||
docker build --progress=plain -f dockerfiles/Dockerfile.dev --tag cli-builder-with-git:$CIRCLE_BUILD_NUM .
|
||||
docker run --rm cli-builder-with-git:$CIRCLE_BUILD_NUM \
|
||||
make ci-validate
|
||||
no_output_timeout: 15m
|
||||
shellcheck:
|
||||
working_directory: /work
|
||||
docker: [{image: 'docker:18.03-git'}]
|
||||
docker: [{image: 'docker:18.09-git'}]
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 18.03.1-ce
|
||||
reusable: true
|
||||
exclusive: false
|
||||
version: 18.09.3
|
||||
reusable: true
|
||||
exclusive: false
|
||||
- run:
|
||||
name: "Run shellcheck"
|
||||
command: |
|
||||
docker build -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM .
|
||||
docker build --progress=plain -f dockerfiles/Dockerfile.shellcheck --tag cli-validator:$CIRCLE_BUILD_NUM .
|
||||
docker run --rm cli-validator:$CIRCLE_BUILD_NUM \
|
||||
make shellcheck
|
||||
workflows:
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
@@ -79,6 +80,24 @@ func TestNewAPIClientFromFlagsWithAPIVersionFromEnv(t *testing.T) {
|
||||
assert.Check(t, is.Equal(customVersion, apiclient.ClientVersion()))
|
||||
}
|
||||
|
||||
func TestNewAPIClientFromFlagsWithHttpProxyEnv(t *testing.T) {
|
||||
defer env.Patch(t, "HTTP_PROXY", "http://proxy.acme.com:1234")()
|
||||
defer env.Patch(t, "DOCKER_HOST", "tcp://docker.acme.com:2376")()
|
||||
|
||||
opts := &flags.CommonOptions{}
|
||||
configFile := &configfile.ConfigFile{}
|
||||
apiclient, err := NewAPIClientFromFlags(opts, configFile)
|
||||
assert.NilError(t, err)
|
||||
transport, ok := apiclient.HTTPClient().Transport.(*http.Transport)
|
||||
assert.Assert(t, ok)
|
||||
assert.Assert(t, transport.Proxy != nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "tcp://docker.acme.com:2376", nil)
|
||||
assert.NilError(t, err)
|
||||
url, err := transport.Proxy(request)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal("http://proxy.acme.com:1234", url.String()))
|
||||
}
|
||||
|
||||
type fakeClient struct {
|
||||
client.Client
|
||||
pingFunc func() (types.Ping, error)
|
||||
|
||||
@@ -78,13 +78,19 @@ func RunCreate(cli command.Cli, o *CreateOptions) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to parse default-stack-orchestrator")
|
||||
}
|
||||
if o.From == "" && o.Docker == nil && o.Kubernetes == nil {
|
||||
return createFromExistingContext(s, cli.CurrentContext(), stackOrchestrator, o)
|
||||
switch {
|
||||
case o.From == "" && o.Docker == nil && o.Kubernetes == nil:
|
||||
err = createFromExistingContext(s, cli.CurrentContext(), stackOrchestrator, o)
|
||||
case o.From != "":
|
||||
err = createFromExistingContext(s, o.From, stackOrchestrator, o)
|
||||
default:
|
||||
err = createNewContext(o, stackOrchestrator, cli, s)
|
||||
}
|
||||
if o.From != "" {
|
||||
return createFromExistingContext(s, o.From, stackOrchestrator, o)
|
||||
if err == nil {
|
||||
fmt.Fprintln(cli.Out(), o.Name)
|
||||
fmt.Fprintf(cli.Err(), "Successfully created context %q\n", o.Name)
|
||||
}
|
||||
return createNewContext(o, stackOrchestrator, cli, s)
|
||||
return err
|
||||
}
|
||||
|
||||
func createNewContext(o *CreateOptions, stackOrchestrator command.Orchestrator, cli command.Cli, s store.Writer) error {
|
||||
@@ -127,8 +133,6 @@ func createNewContext(o *CreateOptions, stackOrchestrator command.Orchestrator,
|
||||
if err := s.ResetTLSMaterial(o.Name, &contextTLSData); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintln(cli.Out(), o.Name)
|
||||
fmt.Fprintf(cli.Err(), "Successfully created context %q\n", o.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -131,6 +132,11 @@ func TestCreateInvalids(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func assertContextCreateLogging(t *testing.T, cli *test.FakeCli, n string) {
|
||||
assert.Equal(t, n+"\n", cli.OutBuffer().String())
|
||||
assert.Equal(t, fmt.Sprintf("Successfully created context %q\n", n), cli.ErrBuffer().String())
|
||||
}
|
||||
|
||||
func TestCreateOrchestratorSwarm(t *testing.T) {
|
||||
cli, cleanup := makeFakeCli(t)
|
||||
defer cleanup()
|
||||
@@ -141,8 +147,7 @@ func TestCreateOrchestratorSwarm(t *testing.T) {
|
||||
Docker: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, "test\n", cli.OutBuffer().String())
|
||||
assert.Equal(t, "Successfully created context \"test\"\n", cli.ErrBuffer().String())
|
||||
assertContextCreateLogging(t, cli, "test")
|
||||
}
|
||||
|
||||
func TestCreateOrchestratorEmpty(t *testing.T) {
|
||||
@@ -154,6 +159,7 @@ func TestCreateOrchestratorEmpty(t *testing.T) {
|
||||
Docker: map[string]string{},
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, "test")
|
||||
}
|
||||
|
||||
func validateTestKubeEndpoint(t *testing.T, s store.Reader, name string) {
|
||||
@@ -189,6 +195,7 @@ func TestCreateOrchestratorAllKubernetesEndpointFromCurrent(t *testing.T) {
|
||||
cli, cleanup := makeFakeCli(t)
|
||||
defer cleanup()
|
||||
createTestContextWithKube(t, cli)
|
||||
assertContextCreateLogging(t, cli, "test")
|
||||
validateTestKubeEndpoint(t, cli.ContextStore(), "test")
|
||||
}
|
||||
|
||||
@@ -225,6 +232,7 @@ func TestCreateFromContext(t *testing.T) {
|
||||
defer cleanup()
|
||||
revert := env.Patch(t, "KUBECONFIG", "./testdata/test-kubeconfig")
|
||||
defer revert()
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "original",
|
||||
Description: "original description",
|
||||
@@ -236,6 +244,9 @@ func TestCreateFromContext(t *testing.T) {
|
||||
},
|
||||
DefaultStackOrchestrator: "swarm",
|
||||
}))
|
||||
assertContextCreateLogging(t, cli, "original")
|
||||
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "dummy",
|
||||
Description: "dummy description",
|
||||
@@ -247,11 +258,13 @@ func TestCreateFromContext(t *testing.T) {
|
||||
},
|
||||
DefaultStackOrchestrator: "swarm",
|
||||
}))
|
||||
assertContextCreateLogging(t, cli, "dummy")
|
||||
|
||||
cli.SetCurrentContext("dummy")
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
cli.ResetOutputBuffers()
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
From: "original",
|
||||
Name: c.name,
|
||||
@@ -261,6 +274,7 @@ func TestCreateFromContext(t *testing.T) {
|
||||
Kubernetes: c.kubernetes,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, c.name)
|
||||
newContext, err := cli.ContextStore().GetMetadata(c.name)
|
||||
assert.NilError(t, err)
|
||||
newContextTyped, err := command.GetDockerContext(newContext)
|
||||
@@ -308,6 +322,7 @@ func TestCreateFromCurrent(t *testing.T) {
|
||||
defer cleanup()
|
||||
revert := env.Patch(t, "KUBECONFIG", "./testdata/test-kubeconfig")
|
||||
defer revert()
|
||||
cli.ResetOutputBuffers()
|
||||
assert.NilError(t, RunCreate(cli, &CreateOptions{
|
||||
Name: "original",
|
||||
Description: "original description",
|
||||
@@ -319,17 +334,20 @@ func TestCreateFromCurrent(t *testing.T) {
|
||||
},
|
||||
DefaultStackOrchestrator: "swarm",
|
||||
}))
|
||||
assertContextCreateLogging(t, cli, "original")
|
||||
|
||||
cli.SetCurrentContext("original")
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
cli.ResetOutputBuffers()
|
||||
err := RunCreate(cli, &CreateOptions{
|
||||
Name: c.name,
|
||||
Description: c.description,
|
||||
DefaultStackOrchestrator: c.orchestrator,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assertContextCreateLogging(t, cli, c.name)
|
||||
newContext, err := cli.ContextStore().GetMetadata(c.name)
|
||||
assert.NilError(t, err)
|
||||
newContextTyped, err := command.GetDockerContext(newContext)
|
||||
|
||||
@@ -156,7 +156,8 @@ func runBuildBuildKit(dockerCli command.Cli, options buildOptions) error {
|
||||
}
|
||||
w = f
|
||||
}
|
||||
s.Allow(filesync.NewFSSyncTarget(w))
|
||||
output := func(map[string]string) (io.WriteCloser, error) { return w, nil }
|
||||
s.Allow(filesync.NewFSSyncTarget(output))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@@ -69,12 +70,14 @@ func loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions
|
||||
}
|
||||
|
||||
func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
|
||||
fileInfo, err := os.Stat(keyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
|
||||
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
|
||||
if runtime.GOOS != "windows" {
|
||||
fileInfo, err := os.Stat(keyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
|
||||
return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
|
||||
}
|
||||
}
|
||||
|
||||
from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms)
|
||||
|
||||
@@ -32,6 +32,14 @@ type Options struct {
|
||||
SkipInterpolation bool
|
||||
// Interpolation options
|
||||
Interpolate *interp.Options
|
||||
// Discard 'env_file' entries after resolving to 'environment' section
|
||||
discardEnvFiles bool
|
||||
}
|
||||
|
||||
// WithDiscardEnvFiles sets the Options to discard the `env_file` section after resolving to
|
||||
// the `environment` section
|
||||
func WithDiscardEnvFiles(opts *Options) {
|
||||
opts.discardEnvFiles = true
|
||||
}
|
||||
|
||||
// ParseYAML reads the bytes from a file, parses the bytes into a mapping
|
||||
@@ -105,6 +113,11 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
|
||||
return nil, err
|
||||
}
|
||||
cfg.Filename = file.Filename
|
||||
if opts.discardEnvFiles {
|
||||
for i := range cfg.Services {
|
||||
cfg.Services[i].EnvFile = nil
|
||||
}
|
||||
}
|
||||
|
||||
configs = append(configs, cfg)
|
||||
}
|
||||
@@ -479,12 +492,13 @@ func resolveVolumePaths(volumes []types.ServiceVolumeConfig, workingDir string,
|
||||
}
|
||||
|
||||
filePath := expandUser(volume.Source, lookupEnv)
|
||||
// Check for a Unix absolute path first, to handle a Windows client
|
||||
// with a Unix daemon. This handles a Windows client connecting to a
|
||||
// Unix daemon. Note that this is not required for Docker for Windows
|
||||
// when specifying a local Windows path, because Docker for Windows
|
||||
// translates the Windows path into a valid path within the VM.
|
||||
if !path.IsAbs(filePath) {
|
||||
// Check if source is an absolute path (either Unix or Windows), to
|
||||
// handle a Windows client with a Unix daemon or vice-versa.
|
||||
//
|
||||
// Note that this is not required for Docker for Windows when specifying
|
||||
// a local Windows path, because Docker for Windows translates the Windows
|
||||
// path into a valid path within the VM.
|
||||
if !path.IsAbs(filePath) && !isAbs(filePath) {
|
||||
filePath = absPath(workingDir, filePath)
|
||||
}
|
||||
volume.Source = filePath
|
||||
|
||||
@@ -759,6 +759,38 @@ services:
|
||||
assert.Check(t, is.DeepEqual([]string{"build", "links", "pid"}, unsupported))
|
||||
}
|
||||
|
||||
func TestDiscardEnvFileOption(t *testing.T) {
|
||||
dict, err := ParseYAML([]byte(`version: "3"
|
||||
services:
|
||||
web:
|
||||
image: nginx
|
||||
env_file:
|
||||
- example1.env
|
||||
- example2.env
|
||||
`))
|
||||
expectedEnvironmentMap := types.MappingWithEquals{
|
||||
"FOO": strPtr("foo_from_env_file"),
|
||||
"BAZ": strPtr("baz_from_env_file"),
|
||||
"BAR": strPtr("bar_from_env_file_2"), // Original value is overwritten by example2.env
|
||||
"QUX": strPtr("quz_from_env_file_2"),
|
||||
}
|
||||
assert.NilError(t, err)
|
||||
configDetails := buildConfigDetails(dict, nil)
|
||||
|
||||
// Default behavior keeps the `env_file` entries
|
||||
configWithEnvFiles, err := Load(configDetails)
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, configWithEnvFiles.Services[0].EnvFile, types.StringList{"example1.env",
|
||||
"example2.env"})
|
||||
assert.DeepEqual(t, configWithEnvFiles.Services[0].Environment, expectedEnvironmentMap)
|
||||
|
||||
// Custom behavior removes the `env_file` entries
|
||||
configWithoutEnvFiles, err := Load(configDetails, WithDiscardEnvFiles)
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, configWithoutEnvFiles.Services[0].EnvFile, types.StringList(nil))
|
||||
assert.DeepEqual(t, configWithoutEnvFiles.Services[0].Environment, expectedEnvironmentMap)
|
||||
}
|
||||
|
||||
func TestBuildProperties(t *testing.T) {
|
||||
dict, err := ParseYAML([]byte(`
|
||||
version: "3"
|
||||
@@ -985,6 +1017,84 @@ services:
|
||||
assert.Error(t, err, `invalid mount config for type "bind": field Source must not be empty`)
|
||||
}
|
||||
|
||||
func TestLoadBindMountSourceIsWindowsAbsolute(t *testing.T) {
|
||||
tests := []struct {
|
||||
doc string
|
||||
yaml string
|
||||
expected types.ServiceVolumeConfig
|
||||
}{
|
||||
{
|
||||
doc: "Z-drive lowercase",
|
||||
yaml: `
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
windows:
|
||||
image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019
|
||||
volumes:
|
||||
- type: bind
|
||||
source: z:\
|
||||
target: c:\data
|
||||
`,
|
||||
expected: types.ServiceVolumeConfig{Type: "bind", Source: `z:\`, Target: `c:\data`},
|
||||
},
|
||||
{
|
||||
doc: "Z-drive uppercase",
|
||||
yaml: `
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
windows:
|
||||
image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019
|
||||
volumes:
|
||||
- type: bind
|
||||
source: Z:\
|
||||
target: C:\data
|
||||
`,
|
||||
expected: types.ServiceVolumeConfig{Type: "bind", Source: `Z:\`, Target: `C:\data`},
|
||||
},
|
||||
{
|
||||
doc: "Z-drive subdirectory",
|
||||
yaml: `
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
windows:
|
||||
image: mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019
|
||||
volumes:
|
||||
- type: bind
|
||||
source: Z:\some-dir
|
||||
target: C:\data
|
||||
`,
|
||||
expected: types.ServiceVolumeConfig{Type: "bind", Source: `Z:\some-dir`, Target: `C:\data`},
|
||||
},
|
||||
{
|
||||
doc: "forward-slashes",
|
||||
yaml: `
|
||||
version: '3.3'
|
||||
|
||||
services:
|
||||
app:
|
||||
image: app:latest
|
||||
volumes:
|
||||
- type: bind
|
||||
source: /z/some-dir
|
||||
target: /c/data
|
||||
`,
|
||||
expected: types.ServiceVolumeConfig{Type: "bind", Source: `/z/some-dir`, Target: `/c/data`},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.doc, func(t *testing.T) {
|
||||
config, err := loadYAML(tc.yaml)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Len(config.Services[0].Volumes, 1))
|
||||
assert.Check(t, is.DeepEqual(tc.expected, config.Services[0].Volumes[0]))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBindMountWithSource(t *testing.T) {
|
||||
config, err := loadYAML(`
|
||||
version: "3.5"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package loader
|
||||
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// https://github.com/golang/go/blob/master/LICENSE
|
||||
|
||||
// This file contains utilities to check for Windows absolute paths on Linux.
|
||||
// The code in this file was largely copied from the Golang filepath package
|
||||
// https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_windows.go#L12-L65
|
||||
|
||||
func isSlash(c uint8) bool {
|
||||
return c == '\\' || c == '/'
|
||||
}
|
||||
|
||||
// isAbs reports whether the path is a Windows absolute path.
|
||||
func isAbs(path string) (b bool) {
|
||||
l := volumeNameLen(path)
|
||||
if l == 0 {
|
||||
return false
|
||||
}
|
||||
path = path[l:]
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
return isSlash(path[0])
|
||||
}
|
||||
|
||||
// volumeNameLen returns length of the leading volume name on Windows.
|
||||
// It returns 0 elsewhere.
|
||||
// nolint: gocyclo
|
||||
func volumeNameLen(path string) int {
|
||||
if len(path) < 2 {
|
||||
return 0
|
||||
}
|
||||
// with drive letter
|
||||
c := path[0]
|
||||
if path[1] == ':' && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
|
||||
return 2
|
||||
}
|
||||
// is it UNC? https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
||||
if l := len(path); l >= 5 && isSlash(path[0]) && isSlash(path[1]) &&
|
||||
!isSlash(path[2]) && path[2] != '.' {
|
||||
// first, leading `\\` and next shouldn't be `\`. its server name.
|
||||
for n := 3; n < l-1; n++ {
|
||||
// second, next '\' shouldn't be repeated.
|
||||
if isSlash(path[n]) {
|
||||
n++
|
||||
// third, following something characters. its share name.
|
||||
if !isSlash(path[n]) {
|
||||
if path[n] == '.' {
|
||||
break
|
||||
}
|
||||
for ; n < l; n++ {
|
||||
if isSlash(path[n]) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package loader
|
||||
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// https://github.com/golang/go/blob/master/LICENSE
|
||||
|
||||
// The code in this file was copied from the Golang filepath package with some
|
||||
// small modifications to run it on non-Windows platforms.
|
||||
// https://github.com/golang/go/blob/1d0e94b1e13d5e8a323a63cd1cc1ef95290c9c36/src/path/filepath/path_test.go#L711-L763
|
||||
|
||||
import "testing"
|
||||
|
||||
type IsAbsTest struct {
|
||||
path string
|
||||
isAbs bool
|
||||
}
|
||||
|
||||
var isabstests = []IsAbsTest{
|
||||
{"", false},
|
||||
{"/", true},
|
||||
{"/usr/bin/gcc", true},
|
||||
{"..", false},
|
||||
{"/a/../bb", true},
|
||||
{".", false},
|
||||
{"./", false},
|
||||
{"lala", false},
|
||||
}
|
||||
|
||||
var winisabstests = []IsAbsTest{
|
||||
{`C:\`, true},
|
||||
{`c\`, false},
|
||||
{`c::`, false},
|
||||
{`c:`, false},
|
||||
{`/`, false},
|
||||
{`\`, false},
|
||||
{`\Windows`, false},
|
||||
{`c:a\b`, false},
|
||||
{`c:\a\b`, true},
|
||||
{`c:/a/b`, true},
|
||||
{`\\host\share\foo`, true},
|
||||
{`//host/share/foo/bar`, true},
|
||||
}
|
||||
|
||||
func TestIsAbs(t *testing.T) {
|
||||
tests := append(isabstests, winisabstests...)
|
||||
// All non-windows tests should fail, because they have no volume letter.
|
||||
for _, test := range isabstests {
|
||||
tests = append(tests, IsAbsTest{test.path, false})
|
||||
}
|
||||
// All non-windows test should work as intended if prefixed with volume letter.
|
||||
for _, test := range isabstests {
|
||||
tests = append(tests, IsAbsTest{"c:" + test.path, test.isAbs})
|
||||
}
|
||||
|
||||
for _, test := range winisabstests {
|
||||
if r := isAbs(test.path); r != test.isAbs {
|
||||
t.Errorf("IsAbs(%q) = %v, want %v", test.path, r, test.isAbs)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,8 @@ func (c *Endpoint) ClientOpts() ([]client.Opt, error) {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result,
|
||||
client.WithHost(c.Host),
|
||||
withHTTPClient(tlsConfig),
|
||||
client.WithHost(c.Host),
|
||||
)
|
||||
|
||||
} else {
|
||||
|
||||
@@ -550,17 +550,18 @@ __docker_complete_nodes() {
|
||||
# output to the IDs or names of matching items. This setting takes
|
||||
# precedence over the environment setting.
|
||||
__docker_services() {
|
||||
local fields='$2' # default: service name only
|
||||
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
|
||||
local format='{{.Name}}' # default: service name only
|
||||
[ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && format='{{.ID}} {{.Name}}' # ID & name
|
||||
|
||||
if [ "$1" = "--id" ] ; then
|
||||
fields='$1' # IDs only
|
||||
format='{{.ID}}' # IDs only
|
||||
shift
|
||||
elif [ "$1" = "--name" ] ; then
|
||||
fields='$2' # names only
|
||||
format='{{.Name}}' # names only
|
||||
shift
|
||||
fi
|
||||
__docker_q service ls "$@" | awk "NR>1 {print $fields}"
|
||||
|
||||
__docker_q service ls --quiet --format "$format" "$@"
|
||||
}
|
||||
|
||||
# __docker_complete_services applies completion of services based on the current
|
||||
@@ -572,7 +573,7 @@ __docker_complete_services() {
|
||||
current="$2"
|
||||
shift 2
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "$(__docker_services "$@")" -- "$current") )
|
||||
COMPREPLY=( $(__docker_services "$@" --filter "name=$current") )
|
||||
}
|
||||
|
||||
# __docker_tasks returns a list of all task IDs.
|
||||
@@ -1204,6 +1205,7 @@ _docker_build() {
|
||||
|
||||
_docker_builder() {
|
||||
local subcommands="
|
||||
build
|
||||
prune
|
||||
"
|
||||
__docker_subcommands "$subcommands" && return
|
||||
@@ -1218,6 +1220,10 @@ _docker_builder() {
|
||||
esac
|
||||
}
|
||||
|
||||
_docker_builder_build() {
|
||||
_docker_image_build
|
||||
}
|
||||
|
||||
_docker_builder_prune() {
|
||||
case "$prev" in
|
||||
--filter)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
function __fish_docker_no_subcommand --description 'Test if docker has yet to be given the subcommand'
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i attach build commit cp create diff events exec export history images import info inspect kill load login logout logs pause port ps pull push rename restart rm rmi run save search start stop tag top trust unpause version wait stats
|
||||
if contains -- $i attach build commit cp create diff events exec export history images import info inspect kill load login logout logs network pause port ps pull push rename restart rm rmi run save search start stop tag top trust unpause version wait stats
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@@ -34,6 +34,11 @@ function __fish_print_docker_containers --description 'Print a list of docker co
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_print_docker_networks --description 'Print a list of docker networks'
|
||||
docker network ls --format "{{.ID}}\n{{.Name}}" | tr ',' '\n'
|
||||
end
|
||||
|
||||
|
||||
function __fish_docker_no_subcommand_trust --description 'Test if docker has yet to be given the trust subcommand'
|
||||
if __fish_seen_subcommand_from trust
|
||||
for i in (commandline -opc)
|
||||
@@ -370,6 +375,21 @@ complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l since -d 'Show
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -l tail -d 'Output the specified number of lines at the end of logs (defaults to all logs)'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from logs' -a '(__fish_print_docker_containers running)' -d "Container"
|
||||
|
||||
# network
|
||||
complete -c docker -f -n '__fish_docker_no_subcommand' -a network -d 'Manage networks'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a connect -d 'Connect a container to a network'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a create -d 'Create a network'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a disconnect -d 'Disconnect a container from a network'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a inspect -d 'Display detailed information on one or more networks'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a ls -d 'List networks'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a prune -d 'Remove all unused networks'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -a rm -d 'Remove one or more networks'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network' -l help -d 'Print usage'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network rm' -a '(__fish_print_docker_networks)' -d "Network"
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network connect' -a '(__fish_print_docker_networks)' -d "Network"
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network disconnect' -a '(__fish_print_docker_networks)' -d "Network"
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from network inspect' -a '(__fish_print_docker_networks)' -d "Network"
|
||||
|
||||
# port
|
||||
complete -c docker -f -n '__fish_docker_no_subcommand' -a port -d 'Lookup the public-facing port that is NAT-ed to PRIVATE_PORT'
|
||||
complete -c docker -A -f -n '__fish_seen_subcommand_from port' -l help -d 'Print usage'
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
# - Felix Riedel
|
||||
# - Steve Durrheimer
|
||||
# - Vincent Bernat
|
||||
# - Rohan Verma
|
||||
#
|
||||
# license:
|
||||
#
|
||||
@@ -2784,7 +2785,7 @@ __docker_subcommand() {
|
||||
$opts_help \
|
||||
"($help -p --password)"{-p=,--password=}"[Password]:password: " \
|
||||
"($help)--password-stdin[Read password from stdin]" \
|
||||
"($help -u --user)"{-u=,--user=}"[Username]:username: " \
|
||||
"($help -u --username)"{-u=,--username=}"[Username]:username: " \
|
||||
"($help -)1:server: " && ret=0
|
||||
;;
|
||||
(logout)
|
||||
|
||||
+6
-6
@@ -27,32 +27,32 @@ ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIR
|
||||
.PHONY: build_docker_image
|
||||
build_docker_image:
|
||||
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
|
||||
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} -t $(DEV_DOCKER_IMAGE_NAME) -
|
||||
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) -
|
||||
|
||||
# build docker image having the linting tools (dockerfiles/Dockerfile.lint)
|
||||
.PHONY: build_linter_image
|
||||
build_linter_image:
|
||||
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
|
||||
cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} -t $(LINTER_IMAGE_NAME) -
|
||||
cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(LINTER_IMAGE_NAME) -
|
||||
|
||||
.PHONY: build_cross_image
|
||||
build_cross_image:
|
||||
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
|
||||
cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} -t $(CROSS_IMAGE_NAME) -
|
||||
cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(CROSS_IMAGE_NAME) -
|
||||
|
||||
.PHONY: build_shell_validate_image
|
||||
build_shell_validate_image:
|
||||
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
|
||||
cat ./dockerfiles/Dockerfile.shellcheck | docker build -t $(VALIDATE_IMAGE_NAME) -
|
||||
cat ./dockerfiles/Dockerfile.shellcheck | docker build --build-arg=GO_VERSION -t $(VALIDATE_IMAGE_NAME) -
|
||||
|
||||
.PHONY: build_binary_native_image
|
||||
build_binary_native_image:
|
||||
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
|
||||
cat ./dockerfiles/Dockerfile.binary-native | docker build -t $(BINARY_NATIVE_IMAGE_NAME) -
|
||||
cat ./dockerfiles/Dockerfile.binary-native | docker build --build-arg=GO_VERSION -t $(BINARY_NATIVE_IMAGE_NAME) -
|
||||
|
||||
.PHONY: build_e2e_image
|
||||
build_e2e_image:
|
||||
docker build -t $(E2E_IMAGE_NAME) --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e .
|
||||
docker build -t $(E2E_IMAGE_NAME) --build-arg=GO_VERSION --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e .
|
||||
|
||||
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
|
||||
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
FROM golang:1.12.5-alpine
|
||||
ARG GO_VERSION=1.12.12
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine
|
||||
|
||||
RUN apk add -U git bash coreutils gcc musl-dev
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
FROM dockercore/golang-cross:1.12.5
|
||||
ARG GO_VERSION=1.12.12
|
||||
|
||||
FROM dockercore/golang-cross:${GO_VERSION}
|
||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||
WORKDIR /go/src/github.com/docker/cli
|
||||
COPY . .
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
FROM golang:1.12.5-alpine
|
||||
ARG GO_VERSION=1.12.12
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine
|
||||
|
||||
RUN apk add -U git make bash coreutils ca-certificates curl
|
||||
|
||||
ARG VNDR_SHA=1fc68ee0c852556a9ed53cbde16247033f104111
|
||||
ARG VNDR_SHA=b177b583eb9d44bd5abfca3083a4aeb971b75861
|
||||
RUN go get -d github.com/LK4D4/vndr && \
|
||||
cd /go/src/github.com/LK4D4/vndr && \
|
||||
git checkout -q "$VNDR_SHA" && \
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
ARG GO_VERSION=1.12.5
|
||||
|
||||
FROM docker/containerd-shim-process:a4d1531 AS containerd-shim-process
|
||||
ARG GO_VERSION=1.12.12
|
||||
|
||||
# Use Debian based image as docker-compose requires glibc.
|
||||
FROM golang:${GO_VERSION}
|
||||
@@ -9,10 +7,6 @@ RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
openssl \
|
||||
btrfs-tools \
|
||||
libapparmor-dev \
|
||||
libseccomp-dev \
|
||||
iptables \
|
||||
openssh-client \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
FROM golang:1.12.5-alpine
|
||||
ARG GO_VERSION=1.12.12
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine
|
||||
|
||||
RUN apk add -U git
|
||||
|
||||
|
||||
@@ -157,10 +157,12 @@ be UPPERCASE to distinguish them from arguments more easily.
|
||||
|
||||
|
||||
Docker runs instructions in a `Dockerfile` in order. A `Dockerfile` **must
|
||||
start with a \`FROM\` instruction**. The `FROM` instruction specifies the [*Base
|
||||
Image*](glossary.md#base-image) from which you are building. `FROM` may only be
|
||||
preceded by one or more `ARG` instructions, which declare arguments that are used
|
||||
in `FROM` lines in the `Dockerfile`.
|
||||
begin with a \`FROM\` instruction**. This may be after [parser
|
||||
directives](#parser-directives), [comments](#format), and globally scoped
|
||||
[ARGs](#arg). The `FROM` instruction specifies the [*Parent
|
||||
Image*](glossary.md#parent-image) from which you are building. `FROM`
|
||||
may only be preceded by one or more `ARG` instructions, which declare arguments
|
||||
that are used in `FROM` lines in the `Dockerfile`.
|
||||
|
||||
Docker treats lines that *begin* with `#` as a comment, unless the line is
|
||||
a valid [parser directive](#parser-directives). A `#` marker anywhere
|
||||
@@ -1720,8 +1722,8 @@ The following `ARG` variables are set automatically:
|
||||
* `TARGETVARIANT` - variant component of TARGETPLATFORM
|
||||
* `BUILDPLATFORM` - platform of the node performing the build.
|
||||
* `BUILDOS` - OS component of BUILDPLATFORM
|
||||
* `BUILDARCH` - OS component of BUILDPLATFORM
|
||||
* `BUILDVARIANT` - OS component of BUILDPLATFORM
|
||||
* `BUILDARCH` - architecture component of BUILDPLATFORM
|
||||
* `BUILDVARIANT` - variant component of BUILDPLATFORM
|
||||
|
||||
These arguments are defined in the global scope so are not automatically
|
||||
available inside build stages or for your `RUN` commands. To expose one of
|
||||
|
||||
@@ -54,7 +54,7 @@ each `docker` command with `sudo`. To avoid having to use `sudo` with the
|
||||
For more information about installing Docker or `sudo` configuration, refer to
|
||||
the [installation](https://docs.docker.com/install/) instructions for your operating system.
|
||||
|
||||
### Environment variables
|
||||
## Environment variables
|
||||
|
||||
For easy reference, the following list of environment variables are supported
|
||||
by the `docker` command line:
|
||||
@@ -96,28 +96,43 @@ variables.
|
||||
### Configuration files
|
||||
|
||||
By default, the Docker command line stores its configuration files in a
|
||||
directory called `.docker` within your `$HOME` directory. However, you can
|
||||
specify a different location via the `DOCKER_CONFIG` environment variable
|
||||
or the `--config` command line option. If both are specified, then the
|
||||
`--config` option overrides the `DOCKER_CONFIG` environment variable.
|
||||
For example:
|
||||
|
||||
docker --config ~/testconfigs/ ps
|
||||
|
||||
Instructs Docker to use the configuration files in your `~/testconfigs/`
|
||||
directory when running the `ps` command.
|
||||
directory called `.docker` within your `$HOME` directory.
|
||||
|
||||
Docker manages most of the files in the configuration directory
|
||||
and you should not modify them. However, you *can modify* the
|
||||
and you should not modify them. However, you *can* modify the
|
||||
`config.json` file to control certain aspects of how the `docker`
|
||||
command behaves.
|
||||
|
||||
Currently, you can modify the `docker` command behavior using environment
|
||||
You can modify the `docker` command behavior using environment
|
||||
variables or command-line options. You can also use options within
|
||||
`config.json` to modify some of the same behavior. When using these
|
||||
mechanisms, you must keep in mind the order of precedence among them. Command
|
||||
line options override environment variables and environment variables override
|
||||
properties you specify in a `config.json` file.
|
||||
`config.json` to modify some of the same behavior. If an environment variable
|
||||
and the `--config` flag are set, the flag takes precedent over the environment
|
||||
variable. Command line options override environment variables and environment
|
||||
variables override properties you specify in a `config.json` file.
|
||||
|
||||
|
||||
### Change the `.docker` directory
|
||||
|
||||
To specify a different directory, use the `DOCKER_CONFIG`
|
||||
environment variable or the `--config` command line option. If both are
|
||||
specified, then the `--config` option overrides the `DOCKER_CONFIG` environment
|
||||
variable. The example below overrides the `docker ps` command using a
|
||||
`config.json` file located in the `~/testconfigs/` directory.
|
||||
|
||||
```bash
|
||||
$ docker --config ~/testconfigs/ ps
|
||||
```
|
||||
|
||||
This flag only applies to whatever command is being ran. For persistent
|
||||
configuration, you can set the `DOCKER_CONFIG` environment variable in your
|
||||
shell (e.g. `~/.profile` or `~/.bashrc`). The example below sets the new
|
||||
directory to be `HOME/newdir/.docker`.
|
||||
|
||||
```bash
|
||||
echo export DOCKER_CONFIG=$HOME/newdir/.docker > ~/.profile
|
||||
```
|
||||
|
||||
### `config.json` properties
|
||||
|
||||
The `config.json` file stores a JSON encoding of several properties:
|
||||
|
||||
@@ -265,6 +280,31 @@ Following is a sample `config.json` file:
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Experimental features
|
||||
|
||||
Experimental features provide early access to future product functionality.
|
||||
These features are intended only for testing and feedback as they may change
|
||||
between releases without warning or can be removed entirely from a future
|
||||
release.
|
||||
|
||||
> Experimental features must not be used in production environments.
|
||||
{: .warning }
|
||||
|
||||
To enable experimental features, edit the `config.json` file and set
|
||||
`experimental` to `enabled`. The example below enables experimental features
|
||||
in a `config.json` file that already enables a debug feature.
|
||||
|
||||
```json
|
||||
{
|
||||
"experimental": "enabled",
|
||||
"debug": true
|
||||
}
|
||||
```
|
||||
|
||||
You can also enable experimental features from the Docker Desktop menu. See the
|
||||
[Docker Desktop Getting Started page](https://docs.docker.com/docker-for-mac#experimental-features)
|
||||
for more information.
|
||||
|
||||
### Notary
|
||||
|
||||
If using your own notary server and a self-signed certificate or an internal
|
||||
|
||||
@@ -31,7 +31,12 @@ Options:
|
||||
## Description
|
||||
|
||||
Use `docker events` to get real-time events from the server. These events differ
|
||||
per Docker object type.
|
||||
per Docker object type. Different event types have different scopes. Local
|
||||
scoped events are only seen on the node they take place on, and swarm scoped
|
||||
events are seen on all managers.
|
||||
|
||||
Only the last 1000 log events are returned. You can use filters to further limit
|
||||
the number of events returned.
|
||||
|
||||
### Object types
|
||||
|
||||
@@ -160,6 +165,9 @@ that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
|
||||
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
||||
fraction of a second no more than nine digits long.
|
||||
|
||||
Only the last 1000 log events are returned. You can use filters to further limit
|
||||
the number of events returned.
|
||||
|
||||
#### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If you would
|
||||
|
||||
@@ -27,14 +27,14 @@ Options:
|
||||
## Description
|
||||
|
||||
The `docker pause` command suspends all processes in the specified containers.
|
||||
On Linux, this uses the cgroups freezer. Traditionally, when suspending a process
|
||||
On Linux, this uses the freezer cgroup. Traditionally, when suspending a process
|
||||
the `SIGSTOP` signal is used, which is observable by the process being suspended.
|
||||
With the cgroups freezer the process is unaware, and unable to capture,
|
||||
With the freezer cgroup the process is unaware, and unable to capture,
|
||||
that it is being suspended, and subsequently resumed. On Windows, only Hyper-V
|
||||
containers can be paused.
|
||||
|
||||
See the
|
||||
[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt)
|
||||
[freezer cgroup documentation](https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt)
|
||||
for further details.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -75,6 +75,22 @@ $ docker ps -a
|
||||
container that exposes TCP ports `100, 101, 102` displays `100-102/tcp` in
|
||||
the `PORTS` column.
|
||||
|
||||
### Show disk usage by container
|
||||
|
||||
The `docker ps -s` command displays two different on-disk-sizes for each container:
|
||||
|
||||
```bash
|
||||
$ docker ps -s
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE SIZE
|
||||
e90b8831a4b8 nginx "/bin/bash -c 'mkdir " 11 weeks ago Up 4 hours my_nginx 35.58 kB (virtual 109.2 MB)
|
||||
00c6131c5e30 telegraf:1.5 "/entrypoint.sh" 11 weeks ago Up 11 weeks my_telegraf 0 B (virtual 209.5 MB)
|
||||
```
|
||||
* The "size" information shows the amount of data (on disk) that is used for the _writable_ layer of each container
|
||||
* The "virtual size" is the total amount of disk-space used for the read-only _image_ data used by the container and the writable layer.
|
||||
|
||||
For more information, refer to the [container size on disk](https://docs.docker.com/storage/storagedriver/#container-size-on-disk) section.
|
||||
|
||||
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
|
||||
@@ -431,4 +447,4 @@ a87ecb4f327c com.docker.swarm.node=ubuntu,com.docker.swarm.storage=ssd
|
||||
01946d9d34d8
|
||||
c1d3b0166030 com.docker.swarm.node=debian,com.docker.swarm.cpu=6
|
||||
41d50ecd2f57 com.docker.swarm.node=fedora,com.docker.swarm.cpu=3,com.docker.swarm.storage=ssd
|
||||
```
|
||||
```
|
||||
|
||||
@@ -605,6 +605,33 @@ PS C:\> docker run --device=class/86E0D1E0-8089-11D0-9CE4-08003E301F73 mcr.micro
|
||||
> Windows containers. This option fails if the container isolation is `hyperv`
|
||||
> or when running Linux Containers on Windows (LCOW).
|
||||
|
||||
### Access an NVIDIA GPU
|
||||
|
||||
The `--gpus` flag allows you to access NVIDIA GPU resources. First you need to
|
||||
install [nvidia-container-runtime](https://nvidia.github.io/nvidia-container-runtime/).
|
||||
Visit [Specify a container's resources](https://docs.docker.com/config/containers/resource_constraints/)
|
||||
for more information.
|
||||
|
||||
To use `--gpus`, specify which GPUs (or all) to use. If no value is provied, all
|
||||
available GPUs are used. The example below exposes all available GPUs.
|
||||
|
||||
```bash
|
||||
$ docker run -it --rm --gpus all ubuntu nvidia-smi
|
||||
```
|
||||
|
||||
Use the `device` option to specify GPUs. The example below exposes a specific
|
||||
GPU.
|
||||
|
||||
```bash
|
||||
$ docker run -it --rm --gpus device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a ubuntu nvidia-smi
|
||||
```
|
||||
|
||||
The example below exposes the first and third GPUs.
|
||||
|
||||
```bash
|
||||
$ docker run -it --rm --gpus device=0,2 nvidia-smi
|
||||
```
|
||||
|
||||
### Restart policies (--restart)
|
||||
|
||||
Use Docker's `--restart` to specify a container's *restart policy*. A restart
|
||||
|
||||
@@ -83,7 +83,7 @@ This example displays images with a name containing 'busybox',
|
||||
at least 3 stars and the description isn't truncated in the output:
|
||||
|
||||
```bash
|
||||
$ docker search --stars=3 --no-trunc busybox
|
||||
$ docker search --filter=stars=3 --no-trunc busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 325 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
|
||||
@@ -27,10 +27,10 @@ Options:
|
||||
## Description
|
||||
|
||||
The `docker unpause` command un-suspends all processes in the specified containers.
|
||||
On Linux, it does this using the cgroups freezer.
|
||||
On Linux, it does this using the freezer cgroup.
|
||||
|
||||
See the
|
||||
[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt)
|
||||
[freezer cgroup documentation](https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt)
|
||||
for further details.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -5,9 +5,11 @@ services:
|
||||
image: 'registry:2'
|
||||
|
||||
engine:
|
||||
image: 'docker:${TEST_ENGINE_VERSION:-edge-dind}'
|
||||
image: 'docker:${TEST_ENGINE_VERSION:-stable-dind}'
|
||||
privileged: true
|
||||
command: ['--insecure-registry=registry:5000']
|
||||
environment:
|
||||
- DOCKER_TLS_CERTDIR=
|
||||
|
||||
notary-server:
|
||||
build:
|
||||
|
||||
@@ -169,6 +169,12 @@ func (c *FakeCli) ErrBuffer() *bytes.Buffer {
|
||||
return c.err
|
||||
}
|
||||
|
||||
// ResetOutputBuffers resets the .OutBuffer() and.ErrBuffer() back to empty
|
||||
func (c *FakeCli) ResetOutputBuffers() {
|
||||
c.outBuffer.Reset()
|
||||
c.err.Reset()
|
||||
}
|
||||
|
||||
// SetNotaryClient sets the internal getter for retrieving a NotaryClient
|
||||
func (c *FakeCli) SetNotaryClient(notaryClientFunc NotaryClientFuncType) {
|
||||
c.notaryClientFunc = notaryClientFunc
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
The `docker container pause` command suspends all processes in the specified containers.
|
||||
On Linux, this uses the cgroups freezer. Traditionally, when suspending a process
|
||||
On Linux, this uses the freezer cgroup. Traditionally, when suspending a process
|
||||
the `SIGSTOP` signal is used, which is observable by the process being suspended.
|
||||
With the cgroups freezer the process is unaware, and unable to capture,
|
||||
With the freezer cgroup the process is unaware, and unable to capture,
|
||||
that it is being suspended, and subsequently resumed. On Windows, only Hyper-V
|
||||
containers can be paused.
|
||||
|
||||
See the [cgroups freezer documentation]
|
||||
See the [freezer cgroup documentation]
|
||||
(https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt) for
|
||||
further details.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
The `docker container unpause` command un-suspends all processes in a container.
|
||||
On Linux, it does this using the cgroups freezer.
|
||||
On Linux, it does this using the freezer cgroup.
|
||||
|
||||
See the [cgroups freezer documentation]
|
||||
See the [freezer cgroup documentation]
|
||||
(https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt) for
|
||||
further details.
|
||||
|
||||
+6
-6
@@ -53,8 +53,8 @@ func TestParseHost(t *testing.T) {
|
||||
func TestParseDockerDaemonHost(t *testing.T) {
|
||||
invalids := map[string]string{
|
||||
|
||||
"tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
|
||||
"tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
|
||||
"tcp:a.b.c.d": "",
|
||||
"tcp:a.b.c.d/path": "",
|
||||
"udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1",
|
||||
"udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375",
|
||||
"tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock",
|
||||
@@ -83,7 +83,7 @@ func TestParseDockerDaemonHost(t *testing.T) {
|
||||
"localhost:5555/path": "tcp://localhost:5555/path",
|
||||
}
|
||||
for invalidAddr, expectedError := range invalids {
|
||||
if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || err.Error() != expectedError {
|
||||
if addr, err := parseDockerDaemonHost(invalidAddr); err == nil || expectedError != "" && err.Error() != expectedError {
|
||||
t.Errorf("tcp %v address expected error %q return, got %q and addr %v", invalidAddr, expectedError, err, addr)
|
||||
}
|
||||
}
|
||||
@@ -99,8 +99,8 @@ func TestParseTCP(t *testing.T) {
|
||||
defaultHTTPHost = "tcp://127.0.0.1:2376"
|
||||
)
|
||||
invalids := map[string]string{
|
||||
"tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
|
||||
"tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
|
||||
"tcp:a.b.c.d": "",
|
||||
"tcp:a.b.c.d/path": "",
|
||||
"udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1",
|
||||
"udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375",
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func TestParseTCP(t *testing.T) {
|
||||
"localhost:5555/path": "tcp://localhost:5555/path",
|
||||
}
|
||||
for invalidAddr, expectedError := range invalids {
|
||||
if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || err.Error() != expectedError {
|
||||
if addr, err := ParseTCPAddr(invalidAddr, defaultHTTPHost); err == nil || expectedError != "" && err.Error() != expectedError {
|
||||
t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -16,7 +16,7 @@ github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae
|
||||
github.com/docker/compose-on-kubernetes cc4914dfd1b6684a9750a59f3613fc0a95291824 # v0.4.23
|
||||
github.com/docker/distribution 0d3efadf0154c2b8a4e7b6621fff9809655cc580
|
||||
github.com/docker/docker a004854097417a591c3f6a3aeaab75efae3c5814 https://github.com/docker/engine.git # 19.03 branch
|
||||
github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962
|
||||
github.com/docker/docker-credential-helpers 54f0238b6bf101fc3ad3b34114cb5520beb562f5 # v0.6.3
|
||||
github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 # Contains a customized version of canonical/json and is used by Notary. The package is periodically rebased on current Go versions.
|
||||
github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0
|
||||
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
|
||||
@@ -50,9 +50,9 @@ github.com/mattn/go-shellwords a72fbe27a1b0ed0df2f027549450
|
||||
github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c # v1.0.1
|
||||
github.com/Microsoft/go-winio 84b4ab48a50763fe7b3abcef38e5205c12027fac
|
||||
github.com/Microsoft/hcsshim 672e52e9209d1e53718c1b6a7d68cc9272654ab5
|
||||
github.com/miekg/pkcs11 6120d95c0e9576ccf4a78ba40855809dca31a9ed
|
||||
github.com/miekg/pkcs11 cb39313ec884f2cd77f4762875fe96aecf68f8e3 # v1.0.2
|
||||
github.com/mitchellh/mapstructure f15292f7a699fcc1a38a80977f80a046874ba8ac
|
||||
github.com/moby/buildkit f238f1efb04f00bf0cc147141fda9ddb55c8bc49
|
||||
github.com/moby/buildkit ae10b292fefb00e0fbf9fecd1419c5f252e58895
|
||||
github.com/modern-go/concurrent bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94 # 1.0.3
|
||||
github.com/modern-go/reflect2 4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd # 1.0.1
|
||||
github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b
|
||||
@@ -73,7 +73,7 @@ github.com/spf13/cobra ef82de70bb3f60c65fb8eebacbb2
|
||||
github.com/spf13/pflag 4cb166e4f25ac4e8016a3595bbf7ea2e9aa85a2c https://github.com/thaJeztah/pflag.git # temporary fork with https://github.com/spf13/pflag/pull/170 applied, which isn't merged yet upstream
|
||||
github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2
|
||||
github.com/theupdateframework/notary d6e1431feb32348e0650bf7551ac5cffd01d857b # v0.6.1
|
||||
github.com/tonistiigi/fsutil 3bbb99cdbd76619ab717299830c60f6f2a533a6b
|
||||
github.com/tonistiigi/fsutil 3d2716dd0a4d06ff854241c7e8b6f3f904e1719f
|
||||
github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2
|
||||
github.com/xeipuuv/gojsonpointer 4e3ac2762d5f479393488629ee9370b50873b3a6
|
||||
github.com/xeipuuv/gojsonreference bd5ef7bd5415a7ac448318e64f11a24cd21e594b
|
||||
@@ -88,7 +88,7 @@ golang.org/x/time fbb02b2291d28baffd63558aa44b
|
||||
google.golang.org/genproto 02b4e95473316948020af0b7a4f0f22c73929b0e
|
||||
google.golang.org/grpc 25c4f928eaa6d96443009bd842389fb4fa48664e # v1.20.1
|
||||
gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1
|
||||
gopkg.in/yaml.v2 5420a8b6744d3b0345ab293f6fcba19c978f1183 # v2.2.1
|
||||
gopkg.in/yaml.v2 bb4e33bf68bf89cad44d386192cbed201f35b241 # v2.2.3
|
||||
gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0
|
||||
k8s.io/api 40a48860b5abbba9aa891b02b32da429b08d96a0 # kubernetes-1.14.0
|
||||
k8s.io/apimachinery d7deff9243b165ee192f5551710ea4285dcfd615 # kubernetes-1.14.0
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ The programs in this repository are written with the Go programming language. Th
|
||||
$ go get github.com/docker/docker-credential-helpers
|
||||
```
|
||||
|
||||
2 - Use `make` to build the program you want. That will leave any executable in the `bin` directory inside the repository.
|
||||
2 - Use `make` to build the program you want. That will leave an executable in the `bin` directory inside the repository.
|
||||
|
||||
```
|
||||
$ cd $GOPATH/docker/docker-credentials-helpers
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package credentials
|
||||
|
||||
// Version holds a string describing the current version
|
||||
const Version = "0.6.0"
|
||||
const Version = "0.6.3"
|
||||
|
||||
Generated
Vendored
-1
@@ -224,5 +224,4 @@ void freeListData(char *** data, unsigned int length) {
|
||||
for(int i=0; i<length; i++) {
|
||||
free((*data)[i]);
|
||||
}
|
||||
free(*data);
|
||||
}
|
||||
|
||||
Generated
Vendored
+12
-39
@@ -1,8 +1,8 @@
|
||||
package osxkeychain
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -x objective-c -mmacosx-version-min=10.10
|
||||
#cgo LDFLAGS: -framework Security -framework Foundation -mmacosx-version-min=10.10
|
||||
#cgo CFLAGS: -x objective-c -mmacosx-version-min=10.11
|
||||
#cgo LDFLAGS: -framework Security -framework Foundation -mmacosx-version-min=10.11
|
||||
|
||||
#include "osxkeychain_darwin.h"
|
||||
#include <stdlib.h>
|
||||
@@ -10,12 +10,11 @@ package osxkeychain
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/docker/docker-credential-helpers/credentials"
|
||||
"github.com/docker/docker-credential-helpers/registryurl"
|
||||
)
|
||||
|
||||
// errCredentialsNotFound is the specific error message returned by OS X
|
||||
@@ -110,15 +109,18 @@ func (h Osxkeychain) List() (map[string]string, error) {
|
||||
defer C.free(unsafe.Pointer(acctsC))
|
||||
var listLenC C.uint
|
||||
errMsg := C.keychain_list(credsLabelC, &pathsC, &acctsC, &listLenC)
|
||||
defer C.freeListData(&pathsC, listLenC)
|
||||
defer C.freeListData(&acctsC, listLenC)
|
||||
if errMsg != nil {
|
||||
defer C.free(unsafe.Pointer(errMsg))
|
||||
goMsg := C.GoString(errMsg)
|
||||
if goMsg == errCredentialsNotFound {
|
||||
return make(map[string]string), nil
|
||||
}
|
||||
|
||||
return nil, errors.New(goMsg)
|
||||
}
|
||||
|
||||
defer C.freeListData(&pathsC, listLenC)
|
||||
defer C.freeListData(&acctsC, listLenC)
|
||||
|
||||
var listLen int
|
||||
listLen = int(listLenC)
|
||||
pathTmp := (*[1 << 30]*C.char)(unsafe.Pointer(pathsC))[:listLen:listLen]
|
||||
@@ -135,7 +137,7 @@ func (h Osxkeychain) List() (map[string]string, error) {
|
||||
}
|
||||
|
||||
func splitServer(serverURL string) (*C.struct_Server, error) {
|
||||
u, err := parseURL(serverURL)
|
||||
u, err := registryurl.Parse(serverURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -145,7 +147,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {
|
||||
proto = C.kSecProtocolTypeHTTP
|
||||
}
|
||||
var port int
|
||||
p := getPort(u)
|
||||
p := registryurl.GetPort(u)
|
||||
if p != "" {
|
||||
port, err = strconv.Atoi(p)
|
||||
if err != nil {
|
||||
@@ -155,7 +157,7 @@ func splitServer(serverURL string) (*C.struct_Server, error) {
|
||||
|
||||
return &C.struct_Server{
|
||||
proto: C.SecProtocolType(proto),
|
||||
host: C.CString(getHostname(u)),
|
||||
host: C.CString(registryurl.GetHostname(u)),
|
||||
port: C.uint(port),
|
||||
path: C.CString(u.Path),
|
||||
}, nil
|
||||
@@ -165,32 +167,3 @@ func freeServer(s *C.struct_Server) {
|
||||
C.free(unsafe.Pointer(s.host))
|
||||
C.free(unsafe.Pointer(s.path))
|
||||
}
|
||||
|
||||
// parseURL parses and validates a given serverURL to an url.URL, and
|
||||
// returns an error if validation failed. Querystring parameters are
|
||||
// omitted in the resulting URL, because they are not used in the helper.
|
||||
//
|
||||
// If serverURL does not have a valid scheme, `//` is used as scheme
|
||||
// before parsing. This prevents the hostname being used as path,
|
||||
// and the credentials being stored without host.
|
||||
func parseURL(serverURL string) (*url.URL, error) {
|
||||
// Check if serverURL has a scheme, otherwise add `//` as scheme.
|
||||
if !strings.Contains(serverURL, "://") && !strings.HasPrefix(serverURL, "//") {
|
||||
serverURL = "//" + serverURL
|
||||
}
|
||||
|
||||
u, err := url.Parse(serverURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if u.Scheme != "" && u.Scheme != "https" && u.Scheme != "http" {
|
||||
return nil, errors.New("unsupported scheme: " + u.Scheme)
|
||||
}
|
||||
if getHostname(u) == "" {
|
||||
return nil, errors.New("no hostname in URL")
|
||||
}
|
||||
|
||||
u.RawQuery = ""
|
||||
return u, nil
|
||||
}
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
//+build go1.8
|
||||
|
||||
package osxkeychain
|
||||
|
||||
import "net/url"
|
||||
|
||||
func getHostname(u *url.URL) string {
|
||||
return u.Hostname()
|
||||
}
|
||||
|
||||
func getPort(u *url.URL) string {
|
||||
return u.Port()
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
//+build !go1.8
|
||||
|
||||
package osxkeychain
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func getHostname(u *url.URL) string {
|
||||
return stripPort(u.Host)
|
||||
}
|
||||
|
||||
func getPort(u *url.URL) string {
|
||||
return portOnly(u.Host)
|
||||
}
|
||||
|
||||
func stripPort(hostport string) string {
|
||||
colon := strings.IndexByte(hostport, ':')
|
||||
if colon == -1 {
|
||||
return hostport
|
||||
}
|
||||
if i := strings.IndexByte(hostport, ']'); i != -1 {
|
||||
return strings.TrimPrefix(hostport[:i], "[")
|
||||
}
|
||||
return hostport[:colon]
|
||||
}
|
||||
|
||||
func portOnly(hostport string) string {
|
||||
colon := strings.IndexByte(hostport, ':')
|
||||
if colon == -1 {
|
||||
return ""
|
||||
}
|
||||
if i := strings.Index(hostport, "]:"); i != -1 {
|
||||
return hostport[i+len("]:"):]
|
||||
}
|
||||
if strings.Contains(hostport, "]") {
|
||||
return ""
|
||||
}
|
||||
return hostport[colon+len(":"):]
|
||||
}
|
||||
Generated
Vendored
-1
@@ -158,5 +158,4 @@ void freeListData(char *** data, unsigned int length) {
|
||||
for(i=0; i<length; i++) {
|
||||
free((*data)[i]);
|
||||
}
|
||||
free(*data);
|
||||
}
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -92,12 +92,12 @@ func (h Secretservice) List() (map[string]string, error) {
|
||||
defer C.free(unsafe.Pointer(acctsC))
|
||||
var listLenC C.uint
|
||||
err := C.list(credsLabelC, &pathsC, &acctsC, &listLenC)
|
||||
if err != nil {
|
||||
defer C.free(unsafe.Pointer(err))
|
||||
return nil, errors.New("Error from list function in secretservice_linux.c likely due to error in secretservice library")
|
||||
}
|
||||
defer C.freeListData(&pathsC, listLenC)
|
||||
defer C.freeListData(&acctsC, listLenC)
|
||||
if err != nil {
|
||||
defer C.g_error_free(err)
|
||||
return nil, errors.New("Error from list function in secretservice_linux.c likely due to error in secretservice library")
|
||||
}
|
||||
|
||||
resp := make(map[string]string)
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module github.com/gogo/googleapis
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/gogo/protobuf v1.2.1
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module github.com/gogo/protobuf
|
||||
|
||||
require github.com/kisielk/errcheck v1.1.0 // indirect
|
||||
+1
@@ -0,0 +1 @@
|
||||
module github.com/google/uuid
|
||||
+1
@@ -0,0 +1 @@
|
||||
module github.com/gorilla/mux
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module github.com/jaguilar/vt100
|
||||
|
||||
go 1.12
|
||||
|
||||
require github.com/stretchr/testify v1.3.0
|
||||
+1
@@ -0,0 +1 @@
|
||||
module github.com/konsorten/go-windows-terminal-sequences
|
||||
+1
@@ -0,0 +1 @@
|
||||
module github.com/mattn/go-shellwords
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module github.com/miekg/pkcs11
|
||||
|
||||
go 1.12
|
||||
+14
-12
@@ -42,19 +42,21 @@ type GCMParams struct {
|
||||
// NewGCMParams returns a pointer to AES-GCM parameters that can be used with the CKM_AES_GCM mechanism.
|
||||
// The Free() method must be called after the operation is complete.
|
||||
//
|
||||
// *NOTE*
|
||||
// Some HSMs, like CloudHSM, will ignore the IV you pass in and write their
|
||||
// Note that some HSMs, like CloudHSM, will ignore the IV you pass in and write their
|
||||
// own. As a result, to support all libraries, memory is not freed
|
||||
// automatically, so that after the EncryptInit/Encrypt operation the HSM's IV
|
||||
// can be read back out. It is up to the caller to ensure that Free() is called
|
||||
// on the GCMParams object at an appropriate time, which is after
|
||||
//
|
||||
// Encrypt/Decrypt. As an example:
|
||||
//
|
||||
// gcmParams := pkcs11.NewGCMParams(make([]byte, 12), nil, 128)
|
||||
// p.ctx.EncryptInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_AES_GCM, gcmParams)}, aesObjHandle)
|
||||
// ct, _ := p.ctx.Encrypt(session, pt)
|
||||
// iv := gcmParams.IV()
|
||||
// gcmParams.Free()
|
||||
// gcmParams := pkcs11.NewGCMParams(make([]byte, 12), nil, 128)
|
||||
// p.ctx.EncryptInit(session, []*pkcs11.Mechanism{pkcs11.NewMechanism(pkcs11.CKM_AES_GCM, gcmParams)},
|
||||
// aesObjHandle)
|
||||
// ct, _ := p.ctx.Encrypt(session, pt)
|
||||
// iv := gcmParams.IV()
|
||||
// gcmParams.Free()
|
||||
//
|
||||
func NewGCMParams(iv, aad []byte, tagSize int) *GCMParams {
|
||||
return &GCMParams{
|
||||
iv: iv,
|
||||
@@ -112,7 +114,7 @@ func (p *GCMParams) Free() {
|
||||
p.arena = nil
|
||||
}
|
||||
|
||||
// NewPSSParams creates a CK_RSA_PKCS_PSS_PARAMS structure and returns it as a byte array for use with the CKM_RSA_PKCS_PSS mechanism
|
||||
// NewPSSParams creates a CK_RSA_PKCS_PSS_PARAMS structure and returns it as a byte array for use with the CKM_RSA_PKCS_PSS mechanism.
|
||||
func NewPSSParams(hashAlg, mgf, saltLength uint) []byte {
|
||||
p := C.CK_RSA_PKCS_PSS_PARAMS{
|
||||
hashAlg: C.CK_MECHANISM_TYPE(hashAlg),
|
||||
@@ -122,7 +124,7 @@ func NewPSSParams(hashAlg, mgf, saltLength uint) []byte {
|
||||
return C.GoBytes(unsafe.Pointer(&p), C.int(unsafe.Sizeof(p)))
|
||||
}
|
||||
|
||||
// OAEPParams can be passed to NewMechanism to implement CKM_RSA_PKCS_OAEP
|
||||
// OAEPParams can be passed to NewMechanism to implement CKM_RSA_PKCS_OAEP.
|
||||
type OAEPParams struct {
|
||||
HashAlg uint
|
||||
MGF uint
|
||||
@@ -130,7 +132,7 @@ type OAEPParams struct {
|
||||
SourceData []byte
|
||||
}
|
||||
|
||||
// NewOAEPParams creates a CK_RSA_PKCS_OAEP_PARAMS structure suitable for use with the CKM_RSA_PKCS_OAEP mechanism
|
||||
// NewOAEPParams creates a CK_RSA_PKCS_OAEP_PARAMS structure suitable for use with the CKM_RSA_PKCS_OAEP mechanism.
|
||||
func NewOAEPParams(hashAlg, mgf, sourceType uint, sourceData []byte) *OAEPParams {
|
||||
return &OAEPParams{
|
||||
HashAlg: hashAlg,
|
||||
@@ -154,14 +156,14 @@ func cOAEPParams(p *OAEPParams, arena arena) ([]byte, arena) {
|
||||
return C.GoBytes(unsafe.Pointer(¶ms), C.int(unsafe.Sizeof(params))), arena
|
||||
}
|
||||
|
||||
// ECDH1DeriveParams can be passed to NewMechanism to implement CK_ECDH1_DERIVE_PARAMS
|
||||
// ECDH1DeriveParams can be passed to NewMechanism to implement CK_ECDH1_DERIVE_PARAMS.
|
||||
type ECDH1DeriveParams struct {
|
||||
KDF uint
|
||||
SharedData []byte
|
||||
PublicKeyData []byte
|
||||
}
|
||||
|
||||
// NewECDH1DeriveParams creates a CK_ECDH1_DERIVE_PARAMS structure suitable for use with the CKM_ECDH1_DERIVE mechanism
|
||||
// NewECDH1DeriveParams creates a CK_ECDH1_DERIVE_PARAMS structure suitable for use with the CKM_ECDH1_DERIVE mechanism.
|
||||
func NewECDH1DeriveParams(kdf uint, sharedData []byte, publicKeyData []byte) *ECDH1DeriveParams {
|
||||
return &ECDH1DeriveParams{
|
||||
KDF: kdf,
|
||||
|
||||
+7
-7
@@ -800,13 +800,13 @@ func (c *Ctx) Destroy() {
|
||||
c.ctx = nil
|
||||
}
|
||||
|
||||
// Initialize initializes the Cryptoki library. */
|
||||
// Initialize initializes the Cryptoki library.
|
||||
func (c *Ctx) Initialize() error {
|
||||
e := C.Initialize(c.ctx)
|
||||
return toError(e)
|
||||
}
|
||||
|
||||
// Finalize indicates that an application is done with the Cryptoki library. */
|
||||
// Finalize indicates that an application is done with the Cryptoki library.
|
||||
func (c *Ctx) Finalize() error {
|
||||
if c.ctx == nil {
|
||||
return toError(CKR_CRYPTOKI_NOT_INITIALIZED)
|
||||
@@ -815,7 +815,7 @@ func (c *Ctx) Finalize() error {
|
||||
return toError(e)
|
||||
}
|
||||
|
||||
// GetInfo returns general information about Cryptoki. */
|
||||
// GetInfo returns general information about Cryptoki.
|
||||
func (c *Ctx) GetInfo() (Info, error) {
|
||||
var p C.ckInfo
|
||||
e := C.GetInfo(c.ctx, &p)
|
||||
@@ -829,7 +829,7 @@ func (c *Ctx) GetInfo() (Info, error) {
|
||||
return i, toError(e)
|
||||
}
|
||||
|
||||
// GetSlotList obtains a list of slots in the system. */
|
||||
// GetSlotList obtains a list of slots in the system.
|
||||
func (c *Ctx) GetSlotList(tokenPresent bool) ([]uint, error) {
|
||||
var (
|
||||
slotList C.CK_ULONG_PTR
|
||||
@@ -843,7 +843,7 @@ func (c *Ctx) GetSlotList(tokenPresent bool) ([]uint, error) {
|
||||
return l, nil
|
||||
}
|
||||
|
||||
// GetSlotInfo obtains information about a particular slot in the system. */
|
||||
// GetSlotInfo obtains information about a particular slot in the system.
|
||||
func (c *Ctx) GetSlotInfo(slotID uint) (SlotInfo, error) {
|
||||
var csi C.CK_SLOT_INFO
|
||||
e := C.GetSlotInfo(c.ctx, C.CK_ULONG(slotID), &csi)
|
||||
@@ -885,7 +885,7 @@ func (c *Ctx) GetTokenInfo(slotID uint) (TokenInfo, error) {
|
||||
return s, toError(e)
|
||||
}
|
||||
|
||||
// GetMechanismList obtains a list of mechanism types supported by a token. */
|
||||
// GetMechanismList obtains a list of mechanism types supported by a token.
|
||||
func (c *Ctx) GetMechanismList(slotID uint) ([]*Mechanism, error) {
|
||||
var (
|
||||
mech C.CK_ULONG_PTR // in pkcs#11 we're all CK_ULONGs \o/
|
||||
@@ -997,11 +997,11 @@ func (c *Ctx) GetOperationState(sh SessionHandle) ([]byte, error) {
|
||||
statelen C.CK_ULONG
|
||||
)
|
||||
e := C.GetOperationState(c.ctx, C.CK_SESSION_HANDLE(sh), &state, &statelen)
|
||||
defer C.free(unsafe.Pointer(state))
|
||||
if toError(e) != nil {
|
||||
return nil, toError(e)
|
||||
}
|
||||
b := C.GoBytes(unsafe.Pointer(state), C.int(statelen))
|
||||
C.free(unsafe.Pointer(state))
|
||||
return b, nil
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// +build release
|
||||
|
||||
package pkcs11
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Release is current version of the pkcs11 library.
|
||||
var Release = R{1, 0, 2}
|
||||
|
||||
// R holds the version of this library.
|
||||
type R struct {
|
||||
Major, Minor, Patch int
|
||||
}
|
||||
|
||||
func (r R) String() string {
|
||||
return fmt.Sprintf("%d.%d.%d", r.Major, r.Minor, r.Patch)
|
||||
}
|
||||
+146
-83
@@ -1,27 +1,25 @@
|
||||
[](https://asciinema.org/a/gPEIEo1NzmDTUu2bEPsUboqmU)
|
||||
|
||||
|
||||
## BuildKit
|
||||
|
||||
[](https://godoc.org/github.com/moby/buildkit/client/llb)
|
||||
[](https://travis-ci.org/moby/buildkit)
|
||||
[](https://goreportcard.com/report/github.com/moby/buildkit)
|
||||
|
||||
|
||||
BuildKit is a toolkit for converting source code to build artifacts in an efficient, expressive and repeatable manner.
|
||||
|
||||
Key features:
|
||||
- Automatic garbage collection
|
||||
- Extendable frontend formats
|
||||
- Concurrent dependency resolution
|
||||
- Efficient instruction caching
|
||||
- Build cache import/export
|
||||
- Nested build job invocations
|
||||
- Distributable workers
|
||||
- Multiple output formats
|
||||
- Pluggable architecture
|
||||
- Execution without root privileges
|
||||
|
||||
- Automatic garbage collection
|
||||
- Extendable frontend formats
|
||||
- Concurrent dependency resolution
|
||||
- Efficient instruction caching
|
||||
- Build cache import/export
|
||||
- Nested build job invocations
|
||||
- Distributable workers
|
||||
- Multiple output formats
|
||||
- Pluggable architecture
|
||||
- Execution without root privileges
|
||||
|
||||
Read the proposal from https://github.com/moby/moby/issues/32925
|
||||
|
||||
@@ -33,20 +31,21 @@ Introductory blog post https://blog.mobyproject.org/introducing-buildkit-17e056c
|
||||
|
||||
BuildKit is used by the following projects:
|
||||
|
||||
- [Moby & Docker](https://github.com/moby/moby/pull/37151)
|
||||
- [img](https://github.com/genuinetools/img)
|
||||
- [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud)
|
||||
- [container build interface](https://github.com/containerbuilding/cbi)
|
||||
- [Knative Build Templates](https://github.com/knative/build-templates)
|
||||
- [vab](https://github.com/stellarproject/vab)
|
||||
- [Rio](https://github.com/rancher/rio) (on roadmap)
|
||||
- [Moby & Docker](https://github.com/moby/moby/pull/37151)
|
||||
- [img](https://github.com/genuinetools/img)
|
||||
- [OpenFaaS Cloud](https://github.com/openfaas/openfaas-cloud)
|
||||
- [container build interface](https://github.com/containerbuilding/cbi)
|
||||
- [Knative Build Templates](https://github.com/knative/build-templates)
|
||||
- [the Sanic build tool](https://github.com/distributed-containers-inc/sanic)
|
||||
- [vab](https://github.com/stellarproject/vab)
|
||||
- [Rio](https://github.com/rancher/rio) (on roadmap)
|
||||
|
||||
### Quick start
|
||||
|
||||
Dependencies:
|
||||
- [runc](https://github.com/opencontainers/runc)
|
||||
- [containerd](https://github.com/containerd/containerd) (if you want to use containerd worker)
|
||||
|
||||
- [runc](https://github.com/opencontainers/runc)
|
||||
- [containerd](https://github.com/containerd/containerd) (if you want to use containerd worker)
|
||||
|
||||
The following command installs `buildkitd` and `buildctl` to `/usr/local/bin`:
|
||||
|
||||
@@ -58,14 +57,13 @@ You can also use `make binaries-all` to prepare `buildkitd.containerd_only` and
|
||||
|
||||
#### Starting the buildkitd daemon:
|
||||
|
||||
```
|
||||
```bash
|
||||
buildkitd --debug --root /var/lib/buildkit
|
||||
```
|
||||
|
||||
The buildkitd daemon supports two worker backends: OCI (runc) and containerd.
|
||||
|
||||
By default, the OCI (runc) worker is used.
|
||||
You can set `--oci-worker=false --containerd-worker=true` to use the containerd worker.
|
||||
By default, the OCI (runc) worker is used. You can set `--oci-worker=false --containerd-worker=true` to use the containerd worker.
|
||||
|
||||
We are open to adding more backends.
|
||||
|
||||
@@ -73,44 +71,46 @@ We are open to adding more backends.
|
||||
|
||||
BuildKit builds are based on a binary intermediate format called LLB that is used for defining the dependency graph for processes running part of your build. tl;dr: LLB is to Dockerfile what LLVM IR is to C.
|
||||
|
||||
- Marshaled as Protobuf messages
|
||||
- Concurrently executable
|
||||
- Efficiently cacheable
|
||||
- Vendor-neutral (i.e. non-Dockerfile languages can be easily implemented)
|
||||
- Marshaled as Protobuf messages
|
||||
- Concurrently executable
|
||||
- Efficiently cacheable
|
||||
- Vendor-neutral (i.e. non-Dockerfile languages can be easily implemented)
|
||||
|
||||
See [`solver/pb/ops.proto`](./solver/pb/ops.proto) for the format definition.
|
||||
|
||||
Currently, following high-level languages has been implemented for LLB:
|
||||
|
||||
- Dockerfile (See [Exploring Dockerfiles](#exploring-dockerfiles))
|
||||
- [Buildpacks](https://github.com/tonistiigi/buildkit-pack)
|
||||
- (open a PR to add your own language)
|
||||
- Dockerfile (See [Exploring Dockerfiles](#exploring-dockerfiles))
|
||||
- [Buildpacks](https://github.com/tonistiigi/buildkit-pack)
|
||||
- (open a PR to add your own language)
|
||||
|
||||
For understanding the basics of LLB, `examples/buildkit*` directory contains scripts that define how to build different configurations of BuildKit itself and its dependencies using the `client` package. Running one of these scripts generates a protobuf definition of a build graph. Note that the script itself does not execute any steps of the build.
|
||||
|
||||
You can use `buildctl debug dump-llb` to see what data is in this definition. Add `--dot` to generate dot layout.
|
||||
|
||||
```bash
|
||||
go run examples/buildkit0/buildkit.go | buildctl debug dump-llb | jq .
|
||||
go run examples/buildkit0/buildkit.go \
|
||||
| buildctl debug dump-llb \
|
||||
| jq .
|
||||
```
|
||||
|
||||
To start building use `buildctl build` command. The example script accepts `--with-containerd` flag to choose if containerd binaries and support should be included in the end result as well.
|
||||
To start building use `buildctl build` command. The example script accepts `--with-containerd` flag to choose if containerd binaries and support should be included in the end result as well.
|
||||
|
||||
```bash
|
||||
go run examples/buildkit0/buildkit.go | buildctl build
|
||||
go run examples/buildkit0/buildkit.go \
|
||||
| buildctl build
|
||||
```
|
||||
|
||||
`buildctl build` will show interactive progress bar by default while the build job is running. If the path to the trace file is specified, the trace file generated will contain all information about the timing of the individual steps and logs.
|
||||
|
||||
Different versions of the example scripts show different ways of describing the build definition for this project to show the capabilities of the library. New versions have been added when new features have become available.
|
||||
|
||||
- `./examples/buildkit0` - uses only exec operations, defines a full stage per component.
|
||||
- `./examples/buildkit1` - cloning git repositories has been separated for extra concurrency.
|
||||
- `./examples/buildkit2` - uses git sources directly instead of running `git clone`, allowing better performance and much safer caching.
|
||||
- `./examples/buildkit3` - allows using local source files for separate components eg. `./buildkit3 --runc=local | buildctl build --local runc-src=some/local/path`
|
||||
- `./examples/dockerfile2llb` - can be used to convert a Dockerfile to LLB for debugging purposes
|
||||
- `./examples/gobuild` - shows how to use nested invocation to generate LLB for Go package internal dependencies
|
||||
|
||||
- `./examples/buildkit0` - uses only exec operations, defines a full stage per component.
|
||||
- `./examples/buildkit1` - cloning git repositories has been separated for extra concurrency.
|
||||
- `./examples/buildkit2` - uses git sources directly instead of running `git clone`, allowing better performance and much safer caching.
|
||||
- `./examples/buildkit3` - allows using local source files for separate components eg. `./buildkit3 --runc=local | buildctl build --local runc-src=some/local/path`
|
||||
- `./examples/dockerfile2llb` - can be used to convert a Dockerfile to LLB for debugging purposes
|
||||
- `./examples/gobuild` - shows how to use nested invocation to generate LLB for Go package internal dependencies
|
||||
|
||||
#### Exploring Dockerfiles
|
||||
|
||||
@@ -120,9 +120,18 @@ During development, Dockerfile frontend (dockerfile.v0) is also part of the Buil
|
||||
|
||||
##### Building a Dockerfile with `buildctl`
|
||||
|
||||
```
|
||||
buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=.
|
||||
buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt target=foo --opt build-arg:foo=bar
|
||||
```bash
|
||||
buildctl build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=. \
|
||||
--local dockerfile=.
|
||||
# or
|
||||
buildctl build \
|
||||
--frontend=dockerfile.v0 \
|
||||
--local context=. \
|
||||
--local dockerfile=. \
|
||||
--opt target=foo \
|
||||
--opt build-arg:foo=bar
|
||||
```
|
||||
|
||||
`--local` exposes local source files from client to the builder. `context` and `dockerfile` are the names Dockerfile frontend looks for build context and Dockerfile location.
|
||||
@@ -131,8 +140,9 @@ buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. -
|
||||
|
||||
For people familiar with `docker build` command, there is an example wrapper utility in `./examples/build-using-dockerfile` that allows building Dockerfiles with BuildKit using a syntax similar to `docker build`.
|
||||
|
||||
```
|
||||
go build ./examples/build-using-dockerfile && sudo install build-using-dockerfile /usr/local/bin
|
||||
```bash
|
||||
go build ./examples/build-using-dockerfile \
|
||||
&& sudo install build-using-dockerfile /usr/local/bin
|
||||
|
||||
build-using-dockerfile -t myimage .
|
||||
build-using-dockerfile -t mybuildkit -f ./hack/dockerfiles/test.Dockerfile .
|
||||
@@ -145,10 +155,18 @@ docker inspect myimage
|
||||
|
||||
External versions of the Dockerfile frontend are pushed to https://hub.docker.com/r/docker/dockerfile-upstream and https://hub.docker.com/r/docker/dockerfile and can be used with the gateway frontend. The source for the external frontend is currently located in `./frontend/dockerfile/cmd/dockerfile-frontend` but will move out of this repository in the future ([#163](https://github.com/moby/buildkit/issues/163)). For automatic build from master branch of this repository `docker/dockerfile-upsteam:master` or `docker/dockerfile-upstream:master-experimental` image can be used.
|
||||
|
||||
```bash
|
||||
buildctl build \
|
||||
--frontend gateway.v0 \
|
||||
--opt source=docker/dockerfile \
|
||||
--local context=. \
|
||||
--local dockerfile=.
|
||||
buildctl build \
|
||||
--frontend gateway.v0 \
|
||||
--opt source=docker/dockerfile \
|
||||
--opt context=git://github.com/moby/moby \
|
||||
--opt build-arg:APT_MIRROR=cdn-fastly.deb.debian.org
|
||||
```
|
||||
buildctl build --frontend gateway.v0 --opt source=docker/dockerfile --local context=. --local dockerfile=.
|
||||
buildctl build --frontend gateway.v0 --opt source=docker/dockerfile --opt context=git://github.com/moby/moby --opt build-arg:APT_MIRROR=cdn-fastly.deb.debian.org
|
||||
````
|
||||
|
||||
##### Building a Dockerfile with experimental features like `RUN --mount=type=(bind|cache|tmpfs|secret|ssh)`
|
||||
|
||||
@@ -162,46 +180,58 @@ By default, the build result and intermediate cache will only remain internally
|
||||
|
||||
The containerd worker needs to be used
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --output type=image,name=docker.io/username/image
|
||||
ctr --namespace=buildkit images ls
|
||||
```
|
||||
|
||||
##### Push resulting image to registry
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --output type=image,name=docker.io/username/image,push=true
|
||||
```
|
||||
|
||||
If credentials are required, `buildctl` will attempt to read Docker configuration file.
|
||||
|
||||
|
||||
##### Exporting build result back to client
|
||||
|
||||
The local client will copy the files directly to the client. This is useful if BuildKit is being used for building something else than container images.
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --output type=local,dest=path/to/output-dir
|
||||
```
|
||||
|
||||
To export specific files use multi-stage builds with a scratch stage and copy the needed files into that stage with `COPY --from`.
|
||||
|
||||
```dockerfile
|
||||
...
|
||||
FROM scratch as testresult
|
||||
|
||||
COPY --from=builder /usr/src/app/testresult.xml .
|
||||
...
|
||||
```
|
||||
|
||||
```bash
|
||||
buildctl build ... --opt target=testresult --output type=local,dest=path/to/output-dir
|
||||
```
|
||||
|
||||
Tar exporter is similar to local exporter but transfers the files through a tarball.
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --output type=tar,dest=out.tar
|
||||
buildctl build ... --output type=tar > out.tar
|
||||
```
|
||||
|
||||
|
||||
##### Exporting built image to Docker
|
||||
|
||||
```
|
||||
```bash
|
||||
# exported tarball is also compatible with OCI spec
|
||||
buildctl build ... --output type=docker,name=myimage | docker load
|
||||
```
|
||||
|
||||
##### Exporting [OCI Image Format](https://github.com/opencontainers/image-spec) tarball to client
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --output type=oci,dest=path/to/output.tar
|
||||
buildctl build ... --output type=oci > output.tar
|
||||
```
|
||||
@@ -210,14 +240,14 @@ buildctl build ... --output type=oci > output.tar
|
||||
|
||||
#### To/From registry
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --export-cache type=registry,ref=localhost:5000/myrepo:buildcache
|
||||
buildctl build ... --import-cache type=registry,ref=localhost:5000/myrepo:buildcache
|
||||
```
|
||||
|
||||
#### To/From local filesystem
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl build ... --export-cache type=local,dest=path/to/output-dir
|
||||
buildctl build ... --import-cache type=local,src=path/to/input-dir
|
||||
```
|
||||
@@ -225,27 +255,29 @@ buildctl build ... --import-cache type=local,src=path/to/input-dir
|
||||
The directory layout conforms to OCI Image Spec v1.0.
|
||||
|
||||
#### `--export-cache` options
|
||||
* `mode=min` (default): only export layers for the resulting image
|
||||
* `mode=max`: export all the layers of all intermediate steps
|
||||
* `ref=docker.io/user/image:tag`: reference for `registry` cache exporter
|
||||
* `dest=path/to/output-dir`: directory for `local` cache exporter
|
||||
|
||||
- `mode=min` (default): only export layers for the resulting image
|
||||
- `mode=max`: export all the layers of all intermediate steps
|
||||
- `ref=docker.io/user/image:tag`: reference for `registry` cache exporter
|
||||
- `dest=path/to/output-dir`: directory for `local` cache exporter
|
||||
|
||||
#### `--import-cache` options
|
||||
* `ref=docker.io/user/image:tag`: reference for `registry` cache importer
|
||||
* `src=path/to/input-dir`: directory for `local` cache importer
|
||||
* `digest=sha256:deadbeef`: digest of the manifest list to import for `local` cache importer. Defaults to the digest of "latest" tag in `index.json`
|
||||
|
||||
- `ref=docker.io/user/image:tag`: reference for `registry` cache importer
|
||||
- `src=path/to/input-dir`: directory for `local` cache importer
|
||||
- `digest=sha256:deadbeef`: digest of the manifest list to import for `local` cache importer. Defaults to the digest of "latest" tag in `index.json`
|
||||
|
||||
### Other
|
||||
|
||||
#### View build cache
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl du -v
|
||||
```
|
||||
|
||||
#### Show enabled workers
|
||||
|
||||
```
|
||||
```bash
|
||||
buildctl debug workers -v
|
||||
```
|
||||
|
||||
@@ -255,31 +287,65 @@ BuildKit can also be used by running the `buildkitd` daemon inside a Docker cont
|
||||
|
||||
We provide `buildkitd` container images as [`moby/buildkit`](https://hub.docker.com/r/moby/buildkit/tags/):
|
||||
|
||||
* `moby/buildkit:latest`: built from the latest regular [release](https://github.com/moby/buildkit/releases)
|
||||
* `moby/buildkit:rootless`: same as `latest` but runs as an unprivileged user, see [`docs/rootless.md`](docs/rootless.md)
|
||||
* `moby/buildkit:master`: built from the master branch
|
||||
* `moby/buildkit:master-rootless`: same as master but runs as an unprivileged user, see [`docs/rootless.md`](docs/rootless.md)
|
||||
- `moby/buildkit:latest`: built from the latest regular [release](https://github.com/moby/buildkit/releases)
|
||||
- `moby/buildkit:rootless`: same as `latest` but runs as an unprivileged user, see [`docs/rootless.md`](docs/rootless.md)
|
||||
- `moby/buildkit:master`: built from the master branch
|
||||
- `moby/buildkit:master-rootless`: same as master but runs as an unprivileged user, see [`docs/rootless.md`](docs/rootless.md)
|
||||
|
||||
To run daemon in a container:
|
||||
|
||||
```
|
||||
```bash
|
||||
docker run -d --privileged -p 1234:1234 moby/buildkit:latest --addr tcp://0.0.0.0:1234
|
||||
export BUILDKIT_HOST=tcp://0.0.0.0:1234
|
||||
buildctl build --help
|
||||
```
|
||||
|
||||
The images can be also built locally using `./hack/dockerfiles/test.Dockerfile` (or `./hack/dockerfiles/test.buildkit.Dockerfile` if you already have BuildKit).
|
||||
Run `make images` to build the images as `moby/buildkit:local` and `moby/buildkit:local-rootless`.
|
||||
To run client and an ephemeral daemon in a single container ("daemonless mode"):
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--privileged \
|
||||
-v /path/to/dir:/tmp/work \
|
||||
--entrypoint buildctl-daemonless.sh \
|
||||
moby/buildkit:master \
|
||||
build \
|
||||
--frontend dockerfile.v0 \
|
||||
--local context=/tmp/work \
|
||||
--local dockerfile=/tmp/work
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--security-opt seccomp=unconfined \
|
||||
--security-opt apparmor=unconfined \
|
||||
-e BUILDKITD_FLAGS=--oci-worker-no-process-sandbox \
|
||||
-v /path/to/dir:/tmp/work \
|
||||
--entrypoint buildctl-daemonless.sh \
|
||||
moby/buildkit:master-rootless \
|
||||
build \
|
||||
--frontend \
|
||||
dockerfile.v0 \
|
||||
--local context=/tmp/work \
|
||||
--local dockerfile=/tmp/work
|
||||
```
|
||||
|
||||
The images can be also built locally using `./hack/dockerfiles/test.Dockerfile` (or `./hack/dockerfiles/test.buildkit.Dockerfile` if you already have BuildKit). Run `make images` to build the images as `moby/buildkit:local` and `moby/buildkit:local-rootless`.
|
||||
|
||||
#### Connection helpers
|
||||
|
||||
If you are running `moby/buildkit:master` or `moby/buildkit:master-rootless` as a Docker/Kubernetes container, you can use special `BUILDKIT_HOST` URL for connecting to the BuildKit daemon in the container:
|
||||
|
||||
```
|
||||
export BUILDKIT_HOST=docker://<container>
|
||||
```bash
|
||||
export BUILDKIT_HOST=docker-container://<container>
|
||||
```
|
||||
|
||||
```
|
||||
```bash
|
||||
export BUILDKIT_HOST=kube-pod://<pod>
|
||||
```
|
||||
|
||||
@@ -287,15 +353,13 @@ export BUILDKIT_HOST=kube-pod://<pod>
|
||||
|
||||
BuildKit supports opentracing for buildkitd gRPC API and buildctl commands. To capture the trace to [Jaeger](https://github.com/jaegertracing/jaeger), set `JAEGER_TRACE` environment variable to the collection address.
|
||||
|
||||
|
||||
```
|
||||
```bash
|
||||
docker run -d -p6831:6831/udp -p16686:16686 jaegertracing/all-in-one:latest
|
||||
export JAEGER_TRACE=0.0.0.0:6831
|
||||
# restart buildkitd and buildctl so they know JAEGER_TRACE
|
||||
# any buildctl command should be traced to http://127.0.0.1:16686/
|
||||
```
|
||||
|
||||
|
||||
### Supported runc version
|
||||
|
||||
During development, BuildKit is tested with the version of runc that is being used by the containerd repository. Please refer to [runc.md](https://github.com/containerd/containerd/blob/v1.2.1/RUNC.md) for more information.
|
||||
@@ -306,5 +370,4 @@ Please refer to [`docs/rootless.md`](docs/rootless.md).
|
||||
|
||||
### Contributing
|
||||
|
||||
Want to contribute to BuildKit? Awesome! You can find information about
|
||||
contributing to this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||||
Want to contribute to BuildKit? Awesome! You can find information about contributing to this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
|
||||
|
||||
+10
-4
@@ -427,11 +427,13 @@ func Security(s pb.SecurityMode) RunOption {
|
||||
}
|
||||
|
||||
func Shlex(str string) RunOption {
|
||||
return Shlexf(str)
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = shlexf(str, false)(ei.State)
|
||||
})
|
||||
}
|
||||
func Shlexf(str string, v ...interface{}) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = shlexf(str, v...)(ei.State)
|
||||
ei.State = shlexf(str, true, v...)(ei.State)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -442,7 +444,9 @@ func Args(a []string) RunOption {
|
||||
}
|
||||
|
||||
func AddEnv(key, value string) RunOption {
|
||||
return AddEnvf(key, value)
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = ei.State.AddEnv(key, value)
|
||||
})
|
||||
}
|
||||
|
||||
func AddEnvf(key, value string, v ...interface{}) RunOption {
|
||||
@@ -458,7 +462,9 @@ func User(str string) RunOption {
|
||||
}
|
||||
|
||||
func Dir(str string) RunOption {
|
||||
return Dirf(str)
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
ei.State = ei.State.Dir(str)
|
||||
})
|
||||
}
|
||||
func Dirf(str string, v ...interface{}) RunOption {
|
||||
return runOptionFunc(func(ei *ExecInfo) {
|
||||
|
||||
+15
-7
@@ -24,19 +24,24 @@ var (
|
||||
keySecurity = contextKeyT("llb.security")
|
||||
)
|
||||
|
||||
func addEnvf(key, value string, v ...interface{}) StateOption {
|
||||
func addEnvf(key, value string, replace bool, v ...interface{}) StateOption {
|
||||
if replace {
|
||||
value = fmt.Sprintf(value, v...)
|
||||
}
|
||||
return func(s State) State {
|
||||
return s.WithValue(keyEnv, getEnv(s).AddOrReplace(key, fmt.Sprintf(value, v...)))
|
||||
return s.WithValue(keyEnv, getEnv(s).AddOrReplace(key, value))
|
||||
}
|
||||
}
|
||||
|
||||
func dir(str string) StateOption {
|
||||
return dirf(str)
|
||||
return dirf(str, false)
|
||||
}
|
||||
|
||||
func dirf(str string, v ...interface{}) StateOption {
|
||||
func dirf(value string, replace bool, v ...interface{}) StateOption {
|
||||
if replace {
|
||||
value = fmt.Sprintf(value, v...)
|
||||
}
|
||||
return func(s State) State {
|
||||
value := fmt.Sprintf(str, v...)
|
||||
if !path.IsAbs(value) {
|
||||
prev := getDir(s)
|
||||
if prev == "" {
|
||||
@@ -100,9 +105,12 @@ func args(args ...string) StateOption {
|
||||
}
|
||||
}
|
||||
|
||||
func shlexf(str string, v ...interface{}) StateOption {
|
||||
func shlexf(str string, replace bool, v ...interface{}) StateOption {
|
||||
if replace {
|
||||
str = fmt.Sprintf(str, v...)
|
||||
}
|
||||
return func(s State) State {
|
||||
arg, err := shlex.Split(fmt.Sprintf(str, v...))
|
||||
arg, err := shlex.Split(str)
|
||||
if err != nil {
|
||||
// TODO: handle error
|
||||
}
|
||||
|
||||
+4
-4
@@ -240,18 +240,18 @@ func (s State) File(a *FileAction, opts ...ConstraintsOpt) State {
|
||||
}
|
||||
|
||||
func (s State) AddEnv(key, value string) State {
|
||||
return s.AddEnvf(key, value)
|
||||
return addEnvf(key, value, false)(s)
|
||||
}
|
||||
|
||||
func (s State) AddEnvf(key, value string, v ...interface{}) State {
|
||||
return addEnvf(key, value, v...)(s)
|
||||
return addEnvf(key, value, true, v...)(s)
|
||||
}
|
||||
|
||||
func (s State) Dir(str string) State {
|
||||
return s.Dirf(str)
|
||||
return dirf(str, false)(s)
|
||||
}
|
||||
func (s State) Dirf(str string, v ...interface{}) State {
|
||||
return dirf(str, v...)(s)
|
||||
return dirf(str, true, v...)(s)
|
||||
}
|
||||
|
||||
func (s State) GetEnv(key string) (string, bool) {
|
||||
|
||||
+2
-2
@@ -46,8 +46,8 @@ type SolveOpt struct {
|
||||
type ExportEntry struct {
|
||||
Type string
|
||||
Attrs map[string]string
|
||||
Output io.WriteCloser // for ExporterOCI and ExporterDocker
|
||||
OutputDir string // for ExporterLocal
|
||||
Output func(map[string]string) (io.WriteCloser, error) // for ExporterOCI and ExporterDocker
|
||||
OutputDir string // for ExporterLocal
|
||||
}
|
||||
|
||||
type CacheOptionsEntry struct {
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ func (c *grpcClient) Run(ctx context.Context, f client.BuildFunc) (retError erro
|
||||
}
|
||||
}
|
||||
if retError != nil {
|
||||
st, _ := status.FromError(retError)
|
||||
st, _ := status.FromError(errors.Cause(retError))
|
||||
stp := st.Proto()
|
||||
req.Error = &rpc.Status{
|
||||
Code: stp.Code,
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
module github.com/moby/buildkit
|
||||
|
||||
go 1.11
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/Microsoft/go-winio v0.4.13-0.20190408173621-84b4ab48a507
|
||||
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 // indirect
|
||||
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58 // indirect
|
||||
github.com/containerd/cgroups v0.0.0-20190226200435-dbea6f2bd416 // indirect
|
||||
github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
|
||||
github.com/containerd/containerd v1.3.0-0.20190507210959-7c1e88399ec0
|
||||
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6
|
||||
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260 // indirect
|
||||
github.com/containerd/go-cni v0.0.0-20190610170741-5a4663dad645
|
||||
github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda
|
||||
github.com/containerd/ttrpc v0.0.0-20190411181408-699c4e40d1e7 // indirect
|
||||
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd // indirect
|
||||
github.com/containernetworking/cni v0.6.1-0.20180218032124-142cde0c766c // indirect
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
||||
github.com/docker/cli v0.0.0-20190321234815-f40f9c240ab0
|
||||
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
|
||||
github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c
|
||||
github.com/docker/docker-credential-helpers v0.6.0 // indirect
|
||||
github.com/docker/go-connections v0.3.0
|
||||
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad // indirect
|
||||
github.com/docker/libnetwork v0.8.0-dev.2.0.20190604151032-3c26b4e7495e
|
||||
github.com/godbus/dbus v4.1.0+incompatible // indirect
|
||||
github.com/gofrs/flock v0.7.0
|
||||
github.com/gogo/googleapis v1.1.0
|
||||
github.com/gogo/protobuf v1.2.0
|
||||
github.com/golang/protobuf v1.2.0
|
||||
github.com/google/go-cmp v0.2.0
|
||||
github.com/google/shlex v0.0.0-20150127133951-6f45313302b9
|
||||
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0
|
||||
github.com/hashicorp/golang-lru v0.0.0-20160207214719-a0d98a5f2880
|
||||
github.com/hashicorp/uuid v0.0.0-20160311170451-ebb0a03e909c // indirect
|
||||
github.com/ishidawataru/sctp v0.0.0-20180213033435-07191f837fed // indirect
|
||||
github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea
|
||||
github.com/kr/pretty v0.1.0 // indirect
|
||||
github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452
|
||||
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1
|
||||
github.com/opencontainers/image-spec v1.0.1
|
||||
github.com/opencontainers/runc v1.0.0-rc8
|
||||
github.com/opencontainers/runtime-spec v0.0.0-20180909173843-eba862dc2470
|
||||
github.com/opentracing-contrib/go-stdlib v0.0.0-20171029140428-b1a47cfbdd75
|
||||
github.com/opentracing/opentracing-go v0.0.0-20171003133519-1361b9cd60be
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/pkg/profile v1.2.1
|
||||
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
github.com/stretchr/testify v1.3.0
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
|
||||
github.com/tonistiigi/fsutil v0.0.0-20190819224149-3d2716dd0a4d
|
||||
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea
|
||||
github.com/uber/jaeger-client-go v0.0.0-20180103221425-e02c85f9069e
|
||||
github.com/uber/jaeger-lib v1.2.1 // indirect
|
||||
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5
|
||||
github.com/vishvananda/netlink v1.0.0 // indirect
|
||||
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
|
||||
go.etcd.io/bbolt v1.3.2
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
|
||||
golang.org/x/sys v0.0.0-20190303122642-d455e41777fc
|
||||
golang.org/x/time v0.0.0-20161028155119-f51c12702a4d
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
|
||||
google.golang.org/grpc v1.20.1
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
|
||||
gotest.tools v2.2.0+incompatible
|
||||
)
|
||||
|
||||
replace github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe
|
||||
|
||||
replace github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
|
||||
+3
-2
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/moby/buildkit/session"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
@@ -16,10 +17,10 @@ func CredentialsFunc(ctx context.Context, c session.Caller) func(string) (string
|
||||
Host: host,
|
||||
})
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(err); ok && st.Code() == codes.Unimplemented {
|
||||
if st, ok := status.FromError(errors.Cause(err)); ok && st.Code() == codes.Unimplemented {
|
||||
return "", "", nil
|
||||
}
|
||||
return "", "", err
|
||||
return "", "", errors.WithStack(err)
|
||||
}
|
||||
return resp.Username, resp.Secret, nil
|
||||
}
|
||||
|
||||
+16
-9
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/moby/buildkit/session"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
@@ -31,47 +32,53 @@ func (cs *callerContentStore) choose(ctx context.Context) context.Context {
|
||||
|
||||
func (cs *callerContentStore) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Info(ctx, dgst)
|
||||
info, err := cs.store.Info(ctx, dgst)
|
||||
return info, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Update(ctx, info, fieldpaths...)
|
||||
info, err := cs.store.Update(ctx, info, fieldpaths...)
|
||||
return info, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Walk(ctx context.Context, fn content.WalkFunc, fs ...string) error {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Walk(ctx, fn, fs...)
|
||||
return errors.WithStack(cs.store.Walk(ctx, fn, fs...))
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Delete(ctx context.Context, dgst digest.Digest) error {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Delete(ctx, dgst)
|
||||
return errors.WithStack(cs.store.Delete(ctx, dgst))
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) ListStatuses(ctx context.Context, fs ...string) ([]content.Status, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.ListStatuses(ctx, fs...)
|
||||
resp, err := cs.store.ListStatuses(ctx, fs...)
|
||||
return resp, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Status(ctx context.Context, ref string) (content.Status, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Status(ctx, ref)
|
||||
st, err := cs.store.Status(ctx, ref)
|
||||
return st, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Abort(ctx context.Context, ref string) error {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Abort(ctx, ref)
|
||||
return errors.WithStack(cs.store.Abort(ctx, ref))
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.Writer(ctx, opts...)
|
||||
w, err := cs.store.Writer(ctx, opts...)
|
||||
return w, errors.WithStack(err)
|
||||
}
|
||||
|
||||
func (cs *callerContentStore) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
|
||||
ctx = cs.choose(ctx)
|
||||
return cs.store.ReaderAt(ctx, desc)
|
||||
ra, err := cs.store.ReaderAt(ctx, desc)
|
||||
return ra, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// NewCallerStore creates content.Store from session.Caller with specified storeID
|
||||
|
||||
+18
-12
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func sendDiffCopy(stream grpc.Stream, fs fsutil.FS, progress progressCb) error {
|
||||
return fsutil.Send(stream.Context(), stream, fs, progress)
|
||||
return errors.WithStack(fsutil.Send(stream.Context(), stream, fs, progress))
|
||||
}
|
||||
|
||||
func newStreamWriter(stream grpc.ClientStream) io.WriteCloser {
|
||||
@@ -29,7 +29,7 @@ type bufferedWriteCloser struct {
|
||||
|
||||
func (bwc *bufferedWriteCloser) Close() error {
|
||||
if err := bwc.Writer.Flush(); err != nil {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return bwc.Closer.Close()
|
||||
}
|
||||
@@ -40,19 +40,25 @@ type streamWriterCloser struct {
|
||||
|
||||
func (wc *streamWriterCloser) Write(dt []byte) (int, error) {
|
||||
if err := wc.ClientStream.SendMsg(&BytesMessage{Data: dt}); err != nil {
|
||||
return 0, err
|
||||
// SendMsg return EOF on remote errors
|
||||
if errors.Cause(err) == io.EOF {
|
||||
if err := errors.WithStack(wc.ClientStream.RecvMsg(struct{}{})); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return 0, errors.WithStack(err)
|
||||
}
|
||||
return len(dt), nil
|
||||
}
|
||||
|
||||
func (wc *streamWriterCloser) Close() error {
|
||||
if err := wc.ClientStream.CloseSend(); err != nil {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
// block until receiver is done
|
||||
var bm BytesMessage
|
||||
if err := wc.ClientStream.RecvMsg(&bm); err != io.EOF {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -69,19 +75,19 @@ func recvDiffCopy(ds grpc.Stream, dest string, cu CacheUpdater, progress progres
|
||||
cf = cu.HandleChange
|
||||
ch = cu.ContentHasher()
|
||||
}
|
||||
return fsutil.Receive(ds.Context(), ds, dest, fsutil.ReceiveOpt{
|
||||
return errors.WithStack(fsutil.Receive(ds.Context(), ds, dest, fsutil.ReceiveOpt{
|
||||
NotifyHashed: cf,
|
||||
ContentHasher: ch,
|
||||
ProgressCb: progress,
|
||||
Filter: fsutil.FilterFunc(filter),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
func syncTargetDiffCopy(ds grpc.Stream, dest string) error {
|
||||
if err := os.MkdirAll(dest, 0700); err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "failed to create synctarget dest dir %s", dest)
|
||||
}
|
||||
return fsutil.Receive(ds.Context(), ds, dest, fsutil.ReceiveOpt{
|
||||
return errors.WithStack(fsutil.Receive(ds.Context(), ds, dest, fsutil.ReceiveOpt{
|
||||
Merge: true,
|
||||
Filter: func() func(string, *fstypes.Stat) bool {
|
||||
uid := os.Getuid()
|
||||
@@ -92,7 +98,7 @@ func syncTargetDiffCopy(ds grpc.Stream, dest string) error {
|
||||
return true
|
||||
}
|
||||
}(),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
func writeTargetFile(ds grpc.Stream, wc io.WriteCloser) error {
|
||||
@@ -102,10 +108,10 @@ func writeTargetFile(ds grpc.Stream, wc io.WriteCloser) error {
|
||||
if errors.Cause(err) == io.EOF {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if _, err := wc.Write(bm.Data); err != nil {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
-15
@@ -18,11 +18,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
keyOverrideExcludes = "override-excludes"
|
||||
keyIncludePatterns = "include-patterns"
|
||||
keyExcludePatterns = "exclude-patterns"
|
||||
keyFollowPaths = "followpaths"
|
||||
keyDirName = "dir-name"
|
||||
keyOverrideExcludes = "override-excludes"
|
||||
keyIncludePatterns = "include-patterns"
|
||||
keyExcludePatterns = "exclude-patterns"
|
||||
keyFollowPaths = "followpaths"
|
||||
keyDirName = "dir-name"
|
||||
keyExporterMetaPrefix = "exporter-md-"
|
||||
)
|
||||
|
||||
type fsSyncProvider struct {
|
||||
@@ -238,16 +239,16 @@ func NewFSSyncTargetDir(outdir string) session.Attachable {
|
||||
}
|
||||
|
||||
// NewFSSyncTarget allows writing into an io.WriteCloser
|
||||
func NewFSSyncTarget(w io.WriteCloser) session.Attachable {
|
||||
func NewFSSyncTarget(f func(map[string]string) (io.WriteCloser, error)) session.Attachable {
|
||||
p := &fsSyncTarget{
|
||||
outfile: w,
|
||||
f: f,
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
type fsSyncTarget struct {
|
||||
outdir string
|
||||
outfile io.WriteCloser
|
||||
outdir string
|
||||
f func(map[string]string) (io.WriteCloser, error)
|
||||
}
|
||||
|
||||
func (sp *fsSyncTarget) Register(server *grpc.Server) {
|
||||
@@ -258,11 +259,26 @@ func (sp *fsSyncTarget) DiffCopy(stream FileSend_DiffCopyServer) error {
|
||||
if sp.outdir != "" {
|
||||
return syncTargetDiffCopy(stream, sp.outdir)
|
||||
}
|
||||
if sp.outfile == nil {
|
||||
|
||||
if sp.f == nil {
|
||||
return errors.New("empty outfile and outdir")
|
||||
}
|
||||
defer sp.outfile.Close()
|
||||
return writeTargetFile(stream, sp.outfile)
|
||||
opts, _ := metadata.FromIncomingContext(stream.Context()) // if no metadata continue with empty object
|
||||
md := map[string]string{}
|
||||
for k, v := range opts {
|
||||
if strings.HasPrefix(k, keyExporterMetaPrefix) {
|
||||
md[strings.TrimPrefix(k, keyExporterMetaPrefix)] = strings.Join(v, ",")
|
||||
}
|
||||
}
|
||||
wc, err := sp.f(md)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if wc == nil {
|
||||
return status.Errorf(codes.AlreadyExists, "target already exists")
|
||||
}
|
||||
defer wc.Close()
|
||||
return writeTargetFile(stream, wc)
|
||||
}
|
||||
|
||||
func CopyToCaller(ctx context.Context, fs fsutil.FS, c session.Caller, progress func(int, bool)) error {
|
||||
@@ -275,13 +291,13 @@ func CopyToCaller(ctx context.Context, fs fsutil.FS, c session.Caller, progress
|
||||
|
||||
cc, err := client.DiffCopy(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
return sendDiffCopy(cc, fs, progress)
|
||||
}
|
||||
|
||||
func CopyFileWriter(ctx context.Context, c session.Caller) (io.WriteCloser, error) {
|
||||
func CopyFileWriter(ctx context.Context, md map[string]string, c session.Caller) (io.WriteCloser, error) {
|
||||
method := session.MethodURL(_FileSend_serviceDesc.ServiceName, "diffcopy")
|
||||
if !c.Supports(method) {
|
||||
return nil, errors.Errorf("method %s not supported by the client", method)
|
||||
@@ -289,9 +305,16 @@ func CopyFileWriter(ctx context.Context, c session.Caller) (io.WriteCloser, erro
|
||||
|
||||
client := NewFileSendClient(c.Conn())
|
||||
|
||||
opts := make(map[string][]string, len(md))
|
||||
for k, v := range md {
|
||||
opts[keyExporterMetaPrefix+k] = []string{v}
|
||||
}
|
||||
|
||||
ctx = metadata.NewOutgoingContext(ctx, opts)
|
||||
|
||||
cc, err := client.DiffCopy(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return newStreamWriter(cc), nil
|
||||
|
||||
+2
-2
@@ -21,10 +21,10 @@ func GetSecret(ctx context.Context, c session.Caller, id string) ([]byte, error)
|
||||
ID: id,
|
||||
})
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(err); ok && (st.Code() == codes.Unimplemented || st.Code() == codes.NotFound) {
|
||||
if st, ok := status.FromError(errors.Cause(err)); ok && (st.Code() == codes.Unimplemented || st.Code() == codes.NotFound) {
|
||||
return nil, errors.Wrapf(ErrNotFound, "secret %s not found", id)
|
||||
}
|
||||
return nil, err
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return resp.Data, nil
|
||||
}
|
||||
|
||||
+10
-6
@@ -3,23 +3,24 @@ package sshforward
|
||||
import (
|
||||
io "io"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
context "golang.org/x/net/context"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream) error {
|
||||
func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream, closeStream func() error) error {
|
||||
g, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
g.Go(func() (retErr error) {
|
||||
p := &BytesMessage{}
|
||||
for {
|
||||
if err := stream.RecvMsg(p); err != nil {
|
||||
conn.Close()
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
conn.Close()
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -29,7 +30,7 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream) erro
|
||||
}
|
||||
if _, err := conn.Write(p.Data); err != nil {
|
||||
conn.Close()
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
p.Data = p.Data[:0]
|
||||
}
|
||||
@@ -41,9 +42,12 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream) erro
|
||||
n, err := conn.Read(buf)
|
||||
switch {
|
||||
case err == io.EOF:
|
||||
if closeStream != nil {
|
||||
closeStream()
|
||||
}
|
||||
return nil
|
||||
case err != nil:
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -52,7 +56,7 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream) erro
|
||||
}
|
||||
p := &BytesMessage{Data: buf[:n]}
|
||||
if err := stream.SendMsg(p); err != nil {
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
+8
-7
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/moby/buildkit/session"
|
||||
"github.com/pkg/errors"
|
||||
context "golang.org/x/net/context"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"google.golang.org/grpc/metadata"
|
||||
@@ -48,7 +49,7 @@ func (s *server) run(ctx context.Context, l net.Listener, id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
go Copy(ctx, conn, stream)
|
||||
go Copy(ctx, conn, stream, stream.CloseSend)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -65,7 +66,7 @@ type SocketOpt struct {
|
||||
func MountSSHSocket(ctx context.Context, c session.Caller, opt SocketOpt) (sockPath string, closer func() error, err error) {
|
||||
dir, err := ioutil.TempDir("", ".buildkit-ssh-sock")
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
return "", nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
@@ -78,16 +79,16 @@ func MountSSHSocket(ctx context.Context, c session.Caller, opt SocketOpt) (sockP
|
||||
|
||||
l, err := net.Listen("unix", sockPath)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
return "", nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if err := os.Chown(sockPath, opt.UID, opt.GID); err != nil {
|
||||
l.Close()
|
||||
return "", nil, err
|
||||
return "", nil, errors.WithStack(err)
|
||||
}
|
||||
if err := os.Chmod(sockPath, os.FileMode(opt.Mode)); err != nil {
|
||||
l.Close()
|
||||
return "", nil, err
|
||||
return "", nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
s := &server{caller: c}
|
||||
@@ -102,12 +103,12 @@ func MountSSHSocket(ctx context.Context, c session.Caller, opt SocketOpt) (sockP
|
||||
return sockPath, func() error {
|
||||
err := l.Close()
|
||||
os.RemoveAll(sockPath)
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func CheckSSHID(ctx context.Context, c session.Caller, id string) error {
|
||||
client := NewSSHClient(c.Conn())
|
||||
_, err := client.CheckAgent(ctx, &CheckAgentRequest{ID: id})
|
||||
return err
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ func (sp *socketProvider) ForwardAgent(stream sshforward.SSH_ForwardAgentServer)
|
||||
|
||||
eg.Go(func() error {
|
||||
defer s1.Close()
|
||||
return sshforward.Copy(ctx, s2, stream)
|
||||
return sshforward.Copy(ctx, s2, stream, nil)
|
||||
})
|
||||
|
||||
return eg.Wait()
|
||||
|
||||
+20
-13
@@ -30,19 +30,20 @@ const (
|
||||
|
||||
CapBuildOpLLBFileName apicaps.CapID = "source.buildop.llbfilename"
|
||||
|
||||
CapExecMetaBase apicaps.CapID = "exec.meta.base"
|
||||
CapExecMetaProxy apicaps.CapID = "exec.meta.proxyenv"
|
||||
CapExecMetaNetwork apicaps.CapID = "exec.meta.network"
|
||||
CapExecMetaSecurity apicaps.CapID = "exec.meta.security"
|
||||
CapExecMetaSetsDefaultPath apicaps.CapID = "exec.meta.setsdefaultpath"
|
||||
CapExecMountBind apicaps.CapID = "exec.mount.bind"
|
||||
CapExecMountCache apicaps.CapID = "exec.mount.cache"
|
||||
CapExecMountCacheSharing apicaps.CapID = "exec.mount.cache.sharing"
|
||||
CapExecMountSelector apicaps.CapID = "exec.mount.selector"
|
||||
CapExecMountTmpfs apicaps.CapID = "exec.mount.tmpfs"
|
||||
CapExecMountSecret apicaps.CapID = "exec.mount.secret"
|
||||
CapExecMountSSH apicaps.CapID = "exec.mount.ssh"
|
||||
CapExecCgroupsMounted apicaps.CapID = "exec.cgroup"
|
||||
CapExecMetaBase apicaps.CapID = "exec.meta.base"
|
||||
CapExecMetaProxy apicaps.CapID = "exec.meta.proxyenv"
|
||||
CapExecMetaNetwork apicaps.CapID = "exec.meta.network"
|
||||
CapExecMetaSecurity apicaps.CapID = "exec.meta.security"
|
||||
CapExecMetaSetsDefaultPath apicaps.CapID = "exec.meta.setsdefaultpath"
|
||||
CapExecMountBind apicaps.CapID = "exec.mount.bind"
|
||||
CapExecMountBindReadWriteNoOuput apicaps.CapID = "exec.mount.bind.readwrite-nooutput"
|
||||
CapExecMountCache apicaps.CapID = "exec.mount.cache"
|
||||
CapExecMountCacheSharing apicaps.CapID = "exec.mount.cache.sharing"
|
||||
CapExecMountSelector apicaps.CapID = "exec.mount.selector"
|
||||
CapExecMountTmpfs apicaps.CapID = "exec.mount.tmpfs"
|
||||
CapExecMountSecret apicaps.CapID = "exec.mount.secret"
|
||||
CapExecMountSSH apicaps.CapID = "exec.mount.ssh"
|
||||
CapExecCgroupsMounted apicaps.CapID = "exec.cgroup"
|
||||
|
||||
CapFileBase apicaps.CapID = "file.base"
|
||||
|
||||
@@ -193,6 +194,12 @@ func init() {
|
||||
Status: apicaps.CapStatusExperimental,
|
||||
})
|
||||
|
||||
Caps.Init(apicaps.Cap{
|
||||
ID: CapExecMountBindReadWriteNoOuput,
|
||||
Enabled: true,
|
||||
Status: apicaps.CapStatusExperimental,
|
||||
})
|
||||
|
||||
Caps.Init(apicaps.Cap{
|
||||
ID: CapExecMountCache,
|
||||
Enabled: true,
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
module github.com/sirupsen/logrus
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/objx v0.1.1 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
|
||||
)
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
module github.com/tonistiigi/fsutil
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.11 // indirect
|
||||
github.com/Microsoft/hcsshim v0.8.5 // indirect
|
||||
github.com/containerd/containerd v1.2.4
|
||||
github.com/containerd/continuity v0.0.0-20181001140422-bd77b46c8352
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/docker/docker v0.0.0-20180531152204-71cd53e4a197
|
||||
github.com/docker/go-units v0.3.1 // indirect
|
||||
github.com/gogo/protobuf v1.0.0
|
||||
github.com/google/go-cmp v0.2.0 // indirect
|
||||
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
|
||||
github.com/onsi/ginkgo v1.7.0 // indirect
|
||||
github.com/onsi/gomega v1.4.3 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1
|
||||
github.com/opencontainers/image-spec v1.0.1 // indirect
|
||||
github.com/opencontainers/runc v1.0.0-rc6 // indirect
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/sirupsen/logrus v1.0.3 // indirect
|
||||
github.com/stretchr/testify v1.3.0
|
||||
golang.org/x/crypto v0.0.0-20190129210102-0709b304e793 // indirect
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
|
||||
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
|
||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
||||
gotest.tools v2.1.0+incompatible // indirect
|
||||
)
|
||||
+3
@@ -49,6 +49,9 @@ func mkstat(path, relpath string, fi os.FileInfo, inodemap map[uint64]string) (*
|
||||
stat.Mode = noPermPart | permPart
|
||||
}
|
||||
|
||||
// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
|
||||
stat.Mode &^= uint32(os.ModeSocket)
|
||||
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module golang.org/x/crypto
|
||||
|
||||
require golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
module golang.org/x/net
|
||||
|
||||
require (
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
golang.org/x/text v0.3.0
|
||||
)
|
||||
+1
@@ -0,0 +1 @@
|
||||
module golang.org/x/sync
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module golang.org/x/sys
|
||||
|
||||
go 1.12
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
module google.golang.org/grpc
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.26.0 // indirect
|
||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||
github.com/client9/misspell v0.3.4
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/golang/mock v1.1.1
|
||||
github.com/golang/protobuf v1.2.0
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd
|
||||
google.golang.org/appengine v1.1.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
|
||||
)
|
||||
+13
@@ -229,6 +229,10 @@ type decoder struct {
|
||||
mapType reflect.Type
|
||||
terrors []string
|
||||
strict bool
|
||||
|
||||
decodeCount int
|
||||
aliasCount int
|
||||
aliasDepth int
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -315,6 +319,13 @@ func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unm
|
||||
}
|
||||
|
||||
func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) {
|
||||
d.decodeCount++
|
||||
if d.aliasDepth > 0 {
|
||||
d.aliasCount++
|
||||
}
|
||||
if d.aliasCount > 100 && d.decodeCount > 1000 && float64(d.aliasCount)/float64(d.decodeCount) > 0.99 {
|
||||
failf("document contains excessive aliasing")
|
||||
}
|
||||
switch n.kind {
|
||||
case documentNode:
|
||||
return d.document(n, out)
|
||||
@@ -353,7 +364,9 @@ func (d *decoder) alias(n *node, out reflect.Value) (good bool) {
|
||||
failf("anchor '%s' value contains itself", n.value)
|
||||
}
|
||||
d.aliases[n] = true
|
||||
d.aliasDepth++
|
||||
good = d.unmarshal(n.alias, out)
|
||||
d.aliasDepth--
|
||||
delete(d.aliases, n)
|
||||
return good
|
||||
}
|
||||
|
||||
+28
@@ -13,6 +13,19 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// jsonNumber is the interface of the encoding/json.Number datatype.
|
||||
// Repeating the interface here avoids a dependency on encoding/json, and also
|
||||
// supports other libraries like jsoniter, which use a similar datatype with
|
||||
// the same interface. Detecting this interface is useful when dealing with
|
||||
// structures containing json.Number, which is a string under the hood. The
|
||||
// encoder should prefer the use of Int64(), Float64() and string(), in that
|
||||
// order, when encoding this type.
|
||||
type jsonNumber interface {
|
||||
Float64() (float64, error)
|
||||
Int64() (int64, error)
|
||||
String() string
|
||||
}
|
||||
|
||||
type encoder struct {
|
||||
emitter yaml_emitter_t
|
||||
event yaml_event_t
|
||||
@@ -89,6 +102,21 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
|
||||
}
|
||||
iface := in.Interface()
|
||||
switch m := iface.(type) {
|
||||
case jsonNumber:
|
||||
integer, err := m.Int64()
|
||||
if err == nil {
|
||||
// In this case the json.Number is a valid int64
|
||||
in = reflect.ValueOf(integer)
|
||||
break
|
||||
}
|
||||
float, err := m.Float64()
|
||||
if err == nil {
|
||||
// In this case the json.Number is a valid float64
|
||||
in = reflect.ValueOf(float)
|
||||
break
|
||||
}
|
||||
// fallback case - no number could be obtained
|
||||
in = reflect.ValueOf(m.String())
|
||||
case time.Time, *time.Time:
|
||||
// Although time.Time implements TextMarshaler,
|
||||
// we don't want to treat it as a string for YAML
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
module "gopkg.in/yaml.v2"
|
||||
|
||||
require (
|
||||
"gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405
|
||||
)
|
||||
+1
-1
@@ -81,7 +81,7 @@ func resolvableTag(tag string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)?$`)
|
||||
var yamlStyleFloat = regexp.MustCompile(`^[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?$`)
|
||||
|
||||
func resolve(tag string, in string) (rtag string, out interface{}) {
|
||||
if !resolvableTag(tag) {
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
module gotest.tools
|
||||
|
||||
require (
|
||||
github.com/google/go-cmp v0.2.0
|
||||
github.com/pkg/errors v0.8.0
|
||||
github.com/spf13/pflag v1.0.3
|
||||
golang.org/x/tools v0.0.0-20180810170437-e96c4e24768d
|
||||
)
|
||||
Reference in New Issue
Block a user