summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml4
-rw-r--r--cmd/podman/common/specgen.go73
-rw-r--r--cmd/podman/containers/start.go20
-rw-r--r--cmd/podman/secrets/create.go15
-rwxr-xr-xdocs/remote-docs.sh2
-rw-r--r--docs/source/conf.py4
-rw-r--r--docs/source/markdown/podman-auto-update.1.md2
-rw-r--r--docs/source/markdown/podman-create.1.md17
-rw-r--r--docs/source/markdown/podman-run.1.md17
-rw-r--r--docs/source/markdown/podman-secret-create.1.md4
-rw-r--r--docs/source/markdown/podman-start.1.md25
-rw-r--r--go.mod2
-rw-r--r--go.sum3
-rw-r--r--libpod/container_config.go2
-rw-r--r--libpod/container_internal_linux.go24
-rw-r--r--libpod/container_path_resolution.go2
-rw-r--r--libpod/define/container.go9
-rw-r--r--libpod/kube.go49
-rw-r--r--libpod/options.go22
-rw-r--r--pkg/domain/entities/containers.go1
-rw-r--r--pkg/domain/filters/containers.go27
-rw-r--r--pkg/domain/infra/abi/containers.go28
-rw-r--r--pkg/domain/infra/abi/play.go27
-rw-r--r--pkg/domain/infra/tunnel/containers.go25
-rw-r--r--pkg/specgen/generate/container_create.go5
-rw-r--r--pkg/specgen/generate/kube/kube.go15
-rw-r--r--pkg/specgen/specgen.go3
-rw-r--r--test/e2e/commit_test.go24
-rw-r--r--test/e2e/common_test.go7
-rw-r--r--test/e2e/generate_kube_test.go50
-rw-r--r--test/e2e/play_kube_test.go84
-rw-r--r--test/e2e/run_test.go100
-rw-r--r--test/e2e/secret_test.go23
-rw-r--r--test/system/001-basic.bats25
-rw-r--r--test/system/045-start.bats17
-rw-r--r--test/system/410-selinux.bats13
-rw-r--r--vendor/github.com/containerd/continuity/AUTHORS40
-rw-r--r--vendor/github.com/containerd/continuity/LICENSE191
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy.go176
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy_darwinopenbsdsolaris.go40
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy_freebsd.go42
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy_linux.go147
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy_unix.go102
-rw-r--r--vendor/github.com/containerd/continuity/fs/copy_windows.go49
-rw-r--r--vendor/github.com/containerd/continuity/fs/diff.go326
-rw-r--r--vendor/github.com/containerd/continuity/fs/diff_unix.go74
-rw-r--r--vendor/github.com/containerd/continuity/fs/diff_windows.go48
-rw-r--r--vendor/github.com/containerd/continuity/fs/dtype_linux.go103
-rw-r--r--vendor/github.com/containerd/continuity/fs/du.go38
-rw-r--r--vendor/github.com/containerd/continuity/fs/du_unix.go120
-rw-r--r--vendor/github.com/containerd/continuity/fs/du_windows.go82
-rw-r--r--vendor/github.com/containerd/continuity/fs/hardlink.go43
-rw-r--r--vendor/github.com/containerd/continuity/fs/hardlink_unix.go34
-rw-r--r--vendor/github.com/containerd/continuity/fs/hardlink_windows.go23
-rw-r--r--vendor/github.com/containerd/continuity/fs/path.go311
-rw-r--r--vendor/github.com/containerd/continuity/fs/stat_darwinfreebsd.go44
-rw-r--r--vendor/github.com/containerd/continuity/fs/stat_linuxopenbsd.go45
-rw-r--r--vendor/github.com/containerd/continuity/fs/time.go29
-rw-r--r--vendor/github.com/containerd/continuity/sysx/README.md3
-rw-r--r--vendor/github.com/containerd/continuity/sysx/generate.sh52
-rw-r--r--vendor/github.com/containerd/continuity/sysx/nodata_linux.go23
-rw-r--r--vendor/github.com/containerd/continuity/sysx/nodata_solaris.go24
-rw-r--r--vendor/github.com/containerd/continuity/sysx/nodata_unix.go25
-rw-r--r--vendor/github.com/containerd/continuity/sysx/xattr.go117
-rw-r--r--vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go67
-rw-r--r--vendor/github.com/docker/docker/api/swagger.yaml4
-rw-r--r--vendor/github.com/docker/docker/client/build_cancel.go2
-rw-r--r--vendor/github.com/docker/docker/client/client.go2
-rw-r--r--vendor/github.com/docker/docker/client/config_create.go2
-rw-r--r--vendor/github.com/docker/docker/client/config_remove.go2
-rw-r--r--vendor/github.com/docker/docker/client/config_update.go2
-rw-r--r--vendor/github.com/docker/docker/client/container_commit.go2
-rw-r--r--vendor/github.com/docker/docker/client/container_copy.go2
-rw-r--r--vendor/github.com/docker/docker/client/container_create.go2
-rw-r--r--vendor/github.com/docker/docker/client/container_restart.go2
-rw-r--r--vendor/github.com/docker/docker/client/container_update.go2
-rw-r--r--vendor/github.com/docker/docker/client/distribution_inspect.go2
-rw-r--r--vendor/github.com/docker/docker/client/image_build.go4
-rw-r--r--vendor/github.com/docker/docker/client/image_create.go2
-rw-r--r--vendor/github.com/docker/docker/client/image_import.go2
-rw-r--r--vendor/github.com/docker/docker/client/image_search.go2
-rw-r--r--vendor/github.com/docker/docker/client/secret_create.go2
-rw-r--r--vendor/github.com/docker/docker/client/secret_remove.go2
-rw-r--r--vendor/github.com/docker/docker/client/secret_update.go2
-rw-r--r--vendor/github.com/docker/docker/client/service_create.go2
-rw-r--r--vendor/github.com/docker/docker/client/task_inspect.go2
-rw-r--r--vendor/github.com/docker/docker/pkg/archive/archive.go30
-rw-r--r--vendor/github.com/docker/docker/pkg/archive/archive_linux.go180
-rw-r--r--vendor/github.com/docker/docker/pkg/archive/archive_other.go4
-rw-r--r--vendor/golang.org/x/sync/errgroup/errgroup.go66
-rw-r--r--vendor/modules.txt6
91 files changed, 756 insertions, 2764 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index a011c9af5..ebe12ab4a 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -539,7 +539,7 @@ rootless_integration_test_task:
skip: *branches_and_tags
depends_on:
- unit_test
- matrix: *fedora_vm_axis
+ matrix: *platform_axis
gce_instance: *standardvm
timeout_in: 90m
env:
@@ -614,7 +614,7 @@ rootless_system_test_task:
only_if: *not_docs
depends_on:
- rootless_integration_test
- matrix: *fedora_vm_axis
+ matrix: *platform_axis
gce_instance: *standardvm
env:
TEST_FLAVOR: sys
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 7896ddfc1..5dc2ec864 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -639,12 +639,16 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
}
s.RestartPolicy = splitRestart[0]
}
+
+ s.Secrets, s.EnvSecrets, err = parseSecrets(c.Secrets)
+ if err != nil {
+ return err
+ }
s.Remove = c.Rm
s.StopTimeout = &c.StopTimeout
s.Timeout = c.Timeout
s.Timezone = c.Timezone
s.Umask = c.Umask
- s.Secrets = c.Secrets
s.PidFile = c.PidFile
s.Volatile = c.Rm
@@ -773,3 +777,70 @@ func parseThrottleIOPsDevices(iopsDevices []string) (map[string]specs.LinuxThrot
}
return td, nil
}
+
+func parseSecrets(secrets []string) ([]string, map[string]string, error) {
+ secretParseError := errors.New("error parsing secret")
+ var mount []string
+ envs := make(map[string]string)
+ for _, val := range secrets {
+ source := ""
+ secretType := ""
+ target := ""
+ split := strings.Split(val, ",")
+
+ // --secret mysecret
+ if len(split) == 1 {
+ source = val
+ mount = append(mount, source)
+ continue
+ }
+ // --secret mysecret,opt=opt
+ if !strings.Contains(split[0], "=") {
+ source = split[0]
+ split = split[1:]
+ }
+ // TODO: implement other secret options
+ for _, val := range split {
+ kv := strings.SplitN(val, "=", 2)
+ if len(kv) < 2 {
+ return nil, nil, errors.Wrapf(secretParseError, "option %s must be in form option=value", val)
+ }
+ switch kv[0] {
+ case "source":
+ source = kv[1]
+ case "type":
+ if secretType != "" {
+ return nil, nil, errors.Wrap(secretParseError, "cannot set more tha one secret type")
+ }
+ if kv[1] != "mount" && kv[1] != "env" {
+ return nil, nil, errors.Wrapf(secretParseError, "type %s is invalid", kv[1])
+ }
+ secretType = kv[1]
+ case "target":
+ target = kv[1]
+ default:
+ return nil, nil, errors.Wrapf(secretParseError, "option %s invalid", val)
+ }
+ }
+
+ if secretType == "" {
+ secretType = "mount"
+ }
+ if source == "" {
+ return nil, nil, errors.Wrapf(secretParseError, "no source found %s", val)
+ }
+ if secretType == "mount" {
+ if target != "" {
+ return nil, nil, errors.Wrapf(secretParseError, "target option is invalid for mounted secrets")
+ }
+ mount = append(mount, source)
+ }
+ if secretType == "env" {
+ if target == "" {
+ target = source
+ }
+ envs[target] = source
+ }
+ }
+ return mount, envs, nil
+}
diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go
index 8d62dc12f..dcd1eca82 100644
--- a/cmd/podman/containers/start.go
+++ b/cmd/podman/containers/start.go
@@ -3,6 +3,7 @@ package containers
import (
"fmt"
"os"
+ "strings"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
@@ -42,7 +43,9 @@ var (
)
var (
- startOptions entities.ContainerStartOptions
+ startOptions = entities.ContainerStartOptions{
+ Filters: make(map[string][]string),
+ }
)
func startFlags(cmd *cobra.Command) {
@@ -56,6 +59,8 @@ func startFlags(cmd *cobra.Command) {
flags.BoolVarP(&startOptions.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVar(&startOptions.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
+ flags.StringSliceVarP(&filters, "filter", "f", []string{}, "Filter output based on conditions given")
+ _ = cmd.RegisterFlagCompletionFunc("filter", common.AutocompletePsFilters)
flags.BoolVar(&startOptions.All, "all", false, "Start all containers regardless of their state or configuration")
@@ -116,7 +121,18 @@ func start(cmd *cobra.Command, args []string) error {
startOptions.Stdout = os.Stdout
}
- responses, err := registry.ContainerEngine().ContainerStart(registry.GetContext(), args, startOptions)
+ var containers []string = args
+ if len(filters) > 0 {
+ for _, f := range filters {
+ split := strings.SplitN(f, "=", 2)
+ if len(split) == 1 {
+ return errors.Errorf("invalid filter %q", f)
+ }
+ startOptions.Filters[split[0]] = append(startOptions.Filters[split[0]], split[1])
+ }
+ }
+
+ responses, err := registry.ContainerEngine().ContainerStart(registry.GetContext(), containers, startOptions)
if err != nil {
return err
}
diff --git a/cmd/podman/secrets/create.go b/cmd/podman/secrets/create.go
index 7374b682b..4204f30b4 100644
--- a/cmd/podman/secrets/create.go
+++ b/cmd/podman/secrets/create.go
@@ -2,15 +2,16 @@ package secrets
import (
"context"
- "errors"
"fmt"
"io"
"os"
+ "strings"
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -29,6 +30,7 @@ var (
var (
createOpts = entities.SecretCreateOptions{}
+ env = false
)
func init() {
@@ -43,6 +45,9 @@ func init() {
driverFlagName := "driver"
flags.StringVar(&createOpts.Driver, driverFlagName, "file", "Specify secret driver")
_ = createCmd.RegisterFlagCompletionFunc(driverFlagName, completion.AutocompleteNone)
+
+ envFlagName := "env"
+ flags.BoolVar(&env, envFlagName, false, "Read secret data from environment variable")
}
func create(cmd *cobra.Command, args []string) error {
@@ -52,7 +57,13 @@ func create(cmd *cobra.Command, args []string) error {
path := args[1]
var reader io.Reader
- if path == "-" || path == "/dev/stdin" {
+ if env {
+ envValue := os.Getenv(path)
+ if envValue == "" {
+ return errors.Errorf("cannot create store secret data: environment variable %s is not set", path)
+ }
+ reader = strings.NewReader(envValue)
+ } else if path == "-" || path == "/dev/stdin" {
stat, err := os.Stdin.Stat()
if err != nil {
return err
diff --git a/docs/remote-docs.sh b/docs/remote-docs.sh
index b1682e9cd..8249fc497 100755
--- a/docs/remote-docs.sh
+++ b/docs/remote-docs.sh
@@ -80,7 +80,7 @@ function html_fn() {
local link=$(sed -e 's?.so man1/\(.*\)?\1?' <$dir/links/${file%.md})
markdown=$dir/$link.md
fi
- pandoc --ascii --standalone \
+ pandoc --ascii --standalone --from markdown-smart \
--lua-filter=docs/links-to-html.lua \
--lua-filter=docs/use-pagetitle.lua \
-o $TARGET/${file%%.*}.html $markdown
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 52869baf4..7a180e5ef 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -44,6 +44,10 @@ exclude_patterns = []
master_doc = "index"
+# Configure smartquotes to only transform quotes and ellipses, not dashes
+smartquotes_action = "qe"
+
+
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
diff --git a/docs/source/markdown/podman-auto-update.1.md b/docs/source/markdown/podman-auto-update.1.md
index f298d6bf6..12e8bc70f 100644
--- a/docs/source/markdown/podman-auto-update.1.md
+++ b/docs/source/markdown/podman-auto-update.1.md
@@ -14,7 +14,7 @@ The label "image" is an alternative to "registry" maintained for backwards compa
An image is considered updated if the digest in the local storage is different than the one of the remote image.
If an image must be updated, Podman pulls it down and restarts the systemd unit executing the container.
-The registry policy requires a requires a fully-qualified image reference (e.g., quay.io/podman/stable:latest) to be used to create the container.
+The registry policy requires a fully-qualified image reference (e.g., quay.io/podman/stable:latest) to be used to create the container.
This enforcement is necessary to know which image to actually check and pull.
If an image ID was used, Podman would not know which image to check/pull anymore.
diff --git a/docs/source/markdown/podman-create.1.md b/docs/source/markdown/podman-create.1.md
index e4631c319..b4593e07a 100644
--- a/docs/source/markdown/podman-create.1.md
+++ b/docs/source/markdown/podman-create.1.md
@@ -840,7 +840,7 @@ Specify the policy to select the seccomp profile. If set to *image*, Podman will
Note that this feature is experimental and may change in the future.
-#### **\-\-secret**=*secret*
+#### **\-\-secret**=*secret*[,opt=opt ...]
Give the container access to a secret. Can be specified multiple times.
@@ -848,12 +848,17 @@ A secret is a blob of sensitive data which a container needs at runtime but
should not be stored in the image or in source control, such as usernames and passwords,
TLS certificates and keys, SSH keys or other important generic strings or binary content (up to 500 kb in size).
-Secrets are copied and mounted into the container when a container is created. If a secret is deleted using
-`podman secret rm`, the container will still have access to the secret. If a secret is deleted and
-another secret is created with the same name, the secret inside the container will not change; the old
-secret value will still remain.
+When secrets are specified as type `mount`, the secrets are copied and mounted into the container when a container is created.
+When secrets are specified as type `env`, the secret will be set as an environment variable within the container.
+Secrets are written in the container at the time of container creation, and modifying the secret using `podman secret` commands
+after the container is created will not affect the secret inside the container.
-Secrets are managed using the `podman secret` command.
+Secrets and its storage are managed using the `podman secret` command.
+
+Secret Options
+
+- `type=mount|env` : How the secret will be exposed to the container. Default mount.
+- `target=target` : Target of secret. Defauts to secret name.
#### **\-\-security-opt**=*option*
diff --git a/docs/source/markdown/podman-run.1.md b/docs/source/markdown/podman-run.1.md
index 3270394ac..f371cacbf 100644
--- a/docs/source/markdown/podman-run.1.md
+++ b/docs/source/markdown/podman-run.1.md
@@ -892,7 +892,7 @@ Specify the policy to select the seccomp profile. If set to *image*, Podman will
Note that this feature is experimental and may change in the future.
-#### **\-\-secret**=*secret*
+#### **\-\-secret**=*secret*[,opt=opt ...]
Give the container access to a secret. Can be specified multiple times.
@@ -900,12 +900,17 @@ A secret is a blob of sensitive data which a container needs at runtime but
should not be stored in the image or in source control, such as usernames and passwords,
TLS certificates and keys, SSH keys or other important generic strings or binary content (up to 500 kb in size).
-Secrets are copied and mounted into the container when a container is created. If a secret is deleted using
-`podman secret rm`, the container will still have access to the secret. If a secret is deleted and
-another secret is created with the same name, the secret inside the container will not change; the old
-secret value will still remain.
+When secrets are specified as type `mount`, the secrets are copied and mounted into the container when a container is created.
+When secrets are specified as type `env`, the secret will be set as an environment variable within the container.
+Secrets are written in the container at the time of container creation, and modifying the secret using `podman secret` commands
+after the container is created will not affect the secret inside the container.
-Secrets are managed using the `podman secret` command
+Secrets and its storage are managed using the `podman secret` command.
+
+Secret Options
+
+- `type=mount|env` : How the secret will be exposed to the container. Default mount.
+- `target=target` : Target of secret. Defauts to secret name.
#### **\-\-security-opt**=*option*
diff --git a/docs/source/markdown/podman-secret-create.1.md b/docs/source/markdown/podman-secret-create.1.md
index f5a97a0f3..7aacca3fe 100644
--- a/docs/source/markdown/podman-secret-create.1.md
+++ b/docs/source/markdown/podman-secret-create.1.md
@@ -20,6 +20,10 @@ Secrets will not be committed to an image with `podman commit`, and will not be
## OPTIONS
+#### **\-\-env**=*false*
+
+Read secret data from environment variable
+
#### **\-\-driver**=*driver*
Specify the secret driver (default **file**, which is unencrypted).
diff --git a/docs/source/markdown/podman-start.1.md b/docs/source/markdown/podman-start.1.md
index 626e6e368..7085f3f47 100644
--- a/docs/source/markdown/podman-start.1.md
+++ b/docs/source/markdown/podman-start.1.md
@@ -42,6 +42,31 @@ Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and
Start all the containers created by Podman, default is only running containers.
+#### **\-\-filter**, **-f**
+
+Filter what containers are going to be started from the given arguments.
+Multiple filters can be given with multiple uses of the --filter flag.
+Filters with the same key work inclusive with the only exception being
+`label` which is exclusive. Filters with different keys always work exclusive.
+
+Valid filters are listed below:
+
+| **Filter** | **Description** |
+| --------------- | -------------------------------------------------------------------------------- |
+| id | [ID] Container's ID (accepts regex) |
+| name | [Name] Container's name (accepts regex) |
+| label | [Key] or [Key=Value] Label assigned to a container |
+| exited | [Int] Container's exit code |
+| status | [Status] Container's status: 'created', 'exited', 'paused', 'running', 'unknown' |
+| ancestor | [ImageName] Image or descendant used to create container |
+| before | [ID] or [Name] Containers created before this container |
+| since | [ID] or [Name] Containers created since this container |
+| volume | [VolumeName] or [MountpointDestination] Volume mounted in container |
+| health | [Status] healthy or unhealthy |
+| pod | [Pod] name or full or partial ID of pod |
+| network | [Network] name or full ID of network |
+
+
## EXAMPLE
podman start mywebserver
diff --git a/go.mod b/go.mod
index 5d5c5318c..8abe8d20c 100644
--- a/go.mod
+++ b/go.mod
@@ -25,7 +25,7 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/digitalocean/go-qemu v0.0.0-20210209191958-152a1535e49f
github.com/docker/distribution v2.7.1+incompatible
- github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible
+ github.com/docker/docker v20.10.6+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-plugins-helpers v0.0.0-20200102110956-c9a8a2d92ccc
github.com/docker/go-units v0.4.0
diff --git a/go.sum b/go.sum
index 28f5a4f21..4616474b9 100644
--- a/go.sum
+++ b/go.sum
@@ -266,8 +266,9 @@ github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.4.2-0.20191219165747-a9416c67da9f/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
-github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible h1:Yu2uGErhwEoOT/OxAFe+/SiJCqRLs+pgcS5XKrDXnG4=
github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v20.10.6+incompatible h1:oXI3Vas8TI8Eu/EjH4srKHJBVqraSzJybhxY7Om9faQ=
+github.com/docker/docker v20.10.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.6.3 h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ=
github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
diff --git a/libpod/container_config.go b/libpod/container_config.go
index a508b96ee..904c03f9b 100644
--- a/libpod/container_config.go
+++ b/libpod/container_config.go
@@ -373,4 +373,6 @@ type ContainerMiscConfig struct {
PidFile string `json:"pid_file,omitempty"`
// CDIDevices contains devices that use the CDI
CDIDevices []string `json:"cdiDevices,omitempty"`
+ // EnvSecrets are secrets that are set as environment variables
+ EnvSecrets map[string]*secrets.Secret `json:"secret_env,omitempty"`
}
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index f0608e2b2..7d57e8965 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -29,6 +29,7 @@ import (
"github.com/containers/common/pkg/apparmor"
"github.com/containers/common/pkg/chown"
"github.com/containers/common/pkg/config"
+ "github.com/containers/common/pkg/secrets"
"github.com/containers/common/pkg/subscriptions"
"github.com/containers/common/pkg/umask"
"github.com/containers/podman/v3/libpod/define"
@@ -377,14 +378,8 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
case "z":
fallthrough
case "Z":
- if c.MountLabel() != "" {
- if c.ProcessLabel() != "" {
- if err := label.Relabel(m.Source, c.MountLabel(), label.IsShared(o)); err != nil {
- return nil, err
- }
- } else {
- logrus.Infof("Not relabeling volume %q in container %s as SELinux is disabled", m.Source, c.ID())
- }
+ if err := label.Relabel(m.Source, c.MountLabel(), label.IsShared(o)); err != nil {
+ return nil, err
}
default:
@@ -763,6 +758,19 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
if c.state.ExtensionStageHooks, err = c.setupOCIHooks(ctx, g.Config); err != nil {
return nil, errors.Wrapf(err, "error setting up OCI Hooks")
}
+ if len(c.config.EnvSecrets) > 0 {
+ manager, err := secrets.NewManager(c.runtime.GetSecretsStorageDir())
+ if err != nil {
+ return nil, err
+ }
+ for name, secr := range c.config.EnvSecrets {
+ _, data, err := manager.LookupSecretData(secr.Name)
+ if err != nil {
+ return nil, err
+ }
+ g.AddProcessEnv(name, string(data))
+ }
+ }
return g.Config, nil
}
diff --git a/libpod/container_path_resolution.go b/libpod/container_path_resolution.go
index d798963b1..ec7306ca1 100644
--- a/libpod/container_path_resolution.go
+++ b/libpod/container_path_resolution.go
@@ -128,7 +128,7 @@ func isPathOnVolume(c *Container, containerPath string) bool {
if cleanedContainerPath == filepath.Clean(vol.Dest) {
return true
}
- for dest := vol.Dest; dest != "/"; dest = filepath.Dir(dest) {
+ for dest := vol.Dest; dest != "/" && dest != "."; dest = filepath.Dir(dest) {
if cleanedContainerPath == dest {
return true
}
diff --git a/libpod/define/container.go b/libpod/define/container.go
index 5a2ff026f..f3125afa9 100644
--- a/libpod/define/container.go
+++ b/libpod/define/container.go
@@ -17,3 +17,12 @@ const (
// handling of system restart, which Podman does not yet support.
RestartPolicyUnlessStopped = "unless-stopped"
)
+
+// RestartPolicyMap maps between restart-policy valid values to restart policy types
+var RestartPolicyMap = map[string]string{
+ "none": RestartPolicyNone,
+ RestartPolicyNo: RestartPolicyNo,
+ RestartPolicyAlways: RestartPolicyAlways,
+ RestartPolicyOnFailure: RestartPolicyOnFailure,
+ RestartPolicyUnlessStopped: RestartPolicyUnlessStopped,
+}
diff --git a/libpod/kube.go b/libpod/kube.go
index adcfe92c9..a3f49bfe8 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -218,9 +218,15 @@ func (p *Pod) podWithContainers(containers []*Container, ports []v1.ContainerPor
deDupPodVolumes := make(map[string]*v1.Volume)
first := true
podContainers := make([]v1.Container, 0, len(containers))
+ podAnnotations := make(map[string]string)
dnsInfo := v1.PodDNSConfig{}
for _, ctr := range containers {
if !ctr.IsInfra() {
+ // Convert auto-update labels into kube annotations
+ for k, v := range getAutoUpdateAnnotations(removeUnderscores(ctr.Name()), ctr.Labels()) {
+ podAnnotations[k] = v
+ }
+
ctr, volumes, _, err := containerToV1Container(ctr)
if err != nil {
return nil, err
@@ -267,10 +273,16 @@ func (p *Pod) podWithContainers(containers []*Container, ports []v1.ContainerPor
podVolumes = append(podVolumes, *vol)
}
- return addContainersAndVolumesToPodObject(podContainers, podVolumes, p.Name(), &dnsInfo, hostNetwork), nil
+ return newPodObject(
+ p.Name(),
+ podAnnotations,
+ podContainers,
+ podVolumes,
+ &dnsInfo,
+ hostNetwork), nil
}
-func addContainersAndVolumesToPodObject(containers []v1.Container, volumes []v1.Volume, podName string, dnsOptions *v1.PodDNSConfig, hostNetwork bool) *v1.Pod {
+func newPodObject(podName string, annotations map[string]string, containers []v1.Container, volumes []v1.Volume, dnsOptions *v1.PodDNSConfig, hostNetwork bool) *v1.Pod {
tm := v12.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
@@ -287,6 +299,7 @@ func addContainersAndVolumesToPodObject(containers []v1.Container, volumes []v1.
// will reflect time this is run (not container create time) because the conversion
// of the container create time to v1 Time is probably not warranted nor worthwhile.
CreationTimestamp: v12.Now(),
+ Annotations: annotations,
}
ps := v1.PodSpec{
Containers: containers,
@@ -311,7 +324,13 @@ func simplePodWithV1Containers(ctrs []*Container) (*v1.Pod, error) {
kubeVolumes := make([]v1.Volume, 0)
hostNetwork := true
podDNS := v1.PodDNSConfig{}
+ kubeAnnotations := make(map[string]string)
for _, ctr := range ctrs {
+ // Convert auto-update labels into kube annotations
+ for k, v := range getAutoUpdateAnnotations(removeUnderscores(ctr.Name()), ctr.Labels()) {
+ kubeAnnotations[k] = v
+ }
+
if !ctr.HostNetwork() {
hostNetwork = false
}
@@ -355,7 +374,13 @@ func simplePodWithV1Containers(ctrs []*Container) (*v1.Pod, error) {
}
} // end if ctrDNS
}
- return addContainersAndVolumesToPodObject(kubeCtrs, kubeVolumes, strings.ReplaceAll(ctrs[0].Name(), "_", ""), &podDNS, hostNetwork), nil
+ return newPodObject(
+ strings.ReplaceAll(ctrs[0].Name(), "_", ""),
+ kubeAnnotations,
+ kubeCtrs,
+ kubeVolumes,
+ &podDNS,
+ hostNetwork), nil
}
// containerToV1Container converts information we know about a libpod container
@@ -792,3 +817,21 @@ func generateKubeVolumeDeviceFromLinuxDevice(devices []specs.LinuxDevice) []v1.V
func removeUnderscores(s string) string {
return strings.Replace(s, "_", "", -1)
}
+
+// getAutoUpdateAnnotations searches for auto-update container labels
+// and returns them as kube annotations
+func getAutoUpdateAnnotations(ctrName string, ctrLabels map[string]string) map[string]string {
+ autoUpdateLabel := "io.containers.autoupdate"
+ annotations := make(map[string]string)
+
+ for k, v := range ctrLabels {
+ if strings.Contains(k, autoUpdateLabel) {
+ // since labels can variate between containers within a pod, they will be
+ // identified with the container name when converted into kube annotations
+ kc := fmt.Sprintf("%s/%s", k, ctrName)
+ annotations[kc] = v
+ }
+ }
+
+ return annotations
+}
diff --git a/libpod/options.go b/libpod/options.go
index 391cf0147..be26ced99 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1716,6 +1716,28 @@ func WithSecrets(secretNames []string) CtrCreateOption {
}
}
+// WithSecrets adds environment variable secrets to the container
+func WithEnvSecrets(envSecrets map[string]string) CtrCreateOption {
+ return func(ctr *Container) error {
+ ctr.config.EnvSecrets = make(map[string]*secrets.Secret)
+ if ctr.valid {
+ return define.ErrCtrFinalized
+ }
+ manager, err := secrets.NewManager(ctr.runtime.GetSecretsStorageDir())
+ if err != nil {
+ return err
+ }
+ for target, src := range envSecrets {
+ secr, err := manager.Lookup(src)
+ if err != nil {
+ return err
+ }
+ ctr.config.EnvSecrets[target] = secr
+ }
+ return nil
+ }
+}
+
// WithPidFile adds pidFile to the container
func WithPidFile(pidFile string) CtrCreateOption {
return func(ctr *Container) error {
diff --git a/pkg/domain/entities/containers.go b/pkg/domain/entities/containers.go
index 4707ced85..eacc14d50 100644
--- a/pkg/domain/entities/containers.go
+++ b/pkg/domain/entities/containers.go
@@ -265,6 +265,7 @@ type ContainerExistsOptions struct {
// ContainerStartOptions describes the val from the
// CLI needed to start a container
type ContainerStartOptions struct {
+ Filters map[string][]string
All bool
Attach bool
DetachKeys string
diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go
index 9ac72e415..965a12468 100644
--- a/pkg/domain/filters/containers.go
+++ b/pkg/domain/filters/containers.go
@@ -1,6 +1,7 @@
package filters
import (
+ "fmt"
"strconv"
"strings"
"time"
@@ -226,6 +227,32 @@ func GenerateContainerFilterFuncs(filter string, filterValues []string, r *libpo
}
return false
}, nil
+ case "restart-policy":
+ invalidPolicyNames := []string{}
+ for _, policy := range filterValues {
+ if _, ok := define.RestartPolicyMap[policy]; !ok {
+ invalidPolicyNames = append(invalidPolicyNames, policy)
+ }
+ }
+ var filterValueError error = nil
+ if len(invalidPolicyNames) > 0 {
+ errPrefix := "invalid restart policy"
+ if len(invalidPolicyNames) > 1 {
+ errPrefix = "invalid restart policies"
+ }
+ filterValueError = fmt.Errorf("%s %s", strings.Join(invalidPolicyNames, ", "), errPrefix)
+ }
+ return func(c *libpod.Container) bool {
+ for _, policy := range filterValues {
+ if policy == "none" && c.RestartPolicy() == define.RestartPolicyNone {
+ return true
+ }
+ if c.RestartPolicy() == policy {
+ return true
+ }
+ }
+ return false
+ }, filterValueError
}
return nil, errors.Errorf("%s is an invalid filter", filter)
}
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index ef3ccab0c..d0a2b1bae 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -694,7 +694,33 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID s
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
- ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
+ containersNamesOrIds := namesOrIds
+ if len(options.Filters) > 0 {
+ filterFuncs := make([]libpod.ContainerFilter, 0, len(options.Filters))
+ if len(options.Filters) > 0 {
+ for k, v := range options.Filters {
+ generatedFunc, err := dfilters.GenerateContainerFilterFuncs(k, v, ic.Libpod)
+ if err != nil {
+ return nil, err
+ }
+ filterFuncs = append(filterFuncs, generatedFunc)
+ }
+ }
+ candidates, err := ic.Libpod.GetContainers(filterFuncs...)
+ if err != nil {
+ return nil, err
+ }
+ containersNamesOrIds = []string{}
+ for _, candidate := range candidates {
+ for _, nameOrID := range namesOrIds {
+ if nameOrID == candidate.ID() || nameOrID == candidate.Name() {
+ containersNamesOrIds = append(containersNamesOrIds, nameOrID)
+ }
+ }
+ }
+ }
+
+ ctrs, rawInputs, err := getContainersAndInputByContext(options.All, options.Latest, containersNamesOrIds, ic.Libpod)
if err != nil {
return nil, err
}
diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go
index 64e7f208c..a94c5f5c5 100644
--- a/pkg/domain/infra/abi/play.go
+++ b/pkg/domain/infra/abi/play.go
@@ -16,6 +16,7 @@ import (
"github.com/containers/image/v5/types"
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
+ "github.com/containers/podman/v3/pkg/autoupdate"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/specgen"
"github.com/containers/podman/v3/pkg/specgen/generate"
@@ -73,7 +74,7 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options en
podTemplateSpec.ObjectMeta = podYAML.ObjectMeta
podTemplateSpec.Spec = podYAML.Spec
- r, err := ic.playKubePod(ctx, podTemplateSpec.ObjectMeta.Name, &podTemplateSpec, options, &ipIndex)
+ r, err := ic.playKubePod(ctx, podTemplateSpec.ObjectMeta.Name, &podTemplateSpec, options, &ipIndex, podYAML.Annotations)
if err != nil {
return nil, err
}
@@ -143,7 +144,7 @@ func (ic *ContainerEngine) playKubeDeployment(ctx context.Context, deploymentYAM
// create "replicas" number of pods
for i = 0; i < numReplicas; i++ {
podName := fmt.Sprintf("%s-pod-%d", deploymentName, i)
- podReport, err := ic.playKubePod(ctx, podName, &podSpec, options, ipIndex)
+ podReport, err := ic.playKubePod(ctx, podName, &podSpec, options, ipIndex, deploymentYAML.Annotations)
if err != nil {
return nil, errors.Wrapf(err, "error encountered while bringing up pod %s", podName)
}
@@ -152,7 +153,7 @@ func (ic *ContainerEngine) playKubeDeployment(ctx context.Context, deploymentYAM
return &report, nil
}
-func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec, options entities.PlayKubeOptions, ipIndex *int) (*entities.PlayKubeReport, error) {
+func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec, options entities.PlayKubeOptions, ipIndex *int, annotations map[string]string) (*entities.PlayKubeReport, error) {
var (
writer io.Writer
playKubePod entities.PlayKubePod
@@ -265,6 +266,9 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
containers := make([]*libpod.Container, 0, len(podYAML.Spec.Containers))
for _, container := range podYAML.Spec.Containers {
+ // Contains all labels obtained from kube
+ labels := make(map[string]string)
+
// NOTE: set the pull policy to "newer". This will cover cases
// where the "latest" tag requires a pull and will also
// transparently handle "localhost/" prefixed files which *may*
@@ -292,6 +296,22 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
return nil, err
}
+ // Handle kube annotations
+ for k, v := range annotations {
+ switch k {
+ // Auto update annotation without container name will apply to
+ // all containers within the pod
+ case autoupdate.Label, autoupdate.AuthfileLabel:
+ labels[k] = v
+ // Auto update annotation with container name will apply only
+ // to the specified container
+ case fmt.Sprintf("%s/%s", autoupdate.Label, container.Name),
+ fmt.Sprintf("%s/%s", autoupdate.AuthfileLabel, container.Name):
+ prefixAndCtr := strings.Split(k, "/")
+ labels[prefixAndCtr[0]] = v
+ }
+ }
+
specgenOpts := kube.CtrSpecGenOptions{
Container: container,
Image: pulledImages[0],
@@ -305,6 +325,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
NetNSIsHost: p.NetNS.IsHost(),
SecretsManager: secretsManager,
LogDriver: options.LogDriver,
+ Labels: labels,
}
specGen, err := kube.ToSpecGen(ctx, &specgenOpts)
if err != nil {
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index aa26825e0..3830835cc 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -506,7 +506,30 @@ func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input,
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
- ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, namesOrIds)
+ containersNamesOrIds := namesOrIds
+ if len(options.Filters) > 0 {
+ containersNamesOrIds = []string{}
+ opts := new(containers.ListOptions).WithFilters(options.Filters).WithAll(true)
+ candidates, listErr := containers.List(ic.ClientCtx, opts)
+ if listErr != nil {
+ return nil, listErr
+ }
+ for _, candidate := range candidates {
+ for _, nameOrID := range namesOrIds {
+ if nameOrID == candidate.ID {
+ containersNamesOrIds = append(containersNamesOrIds, nameOrID)
+ continue
+ }
+ for _, containerName := range candidate.Names {
+ if containerName == nameOrID {
+ containersNamesOrIds = append(containersNamesOrIds, nameOrID)
+ continue
+ }
+ }
+ }
+ }
+ }
+ ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, containersNamesOrIds)
if err != nil {
return nil, err
}
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index 0090156c9..7682367b7 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -402,6 +402,11 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen.
if len(s.Secrets) != 0 {
options = append(options, libpod.WithSecrets(s.Secrets))
}
+
+ if len(s.EnvSecrets) != 0 {
+ options = append(options, libpod.WithEnvSecrets(s.EnvSecrets))
+ }
+
if len(s.DependencyContainers) > 0 {
deps := make([]*libpod.Container, 0, len(s.DependencyContainers))
for _, ctr := range s.DependencyContainers {
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index 73c1c31ba..ccce3edba 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -100,6 +100,8 @@ type CtrSpecGenOptions struct {
SecretsManager *secrets.SecretsManager
// LogDriver which should be used for the container
LogDriver string
+ // Labels define key-value pairs of metadata
+ Labels map[string]string
}
func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGenerator, error) {
@@ -278,6 +280,19 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
s.NetNS.NSMode = specgen.Host
}
+ // Add labels that come from kube
+ if len(s.Labels) == 0 {
+ // If there are no labels, let's use the map that comes
+ // from kube
+ s.Labels = opts.Labels
+ } else {
+ // If there are already labels in the map, append the ones
+ // obtained from kube
+ for k, v := range opts.Labels {
+ s.Labels[k] = v
+ }
+ }
+
return s, nil
}
diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go
index 5ef2b0653..2e01d1535 100644
--- a/pkg/specgen/specgen.go
+++ b/pkg/specgen/specgen.go
@@ -180,6 +180,9 @@ type ContainerBasicConfig struct {
// set tags as `json:"-"` for not supported remote
// Optional.
PidFile string `json:"-"`
+ // EnvSecrets are secrets that will be set as environment variables
+ // Optional.
+ EnvSecrets map[string]string `json:"secret_env,omitempty"`
}
// ContainerStorageConfig contains information on the storage configuration of a
diff --git a/test/e2e/commit_test.go b/test/e2e/commit_test.go
index 0d3f2bed7..70a66124a 100644
--- a/test/e2e/commit_test.go
+++ b/test/e2e/commit_test.go
@@ -304,4 +304,28 @@ var _ = Describe("Podman commit", func() {
Expect(session.ExitCode()).To(Not(Equal(0)))
})
+
+ It("podman commit should not commit env secret", func() {
+ secretsString := "somesecretdata"
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal(secretsString))
+
+ session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.OutputToString()).To(Not(ContainSubstring(secretsString)))
+ })
})
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 8530d3dd3..359345096 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -605,13 +605,6 @@ func SkipIfRootlessCgroupsV1(reason string) {
}
}
-func SkipIfUnprivilegedCPULimits() {
- info := GetHostDistributionInfo()
- if isRootless() && info.Distribution == "fedora" {
- ginkgo.Skip("Rootless Fedora doesn't have permission to set CPU limits")
- }
-}
-
func SkipIfRootless(reason string) {
checkReason(reason)
if os.Geteuid() != 0 {
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 611e8ddac..4c0fc6db0 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -873,4 +873,54 @@ USER test1`
}
}
})
+
+ It("podman generate kube on container with auto update labels", func() {
+ top := podmanTest.Podman([]string{"run", "-dt", "--name", "top", "--label", "io.containers.autoupdate=local", ALPINE, "top"})
+ top.WaitWithDefaultTimeout()
+ Expect(top.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "top"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+
+ v, ok := pod.GetAnnotations()["io.containers.autoupdate/top"]
+ Expect(ok).To(Equal(true))
+ Expect(v).To(Equal("local"))
+ })
+
+ It("podman generate kube on pod with auto update labels in all containers", func() {
+ pod1 := podmanTest.Podman([]string{"pod", "create", "--name", "pod1"})
+ pod1.WaitWithDefaultTimeout()
+ Expect(pod1.ExitCode()).To(Equal(0))
+
+ top1 := podmanTest.Podman([]string{"run", "-dt", "--name", "top1", "--pod", "pod1", "--label", "io.containers.autoupdate=registry", "--label", "io.containers.autoupdate.authfile=/some/authfile.json", ALPINE, "top"})
+ top1.WaitWithDefaultTimeout()
+ Expect(top1.ExitCode()).To(Equal(0))
+
+ top2 := podmanTest.Podman([]string{"run", "-dt", "--name", "top2", "--pod", "pod1", "--label", "io.containers.autoupdate=registry", "--label", "io.containers.autoupdate.authfile=/some/authfile.json", ALPINE, "top"})
+ top2.WaitWithDefaultTimeout()
+ Expect(top2.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "pod1"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+
+ for _, ctr := range []string{"top1", "top2"} {
+ v, ok := pod.GetAnnotations()["io.containers.autoupdate/"+ctr]
+ Expect(ok).To(Equal(true))
+ Expect(v).To(Equal("registry"))
+
+ v, ok = pod.GetAnnotations()["io.containers.autoupdate.authfile/"+ctr]
+ Expect(ok).To(Equal(true))
+ Expect(v).To(Equal("/some/authfile.json"))
+ }
+ })
})
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 836fbe1ee..3908d4075 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -768,6 +768,12 @@ func getCtr(options ...ctrOption) *Ctr {
type ctrOption func(*Ctr)
+func withName(name string) ctrOption {
+ return func(c *Ctr) {
+ c.Name = name
+ }
+}
+
func withCmd(cmd []string) ctrOption {
return func(c *Ctr) {
c.Cmd = cmd
@@ -1999,8 +2005,7 @@ VOLUME %s`, ALPINE, hostPathDir+"/")
It("podman play kube allows setting resource limits", func() {
SkipIfContainerized("Resource limits require a running systemd")
- SkipIfRootlessCgroupsV1("Limits require root or cgroups v2")
- SkipIfUnprivilegedCPULimits()
+ SkipIfRootless("CPU limits require root")
podmanTest.CgroupManager = "systemd"
var (
@@ -2305,4 +2310,79 @@ invalid kube kind
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Not(Equal(0)))
})
+
+ It("podman play kube with auto update annotations for all containers", func() {
+ ctr01Name := "ctr01"
+ ctr02Name := "ctr02"
+ podName := "foo"
+ autoUpdateRegistry := "io.containers.autoupdate"
+ autoUpdateRegistryValue := "registry"
+ autoUpdateAuthfile := "io.containers.autoupdate.authfile"
+ autoUpdateAuthfileValue := "/some/authfile.json"
+
+ ctr01 := getCtr(withName(ctr01Name))
+ ctr02 := getCtr(withName(ctr02Name))
+
+ pod := getPod(
+ withPodName(podName),
+ withCtr(ctr01),
+ withCtr(ctr02),
+ withAnnotation(autoUpdateRegistry, autoUpdateRegistryValue),
+ withAnnotation(autoUpdateAuthfile, autoUpdateAuthfileValue))
+
+ err = generateKubeYaml("pod", pod, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ for _, ctr := range []string{podName + "-" + ctr01Name, podName + "-" + ctr02Name} {
+ inspect := podmanTest.Podman([]string{"inspect", ctr, "--format", "'{{.Config.Labels}}'"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+
+ Expect(inspect.OutputToString()).To(ContainSubstring(autoUpdateRegistry + ":" + autoUpdateRegistryValue))
+ Expect(inspect.OutputToString()).To(ContainSubstring(autoUpdateAuthfile + ":" + autoUpdateAuthfileValue))
+ }
+ })
+
+ It("podman play kube with auto update annotations for first container only", func() {
+ ctr01Name := "ctr01"
+ ctr02Name := "ctr02"
+ autoUpdateRegistry := "io.containers.autoupdate"
+ autoUpdateRegistryValue := "local"
+
+ ctr01 := getCtr(withName(ctr01Name))
+ ctr02 := getCtr(withName(ctr02Name))
+
+ pod := getPod(
+ withCtr(ctr01),
+ withCtr(ctr02),
+ )
+
+ deployment := getDeployment(
+ withPod(pod),
+ withDeploymentAnnotation(autoUpdateRegistry+"/"+ctr01Name, autoUpdateRegistryValue),
+ )
+
+ err = generateKubeYaml("deployment", deployment, kubeYaml)
+ Expect(err).To(BeNil())
+
+ kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ podName := getPodNamesInDeployment(deployment)[0].Name
+
+ inspect := podmanTest.Podman([]string{"inspect", podName + "-" + ctr01Name, "--format", "'{{.Config.Labels}}'"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(autoUpdateRegistry + ":" + autoUpdateRegistryValue))
+
+ inspect = podmanTest.Podman([]string{"inspect", podName + "-" + ctr02Name, "--format", "'{{.Config.Labels}}'"})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(ContainSubstring(`map[]`))
+ })
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index d8d7dab07..59220cf01 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -921,6 +921,17 @@ USER mail`, BB)
Expect(session.OutputToString()).To(ContainSubstring("mail root"))
})
+ It("podman run with incorect VOLUME", func() {
+ dockerfile := fmt.Sprintf(`FROM %s
+VOLUME ['/etc/foo']
+WORKDIR /etc/foo`, BB)
+ podmanTest.BuildImage(dockerfile, "test", "false")
+ session := podmanTest.Podman([]string{"run", "--rm", "test", "echo", "test"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring("test"))
+ })
+
It("podman run --volumes-from flag", func() {
vol := filepath.Join(podmanTest.TempDir, "vol-test")
err := os.MkdirAll(vol, 0755)
@@ -1600,6 +1611,95 @@ WORKDIR /madethis`, BB)
})
+ It("podman run --secret source=mysecret,type=mount", func() {
+ secretsString := "somesecretdata"
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=mount", "--name", "secr", ALPINE, "cat", "/run/secrets/mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal(secretsString))
+
+ session = podmanTest.Podman([]string{"inspect", "secr", "--format", " {{(index .Config.Secrets 0).Name}}"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(ContainSubstring("mysecret"))
+
+ })
+
+ It("podman run --secret source=mysecret,type=env", func() {
+ secretsString := "somesecretdata"
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal(secretsString))
+ })
+
+ It("podman run --secret target option", func() {
+ secretsString := "somesecretdata"
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ // target with mount type should fail
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=mount,target=anotherplace", "--name", "secr", ALPINE, "cat", "/run/secrets/mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=env,target=anotherplace", "--name", "secr", ALPINE, "printenv", "anotherplace"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal(secretsString))
+ })
+
+ It("podman run invalid secret option", func() {
+ secretsString := "somesecretdata"
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Invalid type
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type=other", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ // Invalid option
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,invalid=invalid", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ // Option syntax not valid
+ session = podmanTest.Podman([]string{"run", "--secret", "source=mysecret,type", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ // No source given
+ session = podmanTest.Podman([]string{"run", "--secret", "type=env", "--name", "secr", ALPINE, "printenv", "mysecret"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
+
It("podman run --requires", func() {
depName := "ctr1"
depContainer := podmanTest.Podman([]string{"create", "--name", depName, ALPINE, "top"})
diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go
index fbee18442..b54b959bf 100644
--- a/test/e2e/secret_test.go
+++ b/test/e2e/secret_test.go
@@ -199,4 +199,27 @@ var _ = Describe("Podman secret", func() {
Expect(len(session.OutputToStringArray())).To(Equal(1))
})
+ It("podman secret creates from environment variable", func() {
+ // no env variable set, should fail
+ session := podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
+ session.WaitWithDefaultTimeout()
+ secrID := session.OutputToString()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+
+ os.Setenv("MYENVVAR", "somedata")
+ if IsRemote() {
+ podmanTest.RestartRemoteService()
+ }
+
+ session = podmanTest.Podman([]string{"secret", "create", "--env", "a", "MYENVVAR"})
+ session.WaitWithDefaultTimeout()
+ secrID = session.OutputToString()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ inspect := podmanTest.Podman([]string{"secret", "inspect", "--format", "{{.ID}}", secrID})
+ inspect.WaitWithDefaultTimeout()
+ Expect(inspect.ExitCode()).To(Equal(0))
+ Expect(inspect.OutputToString()).To(Equal(secrID))
+ })
+
})
diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats
index 35107f0a0..5d44c373f 100644
--- a/test/system/001-basic.bats
+++ b/test/system/001-basic.bats
@@ -10,16 +10,18 @@ function setup() {
:
}
-@test "podman --context emits reasonable output" {
- run_podman 125 --context=swarm version
- is "$output" "Error: Podman does not support swarm, the only --context value allowed is \"default\"" "--context=default or fail"
-
- run_podman --context=default version
-}
+#### DO NOT ADD ANY TESTS HERE! ADD NEW TESTS AT BOTTOM!
@test "podman version emits reasonable output" {
run_podman version
+ # FIXME FIXME FIXME: #10248: nasty message on Ubuntu cgroups v1, rootless
+ if [[ "$output" =~ "overlay test mount with multiple lowers failed" ]]; then
+ if is_rootless; then
+ lines=("${lines[@]:1}")
+ fi
+ fi
+
# First line of podman-remote is "Client:<blank>".
# Just delete it (i.e. remove the first entry from the 'lines' array)
if is_remote; then
@@ -41,6 +43,17 @@ function setup() {
}
+@test "podman --context emits reasonable output" {
+ # All we care about here is that the command passes
+ run_podman --context=default version
+
+ # This one must fail
+ run_podman 125 --context=swarm version
+ is "$output" \
+ "Error: Podman does not support swarm, the only --context value allowed is \"default\"" \
+ "--context=default or fail"
+}
+
@test "podman can pull an image" {
run_podman pull $IMAGE
}
diff --git a/test/system/045-start.bats b/test/system/045-start.bats
index ff818e51d..542f9d1c2 100644
--- a/test/system/045-start.bats
+++ b/test/system/045-start.bats
@@ -40,4 +40,21 @@ load helpers
fi
}
+@test "podman start --filter - start only containers that match the filter" {
+ run_podman run -d $IMAGE /bin/true
+ cid="$output"
+ run_podman start --filter restart-policy=always $cid "CID of restart-policy=always container"
+ is "$output" ""
+
+ run_podman start --filter restart-policy=none $cid "CID of restart-policy=none container"
+ is "$output" "$cid"
+}
+
+@test "podman start --filter invalid-restart-policy - return error" {
+ run_podman run -d $IMAGE /bin/true
+ cid="$output"
+ run_podman 125 start --filter restart-policy=fakepolicy $cid "CID of restart-policy=<not-exists> container"
+ is "$output" "Error: fakepolicy invalid restart policy"
+}
+
# vim: filetype=sh
diff --git a/test/system/410-selinux.bats b/test/system/410-selinux.bats
index 95233c1e6..f8cee0e59 100644
--- a/test/system/410-selinux.bats
+++ b/test/system/410-selinux.bats
@@ -198,20 +198,23 @@ function check_label() {
skip_if_no_selinux
LABEL="system_u:object_r:tmp_t:s0"
+ RELABEL="system_u:object_r:container_file_t:s0"
tmpdir=$PODMAN_TMPDIR/vol
touch $tmpdir
chcon -vR ${LABEL} $tmpdir
ls -Z $tmpdir
run_podman run -v $tmpdir:/test $IMAGE cat /proc/self/attr/current
- level=$(secon -l $output)
run ls -dZ ${tmpdir}
is "$output" ${LABEL} "No Relabel Correctly"
- run_podman run -v $tmpdir:/test:Z --security-opt label=disable $IMAGE cat /proc/self/attr/current
- level=$(secon -l $output)
+ run_podman run -v $tmpdir:/test:z --security-opt label=disable $IMAGE cat /proc/self/attr/current
+ run ls -dZ $tmpdir
+ is "$output" ${RELABEL} "Privileged Relabel Correctly"
+
+ run_podman run -v $tmpdir:/test:z --privileged $IMAGE cat /proc/self/attr/current
run ls -dZ $tmpdir
- is "$output" ${LABEL} "No Privileged Relabel Correctly"
+ is "$output" ${RELABEL} "Privileged Relabel Correctly"
run_podman run -v $tmpdir:/test:Z $IMAGE cat /proc/self/attr/current
level=$(secon -l $output)
@@ -220,7 +223,7 @@ function check_label() {
run_podman run -v $tmpdir:/test:z $IMAGE cat /proc/self/attr/current
run ls -dZ $tmpdir
- is "$output" "system_u:object_r:container_file_t:s0" "Shared Relabel Correctly"
+ is "$output" ${RELABEL} "Shared Relabel Correctly"
}
# vim: filetype=sh
diff --git a/vendor/github.com/containerd/continuity/AUTHORS b/vendor/github.com/containerd/continuity/AUTHORS
deleted file mode 100644
index 376ceb93d..000000000
--- a/vendor/github.com/containerd/continuity/AUTHORS
+++ /dev/null
@@ -1,40 +0,0 @@
-Aaron Lehmann <aaron.lehmann@docker.com>
-Akash Gupta <akagup@microsoft.com>
-Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
-Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
-Akihiro Suda <suda.kyoto@gmail.com>
-Andrew Pennebaker <apennebaker@datapipe.com>
-Brandon Philips <brandon.philips@coreos.com>
-Brian Goff <cpuguy83@gmail.com>
-Christopher Jones <tophj@linux.vnet.ibm.com>
-Daniel, Dao Quang Minh <dqminh89@gmail.com>
-Darren Stahl <darst@microsoft.com>
-Derek McGowan <derek@mcg.dev>
-Derek McGowan <derek@mcgstyle.net>
-Edward Pilatowicz <edward.pilatowicz@oracle.com>
-Ian Campbell <ijc@docker.com>
-Ivan Markin <sw@nogoegst.net>
-Justin Cormack <justin.cormack@docker.com>
-Justin Cummins <sul3n3t@gmail.com>
-Kasper Fabæch Brandt <poizan@poizan.dk>
-Kir Kolyshkin <kolyshkin@gmail.com>
-Michael Crosby <crosbymichael@gmail.com>
-Michael Crosby <michael@thepasture.io>
-Michael Wan <zirenwan@gmail.com>
-Mike Brown <brownwm@us.ibm.com>
-Niels de Vos <ndevos@redhat.com>
-Phil Estes <estesp@gmail.com>
-Phil Estes <estesp@linux.vnet.ibm.com>
-Samuel Karp <me@samuelkarp.com>
-Sam Whited <sam@samwhited.com>
-Sebastiaan van Stijn <github@gone.nl>
-Shengjing Zhu <zhsj@debian.org>
-Stephen J Day <stephen.day@docker.com>
-Tibor Vass <tibor@docker.com>
-Tobias Klauser <tklauser@distanz.ch>
-Tom Faulhaber <tffaulha@amazon.com>
-Tonis Tiigi <tonistiigi@gmail.com>
-Trevor Porter <trkporter@ucdavis.edu>
-Wei Fu <fuweid89@gmail.com>
-Wilbert van de Ridder <wilbert.ridder@gmail.com>
-Xiaodong Ye <xiaodongy@vmware.com>
diff --git a/vendor/github.com/containerd/continuity/LICENSE b/vendor/github.com/containerd/continuity/LICENSE
deleted file mode 100644
index 584149b6e..000000000
--- a/vendor/github.com/containerd/continuity/LICENSE
+++ /dev/null
@@ -1,191 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- Copyright The containerd Authors
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/vendor/github.com/containerd/continuity/fs/copy.go b/vendor/github.com/containerd/continuity/fs/copy.go
deleted file mode 100644
index 818bba2cd..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "io/ioutil"
- "os"
- "path/filepath"
- "sync"
-
- "github.com/pkg/errors"
-)
-
-var bufferPool = &sync.Pool{
- New: func() interface{} {
- buffer := make([]byte, 32*1024)
- return &buffer
- },
-}
-
-// XAttrErrorHandlers transform a non-nil xattr error.
-// Return nil to ignore an error.
-// xattrKey can be empty for listxattr operation.
-type XAttrErrorHandler func(dst, src, xattrKey string, err error) error
-
-type copyDirOpts struct {
- xeh XAttrErrorHandler
-}
-
-type CopyDirOpt func(*copyDirOpts) error
-
-// WithXAttrErrorHandler allows specifying XAttrErrorHandler
-// If nil XAttrErrorHandler is specified (default), CopyDir stops
-// on a non-nil xattr error.
-func WithXAttrErrorHandler(xeh XAttrErrorHandler) CopyDirOpt {
- return func(o *copyDirOpts) error {
- o.xeh = xeh
- return nil
- }
-}
-
-// WithAllowXAttrErrors allows ignoring xattr errors.
-func WithAllowXAttrErrors() CopyDirOpt {
- xeh := func(dst, src, xattrKey string, err error) error {
- return nil
- }
- return WithXAttrErrorHandler(xeh)
-}
-
-// CopyDir copies the directory from src to dst.
-// Most efficient copy of files is attempted.
-func CopyDir(dst, src string, opts ...CopyDirOpt) error {
- var o copyDirOpts
- for _, opt := range opts {
- if err := opt(&o); err != nil {
- return err
- }
- }
- inodes := map[uint64]string{}
- return copyDirectory(dst, src, inodes, &o)
-}
-
-func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) error {
- stat, err := os.Stat(src)
- if err != nil {
- return errors.Wrapf(err, "failed to stat %s", src)
- }
- if !stat.IsDir() {
- return errors.Errorf("source %s is not directory", src)
- }
-
- if st, err := os.Stat(dst); err != nil {
- if err := os.Mkdir(dst, stat.Mode()); err != nil {
- return errors.Wrapf(err, "failed to mkdir %s", dst)
- }
- } else if !st.IsDir() {
- return errors.Errorf("cannot copy to non-directory: %s", dst)
- } else {
- if err := os.Chmod(dst, stat.Mode()); err != nil {
- return errors.Wrapf(err, "failed to chmod on %s", dst)
- }
- }
-
- fis, err := ioutil.ReadDir(src)
- if err != nil {
- return errors.Wrapf(err, "failed to read %s", src)
- }
-
- if err := copyFileInfo(stat, dst); err != nil {
- return errors.Wrapf(err, "failed to copy file info for %s", dst)
- }
-
- if err := copyXAttrs(dst, src, o.xeh); err != nil {
- return errors.Wrap(err, "failed to copy xattrs")
- }
-
- for _, fi := range fis {
- source := filepath.Join(src, fi.Name())
- target := filepath.Join(dst, fi.Name())
-
- switch {
- case fi.IsDir():
- if err := copyDirectory(target, source, inodes, o); err != nil {
- return err
- }
- continue
- case (fi.Mode() & os.ModeType) == 0:
- link, err := getLinkSource(target, fi, inodes)
- if err != nil {
- return errors.Wrap(err, "failed to get hardlink")
- }
- if link != "" {
- if err := os.Link(link, target); err != nil {
- return errors.Wrap(err, "failed to create hard link")
- }
- } else if err := CopyFile(target, source); err != nil {
- return errors.Wrap(err, "failed to copy files")
- }
- case (fi.Mode() & os.ModeSymlink) == os.ModeSymlink:
- link, err := os.Readlink(source)
- if err != nil {
- return errors.Wrapf(err, "failed to read link: %s", source)
- }
- if err := os.Symlink(link, target); err != nil {
- return errors.Wrapf(err, "failed to create symlink: %s", target)
- }
- case (fi.Mode() & os.ModeDevice) == os.ModeDevice:
- if err := copyDevice(target, fi); err != nil {
- return errors.Wrapf(err, "failed to create device")
- }
- default:
- // TODO: Support pipes and sockets
- return errors.Wrapf(err, "unsupported mode %s", fi.Mode())
- }
- if err := copyFileInfo(fi, target); err != nil {
- return errors.Wrap(err, "failed to copy file info")
- }
-
- if err := copyXAttrs(target, source, o.xeh); err != nil {
- return errors.Wrap(err, "failed to copy xattrs")
- }
- }
-
- return nil
-}
-
-// CopyFile copies the source file to the target.
-// The most efficient means of copying is used for the platform.
-func CopyFile(target, source string) error {
- src, err := os.Open(source)
- if err != nil {
- return errors.Wrapf(err, "failed to open source %s", source)
- }
- defer src.Close()
- tgt, err := os.Create(target)
- if err != nil {
- return errors.Wrapf(err, "failed to open target %s", target)
- }
- defer tgt.Close()
-
- return copyFileContent(tgt, src)
-}
diff --git a/vendor/github.com/containerd/continuity/fs/copy_darwinopenbsdsolaris.go b/vendor/github.com/containerd/continuity/fs/copy_darwinopenbsdsolaris.go
deleted file mode 100644
index 92ccacf9a..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy_darwinopenbsdsolaris.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// +build darwin openbsd solaris
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "os"
- "syscall"
-
- "github.com/pkg/errors"
- "golang.org/x/sys/unix"
-)
-
-func copyDevice(dst string, fi os.FileInfo) error {
- st, ok := fi.Sys().(*syscall.Stat_t)
- if !ok {
- return errors.New("unsupported stat type")
- }
- return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev))
-}
-
-func utimesNano(name string, atime, mtime syscall.Timespec) error {
- timespec := []syscall.Timespec{atime, mtime}
- return syscall.UtimesNano(name, timespec)
-}
diff --git a/vendor/github.com/containerd/continuity/fs/copy_freebsd.go b/vendor/github.com/containerd/continuity/fs/copy_freebsd.go
deleted file mode 100644
index 4b116c95e..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy_freebsd.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// +build freebsd
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "os"
- "syscall"
-
- "github.com/pkg/errors"
- "golang.org/x/sys/unix"
-)
-
-func copyDevice(dst string, fi os.FileInfo) error {
- st, ok := fi.Sys().(*syscall.Stat_t)
- if !ok {
- return errors.New("unsupported stat type")
- }
- return unix.Mknod(dst, uint32(fi.Mode()), st.Rdev)
-}
-
-func utimesNano(name string, atime, mtime syscall.Timespec) error {
- at := unix.NsecToTimespec(atime.Nano())
- mt := unix.NsecToTimespec(mtime.Nano())
- utimes := [2]unix.Timespec{at, mt}
- return unix.UtimesNanoAt(unix.AT_FDCWD, name, utimes[0:], unix.AT_SYMLINK_NOFOLLOW)
-}
diff --git a/vendor/github.com/containerd/continuity/fs/copy_linux.go b/vendor/github.com/containerd/continuity/fs/copy_linux.go
deleted file mode 100644
index 72bae7d4e..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy_linux.go
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "io"
- "os"
- "syscall"
-
- "github.com/containerd/continuity/sysx"
- "github.com/pkg/errors"
- "golang.org/x/sys/unix"
-)
-
-func copyFileInfo(fi os.FileInfo, name string) error {
- st := fi.Sys().(*syscall.Stat_t)
- if err := os.Lchown(name, int(st.Uid), int(st.Gid)); err != nil {
- if os.IsPermission(err) {
- // Normally if uid/gid are the same this would be a no-op, but some
- // filesystems may still return EPERM... for instance NFS does this.
- // In such a case, this is not an error.
- if dstStat, err2 := os.Lstat(name); err2 == nil {
- st2 := dstStat.Sys().(*syscall.Stat_t)
- if st.Uid == st2.Uid && st.Gid == st2.Gid {
- err = nil
- }
- }
- }
- if err != nil {
- return errors.Wrapf(err, "failed to chown %s", name)
- }
- }
-
- if (fi.Mode() & os.ModeSymlink) != os.ModeSymlink {
- if err := os.Chmod(name, fi.Mode()); err != nil {
- return errors.Wrapf(err, "failed to chmod %s", name)
- }
- }
-
- timespec := []unix.Timespec{
- unix.NsecToTimespec(syscall.TimespecToNsec(StatAtime(st))),
- unix.NsecToTimespec(syscall.TimespecToNsec(StatMtime(st))),
- }
- if err := unix.UtimesNanoAt(unix.AT_FDCWD, name, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil {
- return errors.Wrapf(err, "failed to utime %s", name)
- }
-
- return nil
-}
-
-const maxSSizeT = int64(^uint(0) >> 1)
-
-func copyFileContent(dst, src *os.File) error {
- st, err := src.Stat()
- if err != nil {
- return errors.Wrap(err, "unable to stat source")
- }
-
- size := st.Size()
- first := true
- srcFd := int(src.Fd())
- dstFd := int(dst.Fd())
-
- for size > 0 {
- // Ensure that we are never trying to copy more than SSIZE_MAX at a
- // time and at the same time avoids overflows when the file is larger
- // than 4GB on 32-bit systems.
- var copySize int
- if size > maxSSizeT {
- copySize = int(maxSSizeT)
- } else {
- copySize = int(size)
- }
- n, err := unix.CopyFileRange(srcFd, nil, dstFd, nil, copySize, 0)
- if err != nil {
- if (err != unix.ENOSYS && err != unix.EXDEV) || !first {
- return errors.Wrap(err, "copy file range failed")
- }
-
- buf := bufferPool.Get().(*[]byte)
- _, err = io.CopyBuffer(dst, src, *buf)
- bufferPool.Put(buf)
- return errors.Wrap(err, "userspace copy failed")
- }
-
- first = false
- size -= int64(n)
- }
-
- return nil
-}
-
-func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
- xattrKeys, err := sysx.LListxattr(src)
- if err != nil {
- e := errors.Wrapf(err, "failed to list xattrs on %s", src)
- if xeh != nil {
- e = xeh(dst, src, "", e)
- }
- return e
- }
- for _, xattr := range xattrKeys {
- data, err := sysx.LGetxattr(src, xattr)
- if err != nil {
- e := errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src)
- if xeh != nil {
- if e = xeh(dst, src, xattr, e); e == nil {
- continue
- }
- }
- return e
- }
- if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil {
- e := errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst)
- if xeh != nil {
- if e = xeh(dst, src, xattr, e); e == nil {
- continue
- }
- }
- return e
- }
- }
-
- return nil
-}
-
-func copyDevice(dst string, fi os.FileInfo) error {
- st, ok := fi.Sys().(*syscall.Stat_t)
- if !ok {
- return errors.New("unsupported stat type")
- }
- return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev))
-}
diff --git a/vendor/github.com/containerd/continuity/fs/copy_unix.go b/vendor/github.com/containerd/continuity/fs/copy_unix.go
deleted file mode 100644
index dfd857aaa..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy_unix.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// +build darwin freebsd openbsd solaris
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "io"
- "os"
- "syscall"
-
- "github.com/containerd/continuity/sysx"
- "github.com/pkg/errors"
-)
-
-func copyFileInfo(fi os.FileInfo, name string) error {
- st := fi.Sys().(*syscall.Stat_t)
- if err := os.Lchown(name, int(st.Uid), int(st.Gid)); err != nil {
- if os.IsPermission(err) {
- // Normally if uid/gid are the same this would be a no-op, but some
- // filesystems may still return EPERM... for instance NFS does this.
- // In such a case, this is not an error.
- if dstStat, err2 := os.Lstat(name); err2 == nil {
- st2 := dstStat.Sys().(*syscall.Stat_t)
- if st.Uid == st2.Uid && st.Gid == st2.Gid {
- err = nil
- }
- }
- }
- if err != nil {
- return errors.Wrapf(err, "failed to chown %s", name)
- }
- }
-
- if (fi.Mode() & os.ModeSymlink) != os.ModeSymlink {
- if err := os.Chmod(name, fi.Mode()); err != nil {
- return errors.Wrapf(err, "failed to chmod %s", name)
- }
- }
-
- if err := utimesNano(name, StatAtime(st), StatMtime(st)); err != nil {
- return errors.Wrapf(err, "failed to utime %s", name)
- }
-
- return nil
-}
-
-func copyFileContent(dst, src *os.File) error {
- buf := bufferPool.Get().(*[]byte)
- _, err := io.CopyBuffer(dst, src, *buf)
- bufferPool.Put(buf)
-
- return err
-}
-
-func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
- xattrKeys, err := sysx.LListxattr(src)
- if err != nil {
- e := errors.Wrapf(err, "failed to list xattrs on %s", src)
- if xeh != nil {
- e = xeh(dst, src, "", e)
- }
- return e
- }
- for _, xattr := range xattrKeys {
- data, err := sysx.LGetxattr(src, xattr)
- if err != nil {
- e := errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src)
- if xeh != nil {
- if e = xeh(dst, src, xattr, e); e == nil {
- continue
- }
- }
- return e
- }
- if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil {
- e := errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst)
- if xeh != nil {
- if e = xeh(dst, src, xattr, e); e == nil {
- continue
- }
- }
- return e
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/containerd/continuity/fs/copy_windows.go b/vendor/github.com/containerd/continuity/fs/copy_windows.go
deleted file mode 100644
index 27c7d7dbb..000000000
--- a/vendor/github.com/containerd/continuity/fs/copy_windows.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "io"
- "os"
-
- "github.com/pkg/errors"
-)
-
-func copyFileInfo(fi os.FileInfo, name string) error {
- if err := os.Chmod(name, fi.Mode()); err != nil {
- return errors.Wrapf(err, "failed to chmod %s", name)
- }
-
- // TODO: copy windows specific metadata
-
- return nil
-}
-
-func copyFileContent(dst, src *os.File) error {
- buf := bufferPool.Get().(*[]byte)
- _, err := io.CopyBuffer(dst, src, *buf)
- bufferPool.Put(buf)
- return err
-}
-
-func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
- return nil
-}
-
-func copyDevice(dst string, fi os.FileInfo) error {
- return errors.New("device copy not supported")
-}
diff --git a/vendor/github.com/containerd/continuity/fs/diff.go b/vendor/github.com/containerd/continuity/fs/diff.go
deleted file mode 100644
index e64f9e73d..000000000
--- a/vendor/github.com/containerd/continuity/fs/diff.go
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "context"
- "os"
- "path/filepath"
- "strings"
-
- "golang.org/x/sync/errgroup"
-
- "github.com/sirupsen/logrus"
-)
-
-// ChangeKind is the type of modification that
-// a change is making.
-type ChangeKind int
-
-const (
- // ChangeKindUnmodified represents an unmodified
- // file
- ChangeKindUnmodified = iota
-
- // ChangeKindAdd represents an addition of
- // a file
- ChangeKindAdd
-
- // ChangeKindModify represents a change to
- // an existing file
- ChangeKindModify
-
- // ChangeKindDelete represents a delete of
- // a file
- ChangeKindDelete
-)
-
-func (k ChangeKind) String() string {
- switch k {
- case ChangeKindUnmodified:
- return "unmodified"
- case ChangeKindAdd:
- return "add"
- case ChangeKindModify:
- return "modify"
- case ChangeKindDelete:
- return "delete"
- default:
- return ""
- }
-}
-
-// Change represents single change between a diff and its parent.
-type Change struct {
- Kind ChangeKind
- Path string
-}
-
-// ChangeFunc is the type of function called for each change
-// computed during a directory changes calculation.
-type ChangeFunc func(ChangeKind, string, os.FileInfo, error) error
-
-// Changes computes changes between two directories calling the
-// given change function for each computed change. The first
-// directory is intended to the base directory and second
-// directory the changed directory.
-//
-// The change callback is called by the order of path names and
-// should be appliable in that order.
-// Due to this apply ordering, the following is true
-// - Removed directory trees only create a single change for the root
-// directory removed. Remaining changes are implied.
-// - A directory which is modified to become a file will not have
-// delete entries for sub-path items, their removal is implied
-// by the removal of the parent directory.
-//
-// Opaque directories will not be treated specially and each file
-// removed from the base directory will show up as a removal.
-//
-// File content comparisons will be done on files which have timestamps
-// which may have been truncated. If either of the files being compared
-// has a zero value nanosecond value, each byte will be compared for
-// differences. If 2 files have the same seconds value but different
-// nanosecond values where one of those values is zero, the files will
-// be considered unchanged if the content is the same. This behavior
-// is to account for timestamp truncation during archiving.
-func Changes(ctx context.Context, a, b string, changeFn ChangeFunc) error {
- if a == "" {
- logrus.Debugf("Using single walk diff for %s", b)
- return addDirChanges(ctx, changeFn, b)
- } else if diffOptions := detectDirDiff(b, a); diffOptions != nil {
- logrus.Debugf("Using single walk diff for %s from %s", diffOptions.diffDir, a)
- return diffDirChanges(ctx, changeFn, a, diffOptions)
- }
-
- logrus.Debugf("Using double walk diff for %s from %s", b, a)
- return doubleWalkDiff(ctx, changeFn, a, b)
-}
-
-func addDirChanges(ctx context.Context, changeFn ChangeFunc, root string) error {
- return filepath.Walk(root, func(path string, f os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- // Rebase path
- path, err = filepath.Rel(root, path)
- if err != nil {
- return err
- }
-
- path = filepath.Join(string(os.PathSeparator), path)
-
- // Skip root
- if path == string(os.PathSeparator) {
- return nil
- }
-
- return changeFn(ChangeKindAdd, path, f, nil)
- })
-}
-
-// diffDirOptions is used when the diff can be directly calculated from
-// a diff directory to its base, without walking both trees.
-type diffDirOptions struct {
- diffDir string
- skipChange func(string) (bool, error)
- deleteChange func(string, string, os.FileInfo) (string, error)
-}
-
-// diffDirChanges walks the diff directory and compares changes against the base.
-func diffDirChanges(ctx context.Context, changeFn ChangeFunc, base string, o *diffDirOptions) error {
- changedDirs := make(map[string]struct{})
- return filepath.Walk(o.diffDir, func(path string, f os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- // Rebase path
- path, err = filepath.Rel(o.diffDir, path)
- if err != nil {
- return err
- }
-
- path = filepath.Join(string(os.PathSeparator), path)
-
- // Skip root
- if path == string(os.PathSeparator) {
- return nil
- }
-
- // TODO: handle opaqueness, start new double walker at this
- // location to get deletes, and skip tree in single walker
-
- if o.skipChange != nil {
- if skip, err := o.skipChange(path); skip {
- return err
- }
- }
-
- var kind ChangeKind
-
- deletedFile, err := o.deleteChange(o.diffDir, path, f)
- if err != nil {
- return err
- }
-
- // Find out what kind of modification happened
- if deletedFile != "" {
- path = deletedFile
- kind = ChangeKindDelete
- f = nil
- } else {
- // Otherwise, the file was added
- kind = ChangeKindAdd
-
- // ...Unless it already existed in a base, in which case, it's a modification
- stat, err := os.Stat(filepath.Join(base, path))
- if err != nil && !os.IsNotExist(err) {
- return err
- }
- if err == nil {
- // The file existed in the base, so that's a modification
-
- // However, if it's a directory, maybe it wasn't actually modified.
- // If you modify /foo/bar/baz, then /foo will be part of the changed files only because it's the parent of bar
- if stat.IsDir() && f.IsDir() {
- if f.Size() == stat.Size() && f.Mode() == stat.Mode() && sameFsTime(f.ModTime(), stat.ModTime()) {
- // Both directories are the same, don't record the change
- return nil
- }
- }
- kind = ChangeKindModify
- }
- }
-
- // If /foo/bar/file.txt is modified, then /foo/bar must be part of the changed files.
- // This block is here to ensure the change is recorded even if the
- // modify time, mode and size of the parent directory in the rw and ro layers are all equal.
- // Check https://github.com/docker/docker/pull/13590 for details.
- if f.IsDir() {
- changedDirs[path] = struct{}{}
- }
- if kind == ChangeKindAdd || kind == ChangeKindDelete {
- parent := filepath.Dir(path)
- if _, ok := changedDirs[parent]; !ok && parent != "/" {
- pi, err := os.Stat(filepath.Join(o.diffDir, parent))
- if err := changeFn(ChangeKindModify, parent, pi, err); err != nil {
- return err
- }
- changedDirs[parent] = struct{}{}
- }
- }
-
- return changeFn(kind, path, f, nil)
- })
-}
-
-// doubleWalkDiff walks both directories to create a diff
-func doubleWalkDiff(ctx context.Context, changeFn ChangeFunc, a, b string) (err error) {
- g, ctx := errgroup.WithContext(ctx)
-
- var (
- c1 = make(chan *currentPath)
- c2 = make(chan *currentPath)
-
- f1, f2 *currentPath
- rmdir string
- )
- g.Go(func() error {
- defer close(c1)
- return pathWalk(ctx, a, c1)
- })
- g.Go(func() error {
- defer close(c2)
- return pathWalk(ctx, b, c2)
- })
- g.Go(func() error {
- for c1 != nil || c2 != nil {
- if f1 == nil && c1 != nil {
- f1, err = nextPath(ctx, c1)
- if err != nil {
- return err
- }
- if f1 == nil {
- c1 = nil
- }
- }
-
- if f2 == nil && c2 != nil {
- f2, err = nextPath(ctx, c2)
- if err != nil {
- return err
- }
- if f2 == nil {
- c2 = nil
- }
- }
- if f1 == nil && f2 == nil {
- continue
- }
-
- var f os.FileInfo
- k, p := pathChange(f1, f2)
- switch k {
- case ChangeKindAdd:
- if rmdir != "" {
- rmdir = ""
- }
- f = f2.f
- f2 = nil
- case ChangeKindDelete:
- // Check if this file is already removed by being
- // under of a removed directory
- if rmdir != "" && strings.HasPrefix(f1.path, rmdir) {
- f1 = nil
- continue
- } else if f1.f.IsDir() {
- rmdir = f1.path + string(os.PathSeparator)
- } else if rmdir != "" {
- rmdir = ""
- }
- f1 = nil
- case ChangeKindModify:
- same, err := sameFile(f1, f2)
- if err != nil {
- return err
- }
- if f1.f.IsDir() && !f2.f.IsDir() {
- rmdir = f1.path + string(os.PathSeparator)
- } else if rmdir != "" {
- rmdir = ""
- }
- f = f2.f
- f1 = nil
- f2 = nil
- if same {
- if !isLinked(f) {
- continue
- }
- k = ChangeKindUnmodified
- }
- }
- if err := changeFn(k, p, f, nil); err != nil {
- return err
- }
- }
- return nil
- })
-
- return g.Wait()
-}
diff --git a/vendor/github.com/containerd/continuity/fs/diff_unix.go b/vendor/github.com/containerd/continuity/fs/diff_unix.go
deleted file mode 100644
index 7913af27d..000000000
--- a/vendor/github.com/containerd/continuity/fs/diff_unix.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// +build !windows
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "bytes"
- "os"
- "syscall"
-
- "github.com/containerd/continuity/sysx"
- "github.com/pkg/errors"
-)
-
-// detectDirDiff returns diff dir options if a directory could
-// be found in the mount info for upper which is the direct
-// diff with the provided lower directory
-func detectDirDiff(upper, lower string) *diffDirOptions {
- // TODO: get mount options for upper
- // TODO: detect AUFS
- // TODO: detect overlay
- return nil
-}
-
-// compareSysStat returns whether the stats are equivalent,
-// whether the files are considered the same file, and
-// an error
-func compareSysStat(s1, s2 interface{}) (bool, error) {
- ls1, ok := s1.(*syscall.Stat_t)
- if !ok {
- return false, nil
- }
- ls2, ok := s2.(*syscall.Stat_t)
- if !ok {
- return false, nil
- }
-
- return ls1.Mode == ls2.Mode && ls1.Uid == ls2.Uid && ls1.Gid == ls2.Gid && ls1.Rdev == ls2.Rdev, nil
-}
-
-func compareCapabilities(p1, p2 string) (bool, error) {
- c1, err := sysx.LGetxattr(p1, "security.capability")
- if err != nil && err != sysx.ENODATA {
- return false, errors.Wrapf(err, "failed to get xattr for %s", p1)
- }
- c2, err := sysx.LGetxattr(p2, "security.capability")
- if err != nil && err != sysx.ENODATA {
- return false, errors.Wrapf(err, "failed to get xattr for %s", p2)
- }
- return bytes.Equal(c1, c2), nil
-}
-
-func isLinked(f os.FileInfo) bool {
- s, ok := f.Sys().(*syscall.Stat_t)
- if !ok {
- return false
- }
- return !f.IsDir() && s.Nlink > 1
-}
diff --git a/vendor/github.com/containerd/continuity/fs/diff_windows.go b/vendor/github.com/containerd/continuity/fs/diff_windows.go
deleted file mode 100644
index 4bfa72d3a..000000000
--- a/vendor/github.com/containerd/continuity/fs/diff_windows.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "os"
-
- "golang.org/x/sys/windows"
-)
-
-func detectDirDiff(upper, lower string) *diffDirOptions {
- return nil
-}
-
-func compareSysStat(s1, s2 interface{}) (bool, error) {
- f1, ok := s1.(windows.Win32FileAttributeData)
- if !ok {
- return false, nil
- }
- f2, ok := s2.(windows.Win32FileAttributeData)
- if !ok {
- return false, nil
- }
- return f1.FileAttributes == f2.FileAttributes, nil
-}
-
-func compareCapabilities(p1, p2 string) (bool, error) {
- // TODO: Use windows equivalent
- return true, nil
-}
-
-func isLinked(os.FileInfo) bool {
- return false
-}
diff --git a/vendor/github.com/containerd/continuity/fs/dtype_linux.go b/vendor/github.com/containerd/continuity/fs/dtype_linux.go
deleted file mode 100644
index 10510d8de..000000000
--- a/vendor/github.com/containerd/continuity/fs/dtype_linux.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// +build linux
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "fmt"
- "io/ioutil"
- "os"
- "syscall"
- "unsafe"
-)
-
-func locateDummyIfEmpty(path string) (string, error) {
- children, err := ioutil.ReadDir(path)
- if err != nil {
- return "", err
- }
- if len(children) != 0 {
- return "", nil
- }
- dummyFile, err := ioutil.TempFile(path, "fsutils-dummy")
- if err != nil {
- return "", err
- }
- name := dummyFile.Name()
- err = dummyFile.Close()
- return name, err
-}
-
-// SupportsDType returns whether the filesystem mounted on path supports d_type
-func SupportsDType(path string) (bool, error) {
- // locate dummy so that we have at least one dirent
- dummy, err := locateDummyIfEmpty(path)
- if err != nil {
- return false, err
- }
- if dummy != "" {
- defer os.Remove(dummy)
- }
-
- visited := 0
- supportsDType := true
- fn := func(ent *syscall.Dirent) bool {
- visited++
- if ent.Type == syscall.DT_UNKNOWN {
- supportsDType = false
- // stop iteration
- return true
- }
- // continue iteration
- return false
- }
- if err = iterateReadDir(path, fn); err != nil {
- return false, err
- }
- if visited == 0 {
- return false, fmt.Errorf("did not hit any dirent during iteration %s", path)
- }
- return supportsDType, nil
-}
-
-func iterateReadDir(path string, fn func(*syscall.Dirent) bool) error {
- d, err := os.Open(path)
- if err != nil {
- return err
- }
- defer d.Close()
- fd := int(d.Fd())
- buf := make([]byte, 4096)
- for {
- nbytes, err := syscall.ReadDirent(fd, buf)
- if err != nil {
- return err
- }
- if nbytes == 0 {
- break
- }
- for off := 0; off < nbytes; {
- ent := (*syscall.Dirent)(unsafe.Pointer(&buf[off]))
- if stop := fn(ent); stop {
- return nil
- }
- off += int(ent.Reclen)
- }
- }
- return nil
-}
diff --git a/vendor/github.com/containerd/continuity/fs/du.go b/vendor/github.com/containerd/continuity/fs/du.go
deleted file mode 100644
index fccc985dc..000000000
--- a/vendor/github.com/containerd/continuity/fs/du.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import "context"
-
-// Usage of disk information
-type Usage struct {
- Inodes int64
- Size int64
-}
-
-// DiskUsage counts the number of inodes and disk usage for the resources under
-// path.
-func DiskUsage(ctx context.Context, roots ...string) (Usage, error) {
- return diskUsage(ctx, roots...)
-}
-
-// DiffUsage counts the numbers of inodes and disk usage in the
-// diff between the 2 directories. The first path is intended
-// as the base directory and the second as the changed directory.
-func DiffUsage(ctx context.Context, a, b string) (Usage, error) {
- return diffUsage(ctx, a, b)
-}
diff --git a/vendor/github.com/containerd/continuity/fs/du_unix.go b/vendor/github.com/containerd/continuity/fs/du_unix.go
deleted file mode 100644
index 9da43d1bc..000000000
--- a/vendor/github.com/containerd/continuity/fs/du_unix.go
+++ /dev/null
@@ -1,120 +0,0 @@
-// +build !windows
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "context"
- "os"
- "path/filepath"
- "syscall"
-)
-
-// blocksUnitSize is the unit used by `st_blocks` in `stat` in bytes.
-// See https://man7.org/linux/man-pages/man2/stat.2.html
-// st_blocks
-// This field indicates the number of blocks allocated to the
-// file, in 512-byte units. (This may be smaller than
-// st_size/512 when the file has holes.)
-const blocksUnitSize = 512
-
-type inode struct {
- // TODO(stevvooe): Can probably reduce memory usage by not tracking
- // device, but we can leave this right for now.
- dev, ino uint64
-}
-
-func newInode(stat *syscall.Stat_t) inode {
- return inode{
- // Dev is uint32 on darwin/bsd, uint64 on linux/solaris/freebsd
- dev: uint64(stat.Dev), // nolint: unconvert
- // Ino is uint32 on bsd, uint64 on darwin/linux/solaris/freebsd
- ino: uint64(stat.Ino), // nolint: unconvert
- }
-}
-
-func diskUsage(ctx context.Context, roots ...string) (Usage, error) {
-
- var (
- size int64
- inodes = map[inode]struct{}{} // expensive!
- )
-
- for _, root := range roots {
- if err := filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- select {
- case <-ctx.Done():
- return ctx.Err()
- default:
- }
-
- stat := fi.Sys().(*syscall.Stat_t)
- inoKey := newInode(stat)
- if _, ok := inodes[inoKey]; !ok {
- inodes[inoKey] = struct{}{}
- size += stat.Blocks * blocksUnitSize
- }
-
- return nil
- }); err != nil {
- return Usage{}, err
- }
- }
-
- return Usage{
- Inodes: int64(len(inodes)),
- Size: size,
- }, nil
-}
-
-func diffUsage(ctx context.Context, a, b string) (Usage, error) {
- var (
- size int64
- inodes = map[inode]struct{}{} // expensive!
- )
-
- if err := Changes(ctx, a, b, func(kind ChangeKind, _ string, fi os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- if kind == ChangeKindAdd || kind == ChangeKindModify {
- stat := fi.Sys().(*syscall.Stat_t)
- inoKey := newInode(stat)
- if _, ok := inodes[inoKey]; !ok {
- inodes[inoKey] = struct{}{}
- size += stat.Blocks * blocksUnitSize
- }
-
- return nil
-
- }
- return nil
- }); err != nil {
- return Usage{}, err
- }
-
- return Usage{
- Inodes: int64(len(inodes)),
- Size: size,
- }, nil
-}
diff --git a/vendor/github.com/containerd/continuity/fs/du_windows.go b/vendor/github.com/containerd/continuity/fs/du_windows.go
deleted file mode 100644
index 8f25ec59c..000000000
--- a/vendor/github.com/containerd/continuity/fs/du_windows.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// +build windows
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "context"
- "os"
- "path/filepath"
-)
-
-func diskUsage(ctx context.Context, roots ...string) (Usage, error) {
- var (
- size int64
- )
-
- // TODO(stevvooe): Support inodes (or equivalent) for windows.
-
- for _, root := range roots {
- if err := filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- select {
- case <-ctx.Done():
- return ctx.Err()
- default:
- }
-
- size += fi.Size()
- return nil
- }); err != nil {
- return Usage{}, err
- }
- }
-
- return Usage{
- Size: size,
- }, nil
-}
-
-func diffUsage(ctx context.Context, a, b string) (Usage, error) {
- var (
- size int64
- )
-
- if err := Changes(ctx, a, b, func(kind ChangeKind, _ string, fi os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- if kind == ChangeKindAdd || kind == ChangeKindModify {
- size += fi.Size()
-
- return nil
-
- }
- return nil
- }); err != nil {
- return Usage{}, err
- }
-
- return Usage{
- Size: size,
- }, nil
-}
diff --git a/vendor/github.com/containerd/continuity/fs/hardlink.go b/vendor/github.com/containerd/continuity/fs/hardlink.go
deleted file mode 100644
index 762aa45e6..000000000
--- a/vendor/github.com/containerd/continuity/fs/hardlink.go
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import "os"
-
-// GetLinkInfo returns an identifier representing the node a hardlink is pointing
-// to. If the file is not hard linked then 0 will be returned.
-func GetLinkInfo(fi os.FileInfo) (uint64, bool) {
- return getLinkInfo(fi)
-}
-
-// getLinkSource returns a path for the given name and
-// file info to its link source in the provided inode
-// map. If the given file name is not in the map and
-// has other links, it is added to the inode map
-// to be a source for other link locations.
-func getLinkSource(name string, fi os.FileInfo, inodes map[uint64]string) (string, error) {
- inode, isHardlink := getLinkInfo(fi)
- if !isHardlink {
- return "", nil
- }
-
- path, ok := inodes[inode]
- if !ok {
- inodes[inode] = name
- }
- return path, nil
-}
diff --git a/vendor/github.com/containerd/continuity/fs/hardlink_unix.go b/vendor/github.com/containerd/continuity/fs/hardlink_unix.go
deleted file mode 100644
index f95f0904c..000000000
--- a/vendor/github.com/containerd/continuity/fs/hardlink_unix.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// +build !windows
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "os"
- "syscall"
-)
-
-func getLinkInfo(fi os.FileInfo) (uint64, bool) {
- s, ok := fi.Sys().(*syscall.Stat_t)
- if !ok {
- return 0, false
- }
-
- // Ino is uint32 on bsd, uint64 on darwin/linux/solaris
- return uint64(s.Ino), !fi.IsDir() && s.Nlink > 1 // nolint: unconvert
-}
diff --git a/vendor/github.com/containerd/continuity/fs/hardlink_windows.go b/vendor/github.com/containerd/continuity/fs/hardlink_windows.go
deleted file mode 100644
index 748554714..000000000
--- a/vendor/github.com/containerd/continuity/fs/hardlink_windows.go
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import "os"
-
-func getLinkInfo(fi os.FileInfo) (uint64, bool) {
- return 0, false
-}
diff --git a/vendor/github.com/containerd/continuity/fs/path.go b/vendor/github.com/containerd/continuity/fs/path.go
deleted file mode 100644
index c26be7989..000000000
--- a/vendor/github.com/containerd/continuity/fs/path.go
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "bytes"
- "context"
- "io"
- "os"
- "path/filepath"
-
- "github.com/pkg/errors"
-)
-
-var (
- errTooManyLinks = errors.New("too many links")
-)
-
-type currentPath struct {
- path string
- f os.FileInfo
- fullPath string
-}
-
-func pathChange(lower, upper *currentPath) (ChangeKind, string) {
- if lower == nil {
- if upper == nil {
- panic("cannot compare nil paths")
- }
- return ChangeKindAdd, upper.path
- }
- if upper == nil {
- return ChangeKindDelete, lower.path
- }
-
- switch i := directoryCompare(lower.path, upper.path); {
- case i < 0:
- // File in lower that is not in upper
- return ChangeKindDelete, lower.path
- case i > 0:
- // File in upper that is not in lower
- return ChangeKindAdd, upper.path
- default:
- return ChangeKindModify, upper.path
- }
-}
-
-func directoryCompare(a, b string) int {
- l := len(a)
- if len(b) < l {
- l = len(b)
- }
- for i := 0; i < l; i++ {
- c1, c2 := a[i], b[i]
- if c1 == filepath.Separator {
- c1 = byte(0)
- }
- if c2 == filepath.Separator {
- c2 = byte(0)
- }
- if c1 < c2 {
- return -1
- }
- if c1 > c2 {
- return +1
- }
- }
- if len(a) < len(b) {
- return -1
- }
- if len(a) > len(b) {
- return +1
- }
- return 0
-}
-
-func sameFile(f1, f2 *currentPath) (bool, error) {
- if os.SameFile(f1.f, f2.f) {
- return true, nil
- }
-
- equalStat, err := compareSysStat(f1.f.Sys(), f2.f.Sys())
- if err != nil || !equalStat {
- return equalStat, err
- }
-
- if eq, err := compareCapabilities(f1.fullPath, f2.fullPath); err != nil || !eq {
- return eq, err
- }
-
- // If not a directory also check size, modtime, and content
- if !f1.f.IsDir() {
- if f1.f.Size() != f2.f.Size() {
- return false, nil
- }
- t1 := f1.f.ModTime()
- t2 := f2.f.ModTime()
-
- if t1.Unix() != t2.Unix() {
- return false, nil
- }
-
- // If the timestamp may have been truncated in both of the
- // files, check content of file to determine difference
- if t1.Nanosecond() == 0 && t2.Nanosecond() == 0 {
- if (f1.f.Mode() & os.ModeSymlink) == os.ModeSymlink {
- return compareSymlinkTarget(f1.fullPath, f2.fullPath)
- }
- if f1.f.Size() == 0 { // if file sizes are zero length, the files are the same by definition
- return true, nil
- }
- return compareFileContent(f1.fullPath, f2.fullPath)
- } else if t1.Nanosecond() != t2.Nanosecond() {
- return false, nil
- }
- }
-
- return true, nil
-}
-
-func compareSymlinkTarget(p1, p2 string) (bool, error) {
- t1, err := os.Readlink(p1)
- if err != nil {
- return false, err
- }
- t2, err := os.Readlink(p2)
- if err != nil {
- return false, err
- }
- return t1 == t2, nil
-}
-
-const compareChuckSize = 32 * 1024
-
-// compareFileContent compares the content of 2 same sized files
-// by comparing each byte.
-func compareFileContent(p1, p2 string) (bool, error) {
- f1, err := os.Open(p1)
- if err != nil {
- return false, err
- }
- defer f1.Close()
- f2, err := os.Open(p2)
- if err != nil {
- return false, err
- }
- defer f2.Close()
-
- b1 := make([]byte, compareChuckSize)
- b2 := make([]byte, compareChuckSize)
- for {
- n1, err1 := f1.Read(b1)
- if err1 != nil && err1 != io.EOF {
- return false, err1
- }
- n2, err2 := f2.Read(b2)
- if err2 != nil && err2 != io.EOF {
- return false, err2
- }
- if n1 != n2 || !bytes.Equal(b1[:n1], b2[:n2]) {
- return false, nil
- }
- if err1 == io.EOF && err2 == io.EOF {
- return true, nil
- }
- }
-}
-
-func pathWalk(ctx context.Context, root string, pathC chan<- *currentPath) error {
- return filepath.Walk(root, func(path string, f os.FileInfo, err error) error {
- if err != nil {
- return err
- }
-
- // Rebase path
- path, err = filepath.Rel(root, path)
- if err != nil {
- return err
- }
-
- path = filepath.Join(string(os.PathSeparator), path)
-
- // Skip root
- if path == string(os.PathSeparator) {
- return nil
- }
-
- p := &currentPath{
- path: path,
- f: f,
- fullPath: filepath.Join(root, path),
- }
-
- select {
- case <-ctx.Done():
- return ctx.Err()
- case pathC <- p:
- return nil
- }
- })
-}
-
-func nextPath(ctx context.Context, pathC <-chan *currentPath) (*currentPath, error) {
- select {
- case <-ctx.Done():
- return nil, ctx.Err()
- case p := <-pathC:
- return p, nil
- }
-}
-
-// RootPath joins a path with a root, evaluating and bounding any
-// symlink to the root directory.
-func RootPath(root, path string) (string, error) {
- if path == "" {
- return root, nil
- }
- var linksWalked int // to protect against cycles
- for {
- i := linksWalked
- newpath, err := walkLinks(root, path, &linksWalked)
- if err != nil {
- return "", err
- }
- path = newpath
- if i == linksWalked {
- newpath = filepath.Join("/", newpath)
- if path == newpath {
- return filepath.Join(root, newpath), nil
- }
- path = newpath
- }
- }
-}
-
-func walkLink(root, path string, linksWalked *int) (newpath string, islink bool, err error) {
- if *linksWalked > 255 {
- return "", false, errTooManyLinks
- }
-
- path = filepath.Join("/", path)
- if path == "/" {
- return path, false, nil
- }
- realPath := filepath.Join(root, path)
-
- fi, err := os.Lstat(realPath)
- if err != nil {
- // If path does not yet exist, treat as non-symlink
- if os.IsNotExist(err) {
- return path, false, nil
- }
- return "", false, err
- }
- if fi.Mode()&os.ModeSymlink == 0 {
- return path, false, nil
- }
- newpath, err = os.Readlink(realPath)
- if err != nil {
- return "", false, err
- }
- *linksWalked++
- return newpath, true, nil
-}
-
-func walkLinks(root, path string, linksWalked *int) (string, error) {
- switch dir, file := filepath.Split(path); {
- case dir == "":
- newpath, _, err := walkLink(root, file, linksWalked)
- return newpath, err
- case file == "":
- if os.IsPathSeparator(dir[len(dir)-1]) {
- if dir == "/" {
- return dir, nil
- }
- return walkLinks(root, dir[:len(dir)-1], linksWalked)
- }
- newpath, _, err := walkLink(root, dir, linksWalked)
- return newpath, err
- default:
- newdir, err := walkLinks(root, dir, linksWalked)
- if err != nil {
- return "", err
- }
- newpath, islink, err := walkLink(root, filepath.Join(newdir, file), linksWalked)
- if err != nil {
- return "", err
- }
- if !islink {
- return newpath, nil
- }
- if filepath.IsAbs(newpath) {
- return newpath, nil
- }
- return filepath.Join(newdir, newpath), nil
- }
-}
diff --git a/vendor/github.com/containerd/continuity/fs/stat_darwinfreebsd.go b/vendor/github.com/containerd/continuity/fs/stat_darwinfreebsd.go
deleted file mode 100644
index cb7400a33..000000000
--- a/vendor/github.com/containerd/continuity/fs/stat_darwinfreebsd.go
+++ /dev/null
@@ -1,44 +0,0 @@
-// +build darwin freebsd
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "syscall"
- "time"
-)
-
-// StatAtime returns the access time from a stat struct
-func StatAtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Atimespec
-}
-
-// StatCtime returns the created time from a stat struct
-func StatCtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Ctimespec
-}
-
-// StatMtime returns the modified time from a stat struct
-func StatMtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Mtimespec
-}
-
-// StatATimeAsTime returns the access time as a time.Time
-func StatATimeAsTime(st *syscall.Stat_t) time.Time {
- return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) // nolint: unconvert
-}
diff --git a/vendor/github.com/containerd/continuity/fs/stat_linuxopenbsd.go b/vendor/github.com/containerd/continuity/fs/stat_linuxopenbsd.go
deleted file mode 100644
index c68df6e58..000000000
--- a/vendor/github.com/containerd/continuity/fs/stat_linuxopenbsd.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// +build linux openbsd
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import (
- "syscall"
- "time"
-)
-
-// StatAtime returns the Atim
-func StatAtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Atim
-}
-
-// StatCtime returns the Ctim
-func StatCtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Ctim
-}
-
-// StatMtime returns the Mtim
-func StatMtime(st *syscall.Stat_t) syscall.Timespec {
- return st.Mtim
-}
-
-// StatATimeAsTime returns st.Atim as a time.Time
-func StatATimeAsTime(st *syscall.Stat_t) time.Time {
- // The int64 conversions ensure the line compiles for 32-bit systems as well.
- return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) // nolint: unconvert
-}
diff --git a/vendor/github.com/containerd/continuity/fs/time.go b/vendor/github.com/containerd/continuity/fs/time.go
deleted file mode 100644
index cde456123..000000000
--- a/vendor/github.com/containerd/continuity/fs/time.go
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package fs
-
-import "time"
-
-// Gnu tar and the go tar writer don't have sub-second mtime
-// precision, which is problematic when we apply changes via tar
-// files, we handle this by comparing for exact times, *or* same
-// second count and either a or b having exactly 0 nanoseconds
-func sameFsTime(a, b time.Time) bool {
- return a == b ||
- (a.Unix() == b.Unix() &&
- (a.Nanosecond() == 0 || b.Nanosecond() == 0))
-}
diff --git a/vendor/github.com/containerd/continuity/sysx/README.md b/vendor/github.com/containerd/continuity/sysx/README.md
deleted file mode 100644
index ad7aee533..000000000
--- a/vendor/github.com/containerd/continuity/sysx/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-This package is for internal use only. It is intended to only have
-temporary changes before they are upstreamed to golang.org/x/sys/
-(a.k.a. https://github.com/golang/sys).
diff --git a/vendor/github.com/containerd/continuity/sysx/generate.sh b/vendor/github.com/containerd/continuity/sysx/generate.sh
deleted file mode 100644
index 87d708d7a..000000000
--- a/vendor/github.com/containerd/continuity/sysx/generate.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/bash
-
-# Copyright The containerd Authors.
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-set -e
-
-mksyscall="$(go env GOROOT)/src/syscall/mksyscall.pl"
-
-fix() {
- sed 's,^package syscall$,package sysx,' \
- | sed 's,^import "unsafe"$,import (\n\t"syscall"\n\t"unsafe"\n),' \
- | gofmt -r='BytePtrFromString -> syscall.BytePtrFromString' \
- | gofmt -r='Syscall6 -> syscall.Syscall6' \
- | gofmt -r='Syscall -> syscall.Syscall' \
- | gofmt -r='SYS_GETXATTR -> syscall.SYS_GETXATTR' \
- | gofmt -r='SYS_LISTXATTR -> syscall.SYS_LISTXATTR' \
- | gofmt -r='SYS_SETXATTR -> syscall.SYS_SETXATTR' \
- | gofmt -r='SYS_REMOVEXATTR -> syscall.SYS_REMOVEXATTR' \
- | gofmt -r='SYS_LGETXATTR -> syscall.SYS_LGETXATTR' \
- | gofmt -r='SYS_LLISTXATTR -> syscall.SYS_LLISTXATTR' \
- | gofmt -r='SYS_LSETXATTR -> syscall.SYS_LSETXATTR' \
- | gofmt -r='SYS_LREMOVEXATTR -> syscall.SYS_LREMOVEXATTR'
-}
-
-if [ "$GOARCH" == "" ] || [ "$GOOS" == "" ]; then
- echo "Must specify \$GOARCH and \$GOOS"
- exit 1
-fi
-
-mkargs=""
-
-if [ "$GOARCH" == "386" ] || [ "$GOARCH" == "arm" ]; then
- mkargs="-l32"
-fi
-
-for f in "$@"; do
- $mksyscall $mkargs "${f}_${GOOS}.go" | fix > "${f}_${GOOS}_${GOARCH}.go"
-done
-
diff --git a/vendor/github.com/containerd/continuity/sysx/nodata_linux.go b/vendor/github.com/containerd/continuity/sysx/nodata_linux.go
deleted file mode 100644
index 28ce5d8de..000000000
--- a/vendor/github.com/containerd/continuity/sysx/nodata_linux.go
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package sysx
-
-import (
- "syscall"
-)
-
-const ENODATA = syscall.ENODATA
diff --git a/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go b/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go
deleted file mode 100644
index e0575f446..000000000
--- a/vendor/github.com/containerd/continuity/sysx/nodata_solaris.go
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package sysx
-
-import (
- "syscall"
-)
-
-// This should actually be a set that contains ENOENT and EPERM
-const ENODATA = syscall.ENOENT
diff --git a/vendor/github.com/containerd/continuity/sysx/nodata_unix.go b/vendor/github.com/containerd/continuity/sysx/nodata_unix.go
deleted file mode 100644
index de4b3d50c..000000000
--- a/vendor/github.com/containerd/continuity/sysx/nodata_unix.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// +build darwin freebsd openbsd
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package sysx
-
-import (
- "syscall"
-)
-
-const ENODATA = syscall.ENOATTR
diff --git a/vendor/github.com/containerd/continuity/sysx/xattr.go b/vendor/github.com/containerd/continuity/sysx/xattr.go
deleted file mode 100644
index db6fe70fe..000000000
--- a/vendor/github.com/containerd/continuity/sysx/xattr.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// +build linux darwin
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package sysx
-
-import (
- "bytes"
-
- "golang.org/x/sys/unix"
-)
-
-// Listxattr calls syscall listxattr and reads all content
-// and returns a string array
-func Listxattr(path string) ([]string, error) {
- return listxattrAll(path, unix.Listxattr)
-}
-
-// Removexattr calls syscall removexattr
-func Removexattr(path string, attr string) (err error) {
- return unix.Removexattr(path, attr)
-}
-
-// Setxattr calls syscall setxattr
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- return unix.Setxattr(path, attr, data, flags)
-}
-
-// Getxattr calls syscall getxattr
-func Getxattr(path, attr string) ([]byte, error) {
- return getxattrAll(path, attr, unix.Getxattr)
-}
-
-// LListxattr lists xattrs, not following symlinks
-func LListxattr(path string) ([]string, error) {
- return listxattrAll(path, unix.Llistxattr)
-}
-
-// LRemovexattr removes an xattr, not following symlinks
-func LRemovexattr(path string, attr string) (err error) {
- return unix.Lremovexattr(path, attr)
-}
-
-// LSetxattr sets an xattr, not following symlinks
-func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
- return unix.Lsetxattr(path, attr, data, flags)
-}
-
-// LGetxattr gets an xattr, not following symlinks
-func LGetxattr(path, attr string) ([]byte, error) {
- return getxattrAll(path, attr, unix.Lgetxattr)
-}
-
-const defaultXattrBufferSize = 128
-
-type listxattrFunc func(path string, dest []byte) (int, error)
-
-func listxattrAll(path string, listFunc listxattrFunc) ([]string, error) {
- buf := make([]byte, defaultXattrBufferSize)
- n, err := listFunc(path, buf)
- for err == unix.ERANGE {
- // Buffer too small, use zero-sized buffer to get the actual size
- n, err = listFunc(path, []byte{})
- if err != nil {
- return nil, err
- }
- buf = make([]byte, n)
- n, err = listFunc(path, buf)
- }
- if err != nil {
- return nil, err
- }
-
- ps := bytes.Split(bytes.TrimSuffix(buf[:n], []byte{0}), []byte{0})
- var entries []string
- for _, p := range ps {
- if len(p) > 0 {
- entries = append(entries, string(p))
- }
- }
-
- return entries, nil
-}
-
-type getxattrFunc func(string, string, []byte) (int, error)
-
-func getxattrAll(path, attr string, getFunc getxattrFunc) ([]byte, error) {
- buf := make([]byte, defaultXattrBufferSize)
- n, err := getFunc(path, attr, buf)
- for err == unix.ERANGE {
- // Buffer too small, use zero-sized buffer to get the actual size
- n, err = getFunc(path, attr, []byte{})
- if err != nil {
- return nil, err
- }
- buf = make([]byte, n)
- n, err = getFunc(path, attr, buf)
- }
- if err != nil {
- return nil, err
- }
- return buf[:n], nil
-}
diff --git a/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go b/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go
deleted file mode 100644
index f8fa8c63f..000000000
--- a/vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// +build !linux,!darwin
-
-/*
- Copyright The containerd Authors.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package sysx
-
-import (
- "errors"
- "runtime"
-)
-
-var errUnsupported = errors.New("extended attributes unsupported on " + runtime.GOOS)
-
-// Listxattr calls syscall listxattr and reads all content
-// and returns a string array
-func Listxattr(path string) ([]string, error) {
- return []string{}, nil
-}
-
-// Removexattr calls syscall removexattr
-func Removexattr(path string, attr string) (err error) {
- return errUnsupported
-}
-
-// Setxattr calls syscall setxattr
-func Setxattr(path string, attr string, data []byte, flags int) (err error) {
- return errUnsupported
-}
-
-// Getxattr calls syscall getxattr
-func Getxattr(path, attr string) ([]byte, error) {
- return []byte{}, errUnsupported
-}
-
-// LListxattr lists xattrs, not following symlinks
-func LListxattr(path string) ([]string, error) {
- return []string{}, nil
-}
-
-// LRemovexattr removes an xattr, not following symlinks
-func LRemovexattr(path string, attr string) (err error) {
- return errUnsupported
-}
-
-// LSetxattr sets an xattr, not following symlinks
-func LSetxattr(path string, attr string, data []byte, flags int) (err error) {
- return errUnsupported
-}
-
-// LGetxattr gets an xattr, not following symlinks
-func LGetxattr(path, attr string) ([]byte, error) {
- return []byte{}, nil
-}
diff --git a/vendor/github.com/docker/docker/api/swagger.yaml b/vendor/github.com/docker/docker/api/swagger.yaml
index 8500705b5..1294e5a22 100644
--- a/vendor/github.com/docker/docker/api/swagger.yaml
+++ b/vendor/github.com/docker/docker/api/swagger.yaml
@@ -1274,7 +1274,7 @@ definitions:
type: "object"
properties:
Bridge:
- description: Name of the network's bridge (for example, `docker0`).
+ description: Name of the network'a bridge (for example, `docker0`).
type: "string"
example: "docker0"
SandboxID:
@@ -10050,7 +10050,7 @@ paths:
description: |
Address or interface to use for data path traffic (format:
`<ip|interface>`), for example, `192.168.1.1`, or an interface,
- like `eth0`. If `DataPathAddr` is unspecified, the same address
+ like `eth0`. If `DataPathAddr` is unspecified, the same addres
as `AdvertiseAddr` is used.
The `DataPathAddr` specifies the address that global scope
diff --git a/vendor/github.com/docker/docker/client/build_cancel.go b/vendor/github.com/docker/docker/client/build_cancel.go
index b76bf366b..3aae43e3d 100644
--- a/vendor/github.com/docker/docker/client/build_cancel.go
+++ b/vendor/github.com/docker/docker/client/build_cancel.go
@@ -5,7 +5,7 @@ import (
"net/url"
)
-// BuildCancel requests the daemon to cancel the ongoing build request.
+// BuildCancel requests the daemon to cancel ongoing build request
func (cli *Client) BuildCancel(ctx context.Context, id string) error {
query := url.Values{}
query.Set("id", id)
diff --git a/vendor/github.com/docker/docker/client/client.go b/vendor/github.com/docker/docker/client/client.go
index 68064ca9c..21edf1fa1 100644
--- a/vendor/github.com/docker/docker/client/client.go
+++ b/vendor/github.com/docker/docker/client/client.go
@@ -2,7 +2,7 @@
Package client is a Go client for the Docker Engine API.
For more information about the Engine API, see the documentation:
-https://docs.docker.com/engine/reference/api/
+https://docs.docker.com/engine/api/
Usage
diff --git a/vendor/github.com/docker/docker/client/config_create.go b/vendor/github.com/docker/docker/client/config_create.go
index f6b1881fc..ee7d411df 100644
--- a/vendor/github.com/docker/docker/client/config_create.go
+++ b/vendor/github.com/docker/docker/client/config_create.go
@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/swarm"
)
-// ConfigCreate creates a new config.
+// ConfigCreate creates a new Config.
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
var response types.ConfigCreateResponse
if err := cli.NewVersionError("1.30", "config create"); err != nil {
diff --git a/vendor/github.com/docker/docker/client/config_remove.go b/vendor/github.com/docker/docker/client/config_remove.go
index 93de0d844..a708fcaec 100644
--- a/vendor/github.com/docker/docker/client/config_remove.go
+++ b/vendor/github.com/docker/docker/client/config_remove.go
@@ -2,7 +2,7 @@ package client // import "github.com/docker/docker/client"
import "context"
-// ConfigRemove removes a config.
+// ConfigRemove removes a Config.
func (cli *Client) ConfigRemove(ctx context.Context, id string) error {
if err := cli.NewVersionError("1.30", "config remove"); err != nil {
return err
diff --git a/vendor/github.com/docker/docker/client/config_update.go b/vendor/github.com/docker/docker/client/config_update.go
index ba79ae64e..39e59cf85 100644
--- a/vendor/github.com/docker/docker/client/config_update.go
+++ b/vendor/github.com/docker/docker/client/config_update.go
@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/swarm"
)
-// ConfigUpdate attempts to update a config
+// ConfigUpdate attempts to update a Config
func (cli *Client) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error {
if err := cli.NewVersionError("1.30", "config update"); err != nil {
return err
diff --git a/vendor/github.com/docker/docker/client/container_commit.go b/vendor/github.com/docker/docker/client/container_commit.go
index cd7f76346..2966e88c8 100644
--- a/vendor/github.com/docker/docker/client/container_commit.go
+++ b/vendor/github.com/docker/docker/client/container_commit.go
@@ -10,7 +10,7 @@ import (
"github.com/docker/docker/api/types"
)
-// ContainerCommit applies changes to a container and creates a new tagged image.
+// ContainerCommit applies changes into a container and creates a new tagged image.
func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error) {
var repository, tag string
if options.Reference != "" {
diff --git a/vendor/github.com/docker/docker/client/container_copy.go b/vendor/github.com/docker/docker/client/container_copy.go
index c0a47c14e..bb278bf7f 100644
--- a/vendor/github.com/docker/docker/client/container_copy.go
+++ b/vendor/github.com/docker/docker/client/container_copy.go
@@ -14,7 +14,7 @@ import (
"github.com/docker/docker/api/types"
)
-// ContainerStatPath returns stat information about a path inside the container filesystem.
+// ContainerStatPath returns Stat information about a path inside the container filesystem.
func (cli *Client) ContainerStatPath(ctx context.Context, containerID, path string) (types.ContainerPathStat, error) {
query := url.Values{}
query.Set("path", filepath.ToSlash(path)) // Normalize the paths used in the API.
diff --git a/vendor/github.com/docker/docker/client/container_create.go b/vendor/github.com/docker/docker/client/container_create.go
index cfae96a6f..b1d5fea5b 100644
--- a/vendor/github.com/docker/docker/client/container_create.go
+++ b/vendor/github.com/docker/docker/client/container_create.go
@@ -19,7 +19,7 @@ type configWrapper struct {
Platform *specs.Platform
}
-// ContainerCreate creates a new container based on the given configuration.
+// ContainerCreate creates a new container based in the given configuration.
// It can be associated with a name, but it's not mandatory.
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) {
var response container.ContainerCreateCreatedBody
diff --git a/vendor/github.com/docker/docker/client/container_restart.go b/vendor/github.com/docker/docker/client/container_restart.go
index aa0d6485d..41e421969 100644
--- a/vendor/github.com/docker/docker/client/container_restart.go
+++ b/vendor/github.com/docker/docker/client/container_restart.go
@@ -9,7 +9,7 @@ import (
)
// ContainerRestart stops and starts a container again.
-// It makes the daemon wait for the container to be up again for
+// It makes the daemon to wait for the container to be up again for
// a specific amount of time, given the timeout.
func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout *time.Duration) error {
query := url.Values{}
diff --git a/vendor/github.com/docker/docker/client/container_update.go b/vendor/github.com/docker/docker/client/container_update.go
index bf68a5300..6917cf9fb 100644
--- a/vendor/github.com/docker/docker/client/container_update.go
+++ b/vendor/github.com/docker/docker/client/container_update.go
@@ -7,7 +7,7 @@ import (
"github.com/docker/docker/api/types/container"
)
-// ContainerUpdate updates the resources of a container.
+// ContainerUpdate updates resources of a container
func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error) {
var response container.ContainerUpdateOKBody
serverResp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil)
diff --git a/vendor/github.com/docker/docker/client/distribution_inspect.go b/vendor/github.com/docker/docker/client/distribution_inspect.go
index 7f36c99a0..f4e3794cb 100644
--- a/vendor/github.com/docker/docker/client/distribution_inspect.go
+++ b/vendor/github.com/docker/docker/client/distribution_inspect.go
@@ -8,7 +8,7 @@ import (
registrytypes "github.com/docker/docker/api/types/registry"
)
-// DistributionInspect returns the image digest with the full manifest.
+// DistributionInspect returns the image digest with full Manifest
func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registrytypes.DistributionInspect, error) {
// Contact the registry to retrieve digest and platform information
var distributionInspect registrytypes.DistributionInspect
diff --git a/vendor/github.com/docker/docker/client/image_build.go b/vendor/github.com/docker/docker/client/image_build.go
index d16e1d8ea..8fcf99503 100644
--- a/vendor/github.com/docker/docker/client/image_build.go
+++ b/vendor/github.com/docker/docker/client/image_build.go
@@ -14,8 +14,8 @@ import (
"github.com/docker/docker/api/types/container"
)
-// ImageBuild sends a request to the daemon to build images.
-// The Body in the response implements an io.ReadCloser and it's up to the caller to
+// ImageBuild sends request to the daemon to build images.
+// The Body in the response implement an io.ReadCloser and it's up to the caller to
// close it.
func (cli *Client) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
query, err := cli.imageBuildOptionsToQuery(options)
diff --git a/vendor/github.com/docker/docker/client/image_create.go b/vendor/github.com/docker/docker/client/image_create.go
index b1c022777..239380474 100644
--- a/vendor/github.com/docker/docker/client/image_create.go
+++ b/vendor/github.com/docker/docker/client/image_create.go
@@ -10,7 +10,7 @@ import (
"github.com/docker/docker/api/types"
)
-// ImageCreate creates a new image based on the parent options.
+// ImageCreate creates a new image based in the parent options.
// It returns the JSON content in the response body.
func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
ref, err := reference.ParseNormalizedNamed(parentReference)
diff --git a/vendor/github.com/docker/docker/client/image_import.go b/vendor/github.com/docker/docker/client/image_import.go
index c5de42cb7..d3336d410 100644
--- a/vendor/github.com/docker/docker/client/image_import.go
+++ b/vendor/github.com/docker/docker/client/image_import.go
@@ -10,7 +10,7 @@ import (
"github.com/docker/docker/api/types"
)
-// ImageImport creates a new image based on the source options.
+// ImageImport creates a new image based in the source options.
// It returns the JSON content in the response body.
func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) {
if ref != "" {
diff --git a/vendor/github.com/docker/docker/client/image_search.go b/vendor/github.com/docker/docker/client/image_search.go
index 5f40a22a9..82955a747 100644
--- a/vendor/github.com/docker/docker/client/image_search.go
+++ b/vendor/github.com/docker/docker/client/image_search.go
@@ -12,7 +12,7 @@ import (
"github.com/docker/docker/errdefs"
)
-// ImageSearch makes the docker host search by a term in a remote registry.
+// ImageSearch makes the docker host to search by a term in a remote registry.
// The list of results is not sorted in any fashion.
func (cli *Client) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) {
var results []registry.SearchResult
diff --git a/vendor/github.com/docker/docker/client/secret_create.go b/vendor/github.com/docker/docker/client/secret_create.go
index c65d38a19..fd5b91413 100644
--- a/vendor/github.com/docker/docker/client/secret_create.go
+++ b/vendor/github.com/docker/docker/client/secret_create.go
@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/swarm"
)
-// SecretCreate creates a new secret.
+// SecretCreate creates a new Secret.
func (cli *Client) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) {
var response types.SecretCreateResponse
if err := cli.NewVersionError("1.25", "secret create"); err != nil {
diff --git a/vendor/github.com/docker/docker/client/secret_remove.go b/vendor/github.com/docker/docker/client/secret_remove.go
index f6c69e57f..c16f55580 100644
--- a/vendor/github.com/docker/docker/client/secret_remove.go
+++ b/vendor/github.com/docker/docker/client/secret_remove.go
@@ -2,7 +2,7 @@ package client // import "github.com/docker/docker/client"
import "context"
-// SecretRemove removes a secret.
+// SecretRemove removes a Secret.
func (cli *Client) SecretRemove(ctx context.Context, id string) error {
if err := cli.NewVersionError("1.25", "secret remove"); err != nil {
return err
diff --git a/vendor/github.com/docker/docker/client/secret_update.go b/vendor/github.com/docker/docker/client/secret_update.go
index d082dcef7..164256bbc 100644
--- a/vendor/github.com/docker/docker/client/secret_update.go
+++ b/vendor/github.com/docker/docker/client/secret_update.go
@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/swarm"
)
-// SecretUpdate attempts to update a secret.
+// SecretUpdate attempts to update a Secret
func (cli *Client) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error {
if err := cli.NewVersionError("1.25", "secret update"); err != nil {
return err
diff --git a/vendor/github.com/docker/docker/client/service_create.go b/vendor/github.com/docker/docker/client/service_create.go
index a07315f71..e0428bf98 100644
--- a/vendor/github.com/docker/docker/client/service_create.go
+++ b/vendor/github.com/docker/docker/client/service_create.go
@@ -13,7 +13,7 @@ import (
"github.com/pkg/errors"
)
-// ServiceCreate creates a new service.
+// ServiceCreate creates a new Service.
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) {
var response types.ServiceCreateResponse
headers := map[string][]string{
diff --git a/vendor/github.com/docker/docker/client/task_inspect.go b/vendor/github.com/docker/docker/client/task_inspect.go
index ed132f379..44d40ba5a 100644
--- a/vendor/github.com/docker/docker/client/task_inspect.go
+++ b/vendor/github.com/docker/docker/client/task_inspect.go
@@ -9,7 +9,7 @@ import (
"github.com/docker/docker/api/types/swarm"
)
-// TaskInspectWithRaw returns the task information and its raw representation.
+// TaskInspectWithRaw returns the task information and its raw representation..
func (cli *Client) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) {
if taskID == "" {
return swarm.Task{}, nil, objectNotFoundError{object: "task", id: taskID}
diff --git a/vendor/github.com/docker/docker/pkg/archive/archive.go b/vendor/github.com/docker/docker/pkg/archive/archive.go
index 134749d68..8d14b7869 100644
--- a/vendor/github.com/docker/docker/pkg/archive/archive.go
+++ b/vendor/github.com/docker/docker/pkg/archive/archive.go
@@ -402,24 +402,10 @@ func fillGo18FileTypeBits(mode int64, fi os.FileInfo) int64 {
// ReadSecurityXattrToTarHeader reads security.capability xattr from filesystem
// to a tar header
func ReadSecurityXattrToTarHeader(path string, hdr *tar.Header) error {
- const (
- // Values based on linux/include/uapi/linux/capability.h
- xattrCapsSz2 = 20
- versionOffset = 3
- vfsCapRevision2 = 2
- vfsCapRevision3 = 3
- )
capability, _ := system.Lgetxattr(path, "security.capability")
if capability != nil {
- length := len(capability)
- if capability[versionOffset] == vfsCapRevision3 {
- // Convert VFS_CAP_REVISION_3 to VFS_CAP_REVISION_2 as root UID makes no
- // sense outside the user namespace the archive is built in.
- capability[versionOffset] = vfsCapRevision2
- length = xattrCapsSz2
- }
hdr.Xattrs = make(map[string]string)
- hdr.Xattrs["security.capability"] = string(capability[:length])
+ hdr.Xattrs["security.capability"] = string(capability)
}
return nil
}
@@ -753,13 +739,18 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
return nil, err
}
+ whiteoutConverter, err := getWhiteoutConverter(options.WhiteoutFormat, options.InUserNS)
+ if err != nil {
+ return nil, err
+ }
+
go func() {
ta := newTarAppender(
idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps),
compressWriter,
options.ChownOpts,
)
- ta.WhiteoutConverter = getWhiteoutConverter(options.WhiteoutFormat, options.InUserNS)
+ ta.WhiteoutConverter = whiteoutConverter
defer func() {
// Make sure to check the error on Close.
@@ -917,7 +908,10 @@ func Unpack(decompressedArchive io.Reader, dest string, options *TarOptions) err
var dirs []*tar.Header
idMapping := idtools.NewIDMappingsFromMaps(options.UIDMaps, options.GIDMaps)
rootIDs := idMapping.RootPair()
- whiteoutConverter := getWhiteoutConverter(options.WhiteoutFormat, options.InUserNS)
+ whiteoutConverter, err := getWhiteoutConverter(options.WhiteoutFormat, options.InUserNS)
+ if err != nil {
+ return err
+ }
// Iterate through the files in the archive.
loop:
@@ -956,7 +950,7 @@ loop:
parent := filepath.Dir(hdr.Name)
parentPath := filepath.Join(dest, parent)
if _, err := os.Lstat(parentPath); err != nil && os.IsNotExist(err) {
- err = idtools.MkdirAllAndChownNew(parentPath, 0777, rootIDs)
+ err = idtools.MkdirAllAndChownNew(parentPath, 0755, rootIDs)
if err != nil {
return err
}
diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_linux.go b/vendor/github.com/docker/docker/pkg/archive/archive_linux.go
index f7888e659..0a3cc1f92 100644
--- a/vendor/github.com/docker/docker/pkg/archive/archive_linux.go
+++ b/vendor/github.com/docker/docker/pkg/archive/archive_linux.go
@@ -2,29 +2,26 @@ package archive // import "github.com/docker/docker/pkg/archive"
import (
"archive/tar"
- "fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
- "syscall"
- "github.com/containerd/continuity/fs"
"github.com/docker/docker/pkg/system"
- "github.com/moby/sys/mount"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
)
-func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) tarWhiteoutConverter {
+func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) (tarWhiteoutConverter, error) {
if format == OverlayWhiteoutFormat {
- return overlayWhiteoutConverter{inUserNS: inUserNS}
+ if inUserNS {
+ return nil, errors.New("specifying OverlayWhiteoutFormat is not allowed in userns")
+ }
+ return overlayWhiteoutConverter{}, nil
}
- return nil
+ return nil, nil
}
type overlayWhiteoutConverter struct {
- inUserNS bool
}
func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os.FileInfo) (wo *tar.Header, err error) {
@@ -77,13 +74,7 @@ func (c overlayWhiteoutConverter) ConvertRead(hdr *tar.Header, path string) (boo
if base == WhiteoutOpaqueDir {
err := unix.Setxattr(dir, "trusted.overlay.opaque", []byte{'y'}, 0)
if err != nil {
- if c.inUserNS {
- if err = replaceDirWithOverlayOpaque(dir); err != nil {
- return false, errors.Wrapf(err, "replaceDirWithOverlayOpaque(%q) failed", dir)
- }
- } else {
- return false, errors.Wrapf(err, "setxattr(%q, trusted.overlay.opaque=y)", dir)
- }
+ return false, errors.Wrapf(err, "setxattr(%q, trusted.overlay.opaque=y)", dir)
}
// don't write the file itself
return false, err
@@ -95,19 +86,7 @@ func (c overlayWhiteoutConverter) ConvertRead(hdr *tar.Header, path string) (boo
originalPath := filepath.Join(dir, originalBase)
if err := unix.Mknod(originalPath, unix.S_IFCHR, 0); err != nil {
- if c.inUserNS {
- // Ubuntu and a few distros support overlayfs in userns.
- //
- // Although we can't call mknod directly in userns (at least on bionic kernel 4.15),
- // we can still create 0,0 char device using mknodChar0Overlay().
- //
- // NOTE: we don't need this hack for the containerd snapshotter+unpack model.
- if err := mknodChar0Overlay(originalPath); err != nil {
- return false, errors.Wrapf(err, "failed to mknodChar0UserNS(%q)", originalPath)
- }
- } else {
- return false, errors.Wrapf(err, "failed to mknod(%q, S_IFCHR, 0)", originalPath)
- }
+ return false, errors.Wrapf(err, "failed to mknod(%q, S_IFCHR, 0)", originalPath)
}
if err := os.Chown(originalPath, hdr.Uid, hdr.Gid); err != nil {
return false, err
@@ -119,146 +98,3 @@ func (c overlayWhiteoutConverter) ConvertRead(hdr *tar.Header, path string) (boo
return true, nil
}
-
-// mknodChar0Overlay creates 0,0 char device by mounting overlayfs and unlinking.
-// This function can be used for creating 0,0 char device in userns on Ubuntu.
-//
-// Steps:
-// * Mkdir lower,upper,merged,work
-// * Create lower/dummy
-// * Mount overlayfs
-// * Unlink merged/dummy
-// * Unmount overlayfs
-// * Make sure a 0,0 char device is created as upper/dummy
-// * Rename upper/dummy to cleansedOriginalPath
-func mknodChar0Overlay(cleansedOriginalPath string) error {
- dir := filepath.Dir(cleansedOriginalPath)
- tmp, err := ioutil.TempDir(dir, "mc0o")
- if err != nil {
- return errors.Wrapf(err, "failed to create a tmp directory under %s", dir)
- }
- defer os.RemoveAll(tmp)
- lower := filepath.Join(tmp, "l")
- upper := filepath.Join(tmp, "u")
- work := filepath.Join(tmp, "w")
- merged := filepath.Join(tmp, "m")
- for _, s := range []string{lower, upper, work, merged} {
- if err := os.MkdirAll(s, 0700); err != nil {
- return errors.Wrapf(err, "failed to mkdir %s", s)
- }
- }
- dummyBase := "d"
- lowerDummy := filepath.Join(lower, dummyBase)
- if err := ioutil.WriteFile(lowerDummy, []byte{}, 0600); err != nil {
- return errors.Wrapf(err, "failed to create a dummy lower file %s", lowerDummy)
- }
- // lowerdir needs ":" to be escaped: https://github.com/moby/moby/issues/40939#issuecomment-627098286
- lowerEscaped := strings.ReplaceAll(lower, ":", "\\:")
- mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerEscaped, upper, work)
- if err := mount.Mount("overlay", merged, "overlay", mOpts); err != nil {
- return err
- }
- mergedDummy := filepath.Join(merged, dummyBase)
- if err := os.Remove(mergedDummy); err != nil {
- syscall.Unmount(merged, 0)
- return errors.Wrapf(err, "failed to unlink %s", mergedDummy)
- }
- if err := syscall.Unmount(merged, 0); err != nil {
- return errors.Wrapf(err, "failed to unmount %s", merged)
- }
- upperDummy := filepath.Join(upper, dummyBase)
- if err := isChar0(upperDummy); err != nil {
- return err
- }
- if err := os.Rename(upperDummy, cleansedOriginalPath); err != nil {
- return errors.Wrapf(err, "failed to rename %s to %s", upperDummy, cleansedOriginalPath)
- }
- return nil
-}
-
-func isChar0(path string) error {
- osStat, err := os.Stat(path)
- if err != nil {
- return errors.Wrapf(err, "failed to stat %s", path)
- }
- st, ok := osStat.Sys().(*syscall.Stat_t)
- if !ok {
- return errors.Errorf("got unsupported stat for %s", path)
- }
- if os.FileMode(st.Mode)&syscall.S_IFMT != syscall.S_IFCHR {
- return errors.Errorf("%s is not a character device, got mode=%d", path, st.Mode)
- }
- if st.Rdev != 0 {
- return errors.Errorf("%s is not a 0,0 character device, got Rdev=%d", path, st.Rdev)
- }
- return nil
-}
-
-// replaceDirWithOverlayOpaque replaces path with a new directory with trusted.overlay.opaque
-// xattr. The contents of the directory are preserved.
-func replaceDirWithOverlayOpaque(path string) error {
- if path == "/" {
- return errors.New("replaceDirWithOverlayOpaque: path must not be \"/\"")
- }
- dir := filepath.Dir(path)
- tmp, err := ioutil.TempDir(dir, "rdwoo")
- if err != nil {
- return errors.Wrapf(err, "failed to create a tmp directory under %s", dir)
- }
- defer os.RemoveAll(tmp)
- // newPath is a new empty directory crafted with trusted.overlay.opaque xattr.
- // we copy the content of path into newPath, remove path, and rename newPath to path.
- newPath, err := createDirWithOverlayOpaque(tmp)
- if err != nil {
- return errors.Wrapf(err, "createDirWithOverlayOpaque(%q) failed", tmp)
- }
- if err := fs.CopyDir(newPath, path); err != nil {
- return errors.Wrapf(err, "CopyDir(%q, %q) failed", newPath, path)
- }
- if err := os.RemoveAll(path); err != nil {
- return err
- }
- return os.Rename(newPath, path)
-}
-
-// createDirWithOverlayOpaque creates a directory with trusted.overlay.opaque xattr,
-// without calling setxattr, so as to allow creating opaque dir in userns on Ubuntu.
-func createDirWithOverlayOpaque(tmp string) (string, error) {
- lower := filepath.Join(tmp, "l")
- upper := filepath.Join(tmp, "u")
- work := filepath.Join(tmp, "w")
- merged := filepath.Join(tmp, "m")
- for _, s := range []string{lower, upper, work, merged} {
- if err := os.MkdirAll(s, 0700); err != nil {
- return "", errors.Wrapf(err, "failed to mkdir %s", s)
- }
- }
- dummyBase := "d"
- lowerDummy := filepath.Join(lower, dummyBase)
- if err := os.MkdirAll(lowerDummy, 0700); err != nil {
- return "", errors.Wrapf(err, "failed to create a dummy lower directory %s", lowerDummy)
- }
- // lowerdir needs ":" to be escaped: https://github.com/moby/moby/issues/40939#issuecomment-627098286
- lowerEscaped := strings.ReplaceAll(lower, ":", "\\:")
- mOpts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lowerEscaped, upper, work)
- if err := mount.Mount("overlay", merged, "overlay", mOpts); err != nil {
- return "", err
- }
- mergedDummy := filepath.Join(merged, dummyBase)
- if err := os.Remove(mergedDummy); err != nil {
- syscall.Unmount(merged, 0)
- return "", errors.Wrapf(err, "failed to rmdir %s", mergedDummy)
- }
- // upperDummy becomes a 0,0-char device file here
- if err := os.Mkdir(mergedDummy, 0700); err != nil {
- syscall.Unmount(merged, 0)
- return "", errors.Wrapf(err, "failed to mkdir %s", mergedDummy)
- }
- // upperDummy becomes a directory with trusted.overlay.opaque xattr
- // (but can't be verified in userns)
- if err := syscall.Unmount(merged, 0); err != nil {
- return "", errors.Wrapf(err, "failed to unmount %s", merged)
- }
- upperDummy := filepath.Join(upper, dummyBase)
- return upperDummy, nil
-}
diff --git a/vendor/github.com/docker/docker/pkg/archive/archive_other.go b/vendor/github.com/docker/docker/pkg/archive/archive_other.go
index 65a73354c..2a3dc9539 100644
--- a/vendor/github.com/docker/docker/pkg/archive/archive_other.go
+++ b/vendor/github.com/docker/docker/pkg/archive/archive_other.go
@@ -2,6 +2,6 @@
package archive // import "github.com/docker/docker/pkg/archive"
-func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) tarWhiteoutConverter {
- return nil
+func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) (tarWhiteoutConverter, error) {
+ return nil, nil
}
diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go
deleted file mode 100644
index 9857fe53d..000000000
--- a/vendor/golang.org/x/sync/errgroup/errgroup.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2016 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.
-
-// Package errgroup provides synchronization, error propagation, and Context
-// cancelation for groups of goroutines working on subtasks of a common task.
-package errgroup
-
-import (
- "context"
- "sync"
-)
-
-// A Group is a collection of goroutines working on subtasks that are part of
-// the same overall task.
-//
-// A zero Group is valid and does not cancel on error.
-type Group struct {
- cancel func()
-
- wg sync.WaitGroup
-
- errOnce sync.Once
- err error
-}
-
-// WithContext returns a new Group and an associated Context derived from ctx.
-//
-// The derived Context is canceled the first time a function passed to Go
-// returns a non-nil error or the first time Wait returns, whichever occurs
-// first.
-func WithContext(ctx context.Context) (*Group, context.Context) {
- ctx, cancel := context.WithCancel(ctx)
- return &Group{cancel: cancel}, ctx
-}
-
-// Wait blocks until all function calls from the Go method have returned, then
-// returns the first non-nil error (if any) from them.
-func (g *Group) Wait() error {
- g.wg.Wait()
- if g.cancel != nil {
- g.cancel()
- }
- return g.err
-}
-
-// Go calls the given function in a new goroutine.
-//
-// The first call to return a non-nil error cancels the group; its error will be
-// returned by Wait.
-func (g *Group) Go(f func() error) {
- g.wg.Add(1)
-
- go func() {
- defer g.wg.Done()
-
- if err := f(); err != nil {
- g.errOnce.Do(func() {
- g.err = err
- if g.cancel != nil {
- g.cancel()
- }
- })
- }
- }()
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 91c62fbf2..c706ee16e 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -59,9 +59,6 @@ github.com/containerd/containerd/errdefs
github.com/containerd/containerd/log
github.com/containerd/containerd/platforms
github.com/containerd/containerd/sys
-# github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e
-github.com/containerd/continuity/fs
-github.com/containerd/continuity/sysx
# github.com/containernetworking/cni v0.8.1
github.com/containernetworking/cni/libcni
github.com/containernetworking/cni/pkg/invoke
@@ -279,7 +276,7 @@ github.com/docker/distribution/registry/client/auth/challenge
github.com/docker/distribution/registry/client/transport
github.com/docker/distribution/registry/storage/cache
github.com/docker/distribution/registry/storage/cache/memory
-# github.com/docker/docker v20.10.3-0.20210216175712-646072ed6524+incompatible
+# github.com/docker/docker v20.10.6+incompatible
github.com/docker/docker/api
github.com/docker/docker/api/types
github.com/docker/docker/api/types/blkiodev
@@ -665,7 +662,6 @@ golang.org/x/net/internal/timeseries
golang.org/x/net/proxy
golang.org/x/net/trace
# golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
-golang.org/x/sync/errgroup
golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20210423082822-04245dca01da
golang.org/x/sys/cpu