From 72819d68d1597f4b56f0d4fb1bccc870a5e68734 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Wed, 12 Jun 2019 11:16:15 -0700 Subject: [PATCH] Update vendor Signed-off-by: Lantao Liu --- .../containerd/containerd/cmd/ctr/app/main.go | 116 ---- .../containerd/cmd/ctr/app/main_unix.go | 25 - .../containerd/cmd/ctr/commands/client.go | 56 -- .../containerd/cmd/ctr/commands/commands.go | 187 ----- .../cmd/ctr/commands/commands_unix.go | 33 - .../cmd/ctr/commands/commands_windows.go | 30 - .../cmd/ctr/commands/containers/checkpoint.go | 102 --- .../cmd/ctr/commands/containers/containers.go | 286 -------- .../cmd/ctr/commands/containers/restore.go | 96 --- .../cmd/ctr/commands/content/content.go | 570 ---------------- .../cmd/ctr/commands/content/fetch.go | 382 ----------- .../cmd/ctr/commands/events/events.go | 77 --- .../cmd/ctr/commands/images/export.go | 113 ---- .../cmd/ctr/commands/images/images.go | 330 --------- .../cmd/ctr/commands/images/import.go | 144 ---- .../cmd/ctr/commands/images/pull.go | 121 ---- .../cmd/ctr/commands/images/push.go | 218 ------ .../cmd/ctr/commands/install/install.go | 68 -- .../cmd/ctr/commands/leases/leases.go | 202 ------ .../cmd/ctr/commands/namespaces/namespaces.go | 173 ----- .../cmd/ctr/commands/plugins/plugins.go | 162 ----- .../cmd/ctr/commands/pprof/pprof.go | 189 ------ .../cmd/ctr/commands/pprof/pprof_unix.go | 29 - .../cmd/ctr/commands/pprof/pprof_windows.go | 31 - .../containerd/cmd/ctr/commands/resolver.go | 109 --- .../containerd/cmd/ctr/commands/run/run.go | 215 ------ .../cmd/ctr/commands/run/run_unix.go | 194 ------ .../cmd/ctr/commands/run/run_windows.go | 140 ---- .../cmd/ctr/commands/shim/io_unix.go | 93 --- .../containerd/cmd/ctr/commands/shim/shim.go | 258 ------- .../containerd/cmd/ctr/commands/signals.go | 52 -- .../cmd/ctr/commands/snapshots/snapshots.go | 636 ------------------ .../cmd/ctr/commands/tasks/attach.go | 86 --- .../cmd/ctr/commands/tasks/checkpoint.go | 123 ---- .../cmd/ctr/commands/tasks/delete.go | 85 --- .../containerd/cmd/ctr/commands/tasks/exec.go | 143 ---- .../containerd/cmd/ctr/commands/tasks/kill.go | 96 --- .../containerd/cmd/ctr/commands/tasks/list.go | 71 -- .../cmd/ctr/commands/tasks/metrics.go | 117 ---- .../cmd/ctr/commands/tasks/pause.go | 44 -- .../containerd/cmd/ctr/commands/tasks/ps.go | 72 -- .../cmd/ctr/commands/tasks/resume.go | 44 -- .../cmd/ctr/commands/tasks/start.go | 137 ---- .../cmd/ctr/commands/tasks/tasks.go | 46 -- .../cmd/ctr/commands/tasks/tasks_unix.go | 105 --- .../cmd/ctr/commands/tasks/tasks_windows.go | 78 --- .../cmd/ctr/commands/version/version.go | 57 -- .../containerd/contrib/nvidia/nvidia.go | 211 ------ .../containerd/containerd/pkg/progress/bar.go | 82 --- .../containerd/containerd/pkg/progress/doc.go | 18 - .../containerd/pkg/progress/escape.go | 24 - .../containerd/pkg/progress/humaans.go | 45 -- .../containerd/pkg/progress/writer.go | 115 ---- .../runtime/v2/runhcs/options/doc.go | 17 - .../runtime/v2/runhcs/options/runhcs.pb.go | 627 ----------------- .../runtime/v2/runhcs/options/runhcs.proto | 43 -- 56 files changed, 7923 deletions(-) delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/app/main.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/app/main_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/client.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/commands.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_windows.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/checkpoint.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/containers.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/restore.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/content/fetch.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/events/events.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/images/export.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/images/images.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/images/import.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/images/pull.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/images/push.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/install/install.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/leases/leases.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/namespaces/namespaces.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/plugins/plugins.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/pprof/pprof.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/pprof/pprof_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/pprof/pprof_windows.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/resolver.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/run/run.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/run/run_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/run/run_windows.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/shim/io_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/shim/shim.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/signals.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/snapshots/snapshots.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/attach.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/checkpoint.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/delete.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/exec.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/kill.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/list.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/metrics.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/pause.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/ps.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/resume.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/start.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/tasks.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/tasks_unix.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/tasks/tasks_windows.go delete mode 100644 vendor/github.com/containerd/containerd/cmd/ctr/commands/version/version.go delete mode 100644 vendor/github.com/containerd/containerd/contrib/nvidia/nvidia.go delete mode 100644 vendor/github.com/containerd/containerd/pkg/progress/bar.go delete mode 100644 vendor/github.com/containerd/containerd/pkg/progress/doc.go delete mode 100644 vendor/github.com/containerd/containerd/pkg/progress/escape.go delete mode 100644 vendor/github.com/containerd/containerd/pkg/progress/humaans.go delete mode 100644 vendor/github.com/containerd/containerd/pkg/progress/writer.go delete mode 100644 vendor/github.com/containerd/containerd/runtime/v2/runhcs/options/doc.go delete mode 100644 vendor/github.com/containerd/containerd/runtime/v2/runhcs/options/runhcs.pb.go delete mode 100644 vendor/github.com/containerd/containerd/runtime/v2/runhcs/options/runhcs.proto diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/app/main.go b/vendor/github.com/containerd/containerd/cmd/ctr/app/main.go deleted file mode 100644 index 9c33216b3..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/app/main.go +++ /dev/null @@ -1,116 +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 app - -import ( - "fmt" - "io/ioutil" - - "github.com/containerd/containerd/cmd/ctr/commands/containers" - "github.com/containerd/containerd/cmd/ctr/commands/content" - "github.com/containerd/containerd/cmd/ctr/commands/events" - "github.com/containerd/containerd/cmd/ctr/commands/images" - "github.com/containerd/containerd/cmd/ctr/commands/install" - "github.com/containerd/containerd/cmd/ctr/commands/leases" - namespacesCmd "github.com/containerd/containerd/cmd/ctr/commands/namespaces" - "github.com/containerd/containerd/cmd/ctr/commands/plugins" - "github.com/containerd/containerd/cmd/ctr/commands/pprof" - "github.com/containerd/containerd/cmd/ctr/commands/run" - "github.com/containerd/containerd/cmd/ctr/commands/snapshots" - "github.com/containerd/containerd/cmd/ctr/commands/tasks" - versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version" - "github.com/containerd/containerd/defaults" - "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/version" - "github.com/sirupsen/logrus" - "github.com/urfave/cli" - "google.golang.org/grpc/grpclog" -) - -var extraCmds = []cli.Command{} - -func init() { - // Discard grpc logs so that they don't mess with our stdio - grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard)) - - cli.VersionPrinter = func(c *cli.Context) { - fmt.Println(c.App.Name, version.Package, c.App.Version) - } -} - -// New returns a *cli.App instance. -func New() *cli.App { - app := cli.NewApp() - app.Name = "ctr" - app.Version = version.Version - app.Usage = ` - __ - _____/ /______ - / ___/ __/ ___/ -/ /__/ /_/ / -\___/\__/_/ - -containerd CLI -` - app.Flags = []cli.Flag{ - cli.BoolFlag{ - Name: "debug", - Usage: "enable debug output in logs", - }, - cli.StringFlag{ - Name: "address, a", - Usage: "address for containerd's GRPC server", - Value: defaults.DefaultAddress, - }, - cli.DurationFlag{ - Name: "timeout", - Usage: "total timeout for ctr commands", - }, - cli.DurationFlag{ - Name: "connect-timeout", - Usage: "timeout for connecting to containerd", - }, - cli.StringFlag{ - Name: "namespace, n", - Usage: "namespace to use with commands", - Value: namespaces.Default, - EnvVar: namespaces.NamespaceEnvVar, - }, - } - app.Commands = append([]cli.Command{ - plugins.Command, - versionCmd.Command, - containers.Command, - content.Command, - events.Command, - images.Command, - leases.Command, - namespacesCmd.Command, - pprof.Command, - run.Command, - snapshots.Command, - tasks.Command, - install.Command, - }, extraCmds...) - app.Before = func(context *cli.Context) error { - if context.GlobalBool("debug") { - logrus.SetLevel(logrus.DebugLevel) - } - return nil - } - return app -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/app/main_unix.go b/vendor/github.com/containerd/containerd/cmd/ctr/app/main_unix.go deleted file mode 100644 index c0eb1b6e1..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/app/main_unix.go +++ /dev/null @@ -1,25 +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 app - -import "github.com/containerd/containerd/cmd/ctr/commands/shim" - -func init() { - extraCmds = append(extraCmds, shim.Command) -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/client.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/client.go deleted file mode 100644 index b436186b2..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/client.go +++ /dev/null @@ -1,56 +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 commands - -import ( - gocontext "context" - - "github.com/containerd/containerd" - "github.com/containerd/containerd/namespaces" - "github.com/urfave/cli" -) - -// AppContext returns the context for a command. Should only be called once per -// command, near the start. -// -// This will ensure the namespace is picked up and set the timeout, if one is -// defined. -func AppContext(context *cli.Context) (gocontext.Context, gocontext.CancelFunc) { - var ( - ctx = gocontext.Background() - timeout = context.GlobalDuration("timeout") - namespace = context.GlobalString("namespace") - cancel gocontext.CancelFunc - ) - ctx = namespaces.WithNamespace(ctx, namespace) - if timeout > 0 { - ctx, cancel = gocontext.WithTimeout(ctx, timeout) - } else { - ctx, cancel = gocontext.WithCancel(ctx) - } - return ctx, cancel -} - -// NewClient returns a new containerd client -func NewClient(context *cli.Context, opts ...containerd.ClientOpt) (*containerd.Client, gocontext.Context, gocontext.CancelFunc, error) { - client, err := containerd.New(context.GlobalString("address"), opts...) - if err != nil { - return nil, nil, nil, err - } - ctx, cancel := AppContext(context) - return client, ctx, cancel, nil -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands.go deleted file mode 100644 index 6d9fb5488..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands.go +++ /dev/null @@ -1,187 +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 commands - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "runtime" - "strings" - - "github.com/containerd/containerd" - "github.com/urfave/cli" -) - -var ( - // SnapshotterFlags are cli flags specifying snapshotter names - SnapshotterFlags = []cli.Flag{ - cli.StringFlag{ - Name: "snapshotter", - Usage: "snapshotter name. Empty value stands for the default value.", - Value: containerd.DefaultSnapshotter, - EnvVar: "CONTAINERD_SNAPSHOTTER", - }, - } - - // LabelFlag is a cli flag specifying labels - LabelFlag = cli.StringSliceFlag{ - Name: "label", - Usage: "labels to attach to the image", - } - - // RegistryFlags are cli flags specifying registry options - RegistryFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "skip-verify,k", - Usage: "skip SSL certificate validation", - }, - cli.BoolFlag{ - Name: "plain-http", - Usage: "allow connections using plain HTTP", - }, - cli.StringFlag{ - Name: "user,u", - Usage: "user[:password] Registry user and password", - }, - cli.StringFlag{ - Name: "refresh", - Usage: "refresh token for authorization server", - }, - } - - // ContainerFlags are cli flags specifying container options - ContainerFlags = []cli.Flag{ - cli.StringFlag{ - Name: "config,c", - Usage: "path to the runtime-specific spec config file", - }, - cli.StringFlag{ - Name: "cwd", - Usage: "specify the working directory of the process", - }, - cli.StringSliceFlag{ - Name: "env", - Usage: "specify additional container environment variables (i.e. FOO=bar)", - }, - cli.StringSliceFlag{ - Name: "label", - Usage: "specify additional labels (i.e. foo=bar)", - }, - cli.StringSliceFlag{ - Name: "mount", - Usage: "specify additional container mount (ex: type=bind,src=/tmp,dst=/host,options=rbind:ro)", - }, - cli.BoolFlag{ - Name: "net-host", - Usage: "enable host networking for the container", - }, - cli.BoolFlag{ - Name: "privileged", - Usage: "run privileged container", - }, - cli.BoolFlag{ - Name: "read-only", - Usage: "set the containers filesystem as readonly", - }, - cli.StringFlag{ - Name: "runtime", - Usage: "runtime name", - Value: fmt.Sprintf("io.containerd.runtime.v1.%s", runtime.GOOS), - }, - cli.BoolFlag{ - Name: "tty,t", - Usage: "allocate a TTY for the container", - }, - cli.StringSliceFlag{ - Name: "with-ns", - Usage: "specify existing Linux namespaces to join at container runtime (format ':')", - }, - cli.StringFlag{ - Name: "pid-file", - Usage: "file path to write the task's pid", - }, - cli.IntFlag{ - Name: "gpus", - Usage: "add gpus to the container", - }, - cli.BoolFlag{ - Name: "allow-new-privs", - Usage: "turn off OCI spec's NoNewPrivileges feature flag", - }, - cli.Uint64Flag{ - Name: "memory-limit", - Usage: "memory limit (in bytes) for the container", - }, - } -) - -// ObjectWithLabelArgs returns the first arg and a LabelArgs object -func ObjectWithLabelArgs(clicontext *cli.Context) (string, map[string]string) { - var ( - first = clicontext.Args().First() - labelStrings = clicontext.Args().Tail() - ) - - return first, LabelArgs(labelStrings) -} - -// LabelArgs returns a map of label key,value pairs -func LabelArgs(labelStrings []string) map[string]string { - labels := make(map[string]string, len(labelStrings)) - for _, label := range labelStrings { - parts := strings.SplitN(label, "=", 2) - key := parts[0] - value := "true" - if len(parts) > 1 { - value = parts[1] - } - - labels[key] = value - } - - return labels -} - -// PrintAsJSON prints input in JSON format -func PrintAsJSON(x interface{}) { - b, err := json.MarshalIndent(x, "", " ") - if err != nil { - fmt.Fprintf(os.Stderr, "can't marshal %+v as a JSON string: %v\n", x, err) - } - fmt.Println(string(b)) -} - -// WritePidFile writes the pid atomically to a file -func WritePidFile(path string, pid int) error { - path, err := filepath.Abs(path) - if err != nil { - return err - } - tempPath := filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s", filepath.Base(path))) - f, err := os.OpenFile(tempPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666) - if err != nil { - return err - } - _, err = fmt.Fprintf(f, "%d", pid) - f.Close() - if err != nil { - return err - } - return os.Rename(tempPath, path) -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_unix.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_unix.go deleted file mode 100644 index a67fa8f6a..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_unix.go +++ /dev/null @@ -1,33 +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 commands - -import ( - "github.com/urfave/cli" -) - -func init() { - ContainerFlags = append(ContainerFlags, cli.BoolFlag{ - Name: "rootfs", - Usage: "use custom rootfs that is not managed by containerd snapshotter", - }, cli.BoolFlag{ - Name: "no-pivot", - Usage: "disable use of pivot-root (linux only)", - }) -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_windows.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_windows.go deleted file mode 100644 index 4bd3d2596..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/commands_windows.go +++ /dev/null @@ -1,30 +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 commands - -import ( - "github.com/urfave/cli" -) - -func init() { - ContainerFlags = append(ContainerFlags, cli.Uint64Flag{ - Name: "cpu-count", - Usage: "number of CPUs available to the container", - }) -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/checkpoint.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/checkpoint.go deleted file mode 100644 index 53bf70b3c..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/checkpoint.go +++ /dev/null @@ -1,102 +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 containers - -import ( - "fmt" - - "github.com/containerd/containerd" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/errdefs" - "github.com/pkg/errors" - "github.com/urfave/cli" -) - -var checkpointCommand = cli.Command{ - Name: "checkpoint", - Usage: "checkpoint a container", - ArgsUsage: "CONTAINER REF", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "rw", - Usage: "include the rw layer in the checkpoint", - }, - cli.BoolFlag{ - Name: "image", - Usage: "include the image in the checkpoint", - }, - cli.BoolFlag{ - Name: "task", - Usage: "checkpoint container task", - }, - }, - Action: func(context *cli.Context) error { - id := context.Args().First() - if id == "" { - return errors.New("container id must be provided") - } - ref := context.Args().Get(1) - if ref == "" { - return errors.New("ref must be provided") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - opts := []containerd.CheckpointOpts{ - containerd.WithCheckpointRuntime, - } - - if context.Bool("image") { - opts = append(opts, containerd.WithCheckpointImage) - } - if context.Bool("rw") { - opts = append(opts, containerd.WithCheckpointRW) - } - if context.Bool("task") { - opts = append(opts, containerd.WithCheckpointTask) - } - container, err := client.LoadContainer(ctx, id) - if err != nil { - return err - } - task, err := container.Task(ctx, nil) - if err != nil { - if !errdefs.IsNotFound(err) { - return err - } - } - // pause if running - if task != nil { - if err := task.Pause(ctx); err != nil { - return err - } - defer func() { - if err := task.Resume(ctx); err != nil { - fmt.Println(errors.Wrap(err, "error resuming task")) - } - }() - } - - if _, err := container.Checkpoint(ctx, ref, opts...); err != nil { - return err - } - - return nil - }, -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/containers.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/containers.go deleted file mode 100644 index fa0201064..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/containers.go +++ /dev/null @@ -1,286 +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 containers - -import ( - "context" - "fmt" - "os" - "strings" - "text/tabwriter" - - "github.com/containerd/containerd" - "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/cmd/ctr/commands/run" - "github.com/containerd/containerd/containers" - "github.com/containerd/containerd/log" - "github.com/containerd/typeurl" - "github.com/pkg/errors" - "github.com/urfave/cli" -) - -// Command is the cli command for managing containers -var Command = cli.Command{ - Name: "containers", - Usage: "manage containers", - Aliases: []string{"c", "container"}, - Subcommands: []cli.Command{ - createCommand, - deleteCommand, - infoCommand, - listCommand, - setLabelsCommand, - checkpointCommand, - restoreCommand, - }, -} - -var createCommand = cli.Command{ - Name: "create", - Usage: "create container", - ArgsUsage: "[flags] Image|RootFS CONTAINER [COMMAND] [ARG...]", - Flags: append(commands.SnapshotterFlags, commands.ContainerFlags...), - Action: func(context *cli.Context) error { - var ( - id string - ref string - config = context.IsSet("config") - ) - - if config { - id = context.Args().First() - if context.NArg() > 1 { - return errors.New("with spec config file, only container id should be provided") - } - } else { - id = context.Args().Get(1) - ref = context.Args().First() - if ref == "" { - return errors.New("image ref must be provided") - } - } - if id == "" { - return errors.New("container id must be provided") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - _, err = run.NewContainer(ctx, client, context) - if err != nil { - return err - } - return nil - }, -} - -var listCommand = cli.Command{ - Name: "list", - Aliases: []string{"ls"}, - Usage: "list containers", - ArgsUsage: "[flags] [, ...]", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "quiet, q", - Usage: "print only the container id", - }, - }, - Action: func(context *cli.Context) error { - var ( - filters = context.Args() - quiet = context.Bool("quiet") - ) - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - containers, err := client.Containers(ctx, filters...) - if err != nil { - return err - } - if quiet { - for _, c := range containers { - fmt.Printf("%s\n", c.ID()) - } - return nil - } - w := tabwriter.NewWriter(os.Stdout, 4, 8, 4, ' ', 0) - fmt.Fprintln(w, "CONTAINER\tIMAGE\tRUNTIME\t") - for _, c := range containers { - info, err := c.Info(ctx, containerd.WithoutRefreshedMetadata) - if err != nil { - return err - } - imageName := info.Image - if imageName == "" { - imageName = "-" - } - if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t\n", - c.ID(), - imageName, - info.Runtime.Name, - ); err != nil { - return err - } - } - return w.Flush() - }, -} - -var deleteCommand = cli.Command{ - Name: "delete", - Usage: "delete one or more existing containers", - ArgsUsage: "[flags] CONTAINER [CONTAINER, ...]", - Aliases: []string{"del", "rm"}, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "keep-snapshot", - Usage: "do not clean up snapshot with container", - }, - }, - Action: func(context *cli.Context) error { - var exitErr error - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - deleteOpts := []containerd.DeleteOpts{} - if !context.Bool("keep-snapshot") { - deleteOpts = append(deleteOpts, containerd.WithSnapshotCleanup) - } - - if context.NArg() == 0 { - return errors.New("must specify at least one container to delete") - } - for _, arg := range context.Args() { - if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil { - if exitErr == nil { - exitErr = err - } - log.G(ctx).WithError(err).Errorf("failed to delete container %q", arg) - } - } - return exitErr - }, -} - -func deleteContainer(ctx context.Context, client *containerd.Client, id string, opts ...containerd.DeleteOpts) error { - container, err := client.LoadContainer(ctx, id) - if err != nil { - return err - } - task, err := container.Task(ctx, cio.Load) - if err != nil { - return container.Delete(ctx, opts...) - } - status, err := task.Status(ctx) - if err != nil { - return err - } - if status.Status == containerd.Stopped || status.Status == containerd.Created { - if _, err := task.Delete(ctx); err != nil { - return err - } - return container.Delete(ctx, opts...) - } - return fmt.Errorf("cannot delete a non stopped container: %v", status) - -} - -var setLabelsCommand = cli.Command{ - Name: "label", - Usage: "set and clear labels for a container", - ArgsUsage: "[flags] CONTAINER [=, ...]", - Description: "set and clear labels for a container", - Flags: []cli.Flag{}, - Action: func(context *cli.Context) error { - containerID, labels := commands.ObjectWithLabelArgs(context) - if containerID == "" { - return errors.New("container id must be provided") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - - container, err := client.LoadContainer(ctx, containerID) - if err != nil { - return err - } - - setlabels, err := container.SetLabels(ctx, labels) - if err != nil { - return err - } - - var labelStrings []string - for k, v := range setlabels { - labelStrings = append(labelStrings, fmt.Sprintf("%s=%s", k, v)) - } - - fmt.Println(strings.Join(labelStrings, ",")) - - return nil - }, -} - -var infoCommand = cli.Command{ - Name: "info", - Usage: "get info about a container", - ArgsUsage: "CONTAINER", - Action: func(context *cli.Context) error { - id := context.Args().First() - if id == "" { - return errors.New("container id must be provided") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - container, err := client.LoadContainer(ctx, id) - if err != nil { - return err - } - info, err := container.Info(ctx, containerd.WithoutRefreshedMetadata) - if err != nil { - return err - } - - if info.Spec != nil && info.Spec.Value != nil { - v, err := typeurl.UnmarshalAny(info.Spec) - if err != nil { - return err - } - commands.PrintAsJSON(struct { - containers.Container - Spec interface{} `json:"Spec,omitempty"` - }{ - Container: info, - Spec: v, - }) - return nil - } - commands.PrintAsJSON(info) - return nil - }, -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/restore.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/restore.go deleted file mode 100644 index 85337b34d..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/containers/restore.go +++ /dev/null @@ -1,96 +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 containers - -import ( - "github.com/containerd/containerd" - "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/errdefs" - "github.com/pkg/errors" - "github.com/urfave/cli" -) - -var restoreCommand = cli.Command{ - Name: "restore", - Usage: "restore a container from checkpoint", - ArgsUsage: "CONTAINER REF", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "rw", - Usage: "restore the rw layer from the checkpoint", - }, - cli.BoolFlag{ - Name: "live", - Usage: "restore the runtime and memory data from the checkpoint", - }, - }, - Action: func(context *cli.Context) error { - id := context.Args().First() - if id == "" { - return errors.New("container id must be provided") - } - ref := context.Args().Get(1) - if ref == "" { - return errors.New("ref must be provided") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - - checkpoint, err := client.GetImage(ctx, ref) - if err != nil { - if !errdefs.IsNotFound(err) { - return err - } - // TODO (ehazlett): consider other options (always/never fetch) - ck, err := client.Fetch(ctx, ref) - if err != nil { - return err - } - checkpoint = containerd.NewImage(client, ck) - } - - opts := []containerd.RestoreOpts{ - containerd.WithRestoreImage, - containerd.WithRestoreSpec, - containerd.WithRestoreRuntime, - } - if context.Bool("rw") { - opts = append(opts, containerd.WithRestoreRW) - } - - ctr, err := client.Restore(ctx, id, checkpoint, opts...) - if err != nil { - return err - } - - topts := []containerd.NewTaskOpts{} - if context.Bool("live") { - topts = append(topts, containerd.WithTaskCheckpoint(checkpoint)) - } - - task, err := ctr.NewTask(ctx, cio.NewCreator(cio.WithStdio), topts...) - if err != nil { - return err - } - - return task.Start(ctx) - }, -} diff --git a/vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go b/vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go deleted file mode 100644 index 737fc1672..000000000 --- a/vendor/github.com/containerd/containerd/cmd/ctr/commands/content/content.go +++ /dev/null @@ -1,570 +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 content - -import ( - "fmt" - "io" - "io/ioutil" - "os" - "os/exec" - "strings" - "text/tabwriter" - "time" - - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/log" - units "github.com/docker/go-units" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" - "github.com/urfave/cli" -) - -var ( - // Command is the cli command for managing content - Command = cli.Command{ - Name: "content", - Usage: "manage content", - Subcommands: cli.Commands{ - activeIngestCommand, - deleteCommand, - editCommand, - fetchCommand, - fetchObjectCommand, - getCommand, - ingestCommand, - listCommand, - pushObjectCommand, - setLabelsCommand, - }, - } - - getCommand = cli.Command{ - Name: "get", - Usage: "get the data for an object", - ArgsUsage: "[, ...]", - Description: "display the image object", - Action: func(context *cli.Context) error { - dgst, err := digest.Parse(context.Args().First()) - if err != nil { - return err - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - cs := client.ContentStore() - ra, err := cs.ReaderAt(ctx, ocispec.Descriptor{Digest: dgst}) - if err != nil { - return err - } - defer ra.Close() - - _, err = io.Copy(os.Stdout, content.NewReader(ra)) - return err - }, - } - - ingestCommand = cli.Command{ - Name: "ingest", - Usage: "accept content into the store", - ArgsUsage: "[flags] ", - Description: "ingest objects into the local content store", - Flags: []cli.Flag{ - cli.Int64Flag{ - Name: "expected-size", - Usage: "validate against provided size", - }, - cli.StringFlag{ - Name: "expected-digest", - Usage: "verify content against expected digest", - }, - }, - Action: func(context *cli.Context) error { - var ( - ref = context.Args().First() - expectedSize = context.Int64("expected-size") - expectedDigest = digest.Digest(context.String("expected-digest")) - ) - if err := expectedDigest.Validate(); expectedDigest != "" && err != nil { - return err - } - if ref == "" { - return errors.New("must specify a transaction reference") - } - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - - cs := client.ContentStore() - - // TODO(stevvooe): Allow ingest to be reentrant. Currently, we expect - // all data to be written in a single invocation. Allow multiple writes - // to the same transaction key followed by a commit. - return content.WriteBlob(ctx, cs, ref, os.Stdin, ocispec.Descriptor{Size: expectedSize, Digest: expectedDigest}) - }, - } - - activeIngestCommand = cli.Command{ - Name: "active", - Usage: "display active transfers", - ArgsUsage: "[flags] []", - Description: "display the ongoing transfers", - Flags: []cli.Flag{ - cli.DurationFlag{ - Name: "timeout, t", - Usage: "total timeout for fetch", - EnvVar: "CONTAINERD_FETCH_TIMEOUT", - }, - cli.StringFlag{ - Name: "root", - Usage: "path to content store root", - Value: "/tmp/content", // TODO(stevvooe): for now, just use the PWD/.content - }, - }, - Action: func(context *cli.Context) error { - match := context.Args().First() - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - cs := client.ContentStore() - active, err := cs.ListStatuses(ctx, match) - if err != nil { - return err - } - tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0) - fmt.Fprintln(tw, "REF\tSIZE\tAGE\t") - for _, active := range active { - fmt.Fprintf(tw, "%s\t%s\t%s\t\n", - active.Ref, - units.HumanSize(float64(active.Offset)), - units.HumanDuration(time.Since(active.StartedAt))) - } - - return tw.Flush() - }, - } - - listCommand = cli.Command{ - Name: "list", - Aliases: []string{"ls"}, - Usage: "list all blobs in the store", - ArgsUsage: "[flags]", - Description: "list blobs in the content store", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "quiet, q", - Usage: "print only the blob digest", - }, - }, - Action: func(context *cli.Context) error { - var ( - quiet = context.Bool("quiet") - args = []string(context.Args()) - ) - client, ctx, cancel, err := commands.NewClient(context) - if err != nil { - return err - } - defer cancel() - cs := client.ContentStore() - - var walkFn content.WalkFunc - if quiet { - walkFn = func(info content.Info) error { - fmt.Println(info.Digest) - return nil - } - } else { - tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0) - defer tw.Flush() - - fmt.Fprintln(tw, "DIGEST\tSIZE\tAGE\tLABELS") - walkFn = func(info content.Info) error { - var labelStrings []string - for k, v := range info.Labels { - labelStrings = append(labelStrings, strings.Join([]string{k, v}, "=")) - } - labels := strings.Join(labelStrings, ",") - if labels == "" { - labels = "-" - } - - fmt.Fprintf(tw, "%s\t%s\t%s\t%s\n", - info.Digest, - units.HumanSize(float64(info.Size)), - units.HumanDuration(time.Since(info.CreatedAt)), - labels) - return nil - } - - } - - return cs.Walk(ctx, walkFn, args...) - }, - } - - setLabelsCommand = cli.Command{ - Name: "label", - Usage: "add labels to content", - ArgsUsage: " [