Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update containerd to v2.0.0-rc.2 #157

Merged
merged 6 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DESTDIR ?= /usr/local

VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)

CTR_LDFLAGS=-ldflags '-X github.com/containerd/containerd/version.Version=$(VERSION)'
CTR_LDFLAGS=-ldflags '-X github.com/containerd/containerd/v2/version.Version=$(VERSION)'
COMMANDS=ctd-decoder ctr-enc
RELEASE_COMMANDS=ctd-decoder

Expand Down
14 changes: 7 additions & 7 deletions cmd/ctd-decoder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (

"github.com/containerd/imgcrypt"
"github.com/containerd/imgcrypt/images/encryption"
"github.com/containerd/typeurl"
"github.com/containerd/typeurl/v2"

"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/urfave/cli"
"github.com/containerd/containerd/v2/pkg/protobuf/proto"
"github.com/containerd/containerd/v2/pkg/protobuf/types"
"github.com/urfave/cli/v2"
)

var (
Expand All @@ -40,7 +40,7 @@ func main() {
app.Usage = Usage
app.Action = run
app.Flags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "decryption-keys-path",
Usage: "Path to load decryption keys from. (optional)",
},
Expand Down Expand Up @@ -69,8 +69,8 @@ func decrypt(ctx *cli.Context) error {
decCc := &payload.DecryptConfig

// TODO: If decryption key path is set, get additional keys to augment payload keys
if ctx.GlobalIsSet("decryption-keys-path") {
keyPathCc, err := getDecryptionKeys(ctx.GlobalString("decryption-keys-path"))
if ctx.IsSet("decryption-keys-path") {
keyPathCc, err := getDecryptionKeys(ctx.String("decryption-keys-path"))
if err != nil {
return fmt.Errorf("unable to get decryption keys in provided key path: %w", err)
}
Expand Down
65 changes: 34 additions & 31 deletions cmd/ctr/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ import (
"fmt"
"io"

"github.com/containerd/containerd/cmd/ctr/commands/content"
"github.com/containerd/containerd/cmd/ctr/commands/events"
"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"
ociCmd "github.com/containerd/containerd/cmd/ctr/commands/oci"
"github.com/containerd/containerd/cmd/ctr/commands/plugins"
"github.com/containerd/containerd/cmd/ctr/commands/pprof"
"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/containerd/containerd/v2/cmd/ctr/commands/content"
"github.com/containerd/containerd/v2/cmd/ctr/commands/events"
"github.com/containerd/containerd/v2/cmd/ctr/commands/install"
"github.com/containerd/containerd/v2/cmd/ctr/commands/leases"
namespacesCmd "github.com/containerd/containerd/v2/cmd/ctr/commands/namespaces"
ociCmd "github.com/containerd/containerd/v2/cmd/ctr/commands/oci"
"github.com/containerd/containerd/v2/cmd/ctr/commands/plugins"
"github.com/containerd/containerd/v2/cmd/ctr/commands/pprof"
"github.com/containerd/containerd/v2/cmd/ctr/commands/snapshots"
"github.com/containerd/containerd/v2/cmd/ctr/commands/tasks"
versionCmd "github.com/containerd/containerd/v2/cmd/ctr/commands/version"
"github.com/containerd/containerd/v2/defaults"
"github.com/containerd/containerd/v2/pkg/namespaces"
"github.com/containerd/containerd/v2/version"
"github.com/containerd/imgcrypt/cmd/ctr/commands/containers"
"github.com/containerd/imgcrypt/cmd/ctr/commands/images"
"github.com/containerd/imgcrypt/cmd/ctr/commands/run"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
"google.golang.org/grpc/grpclog"
)

var extraCmds = []cli.Command{}
var extraCmds = []*cli.Command{}

func init() {
// Discard grpc logs so that they don't mess with our stdio
Expand Down Expand Up @@ -72,34 +72,37 @@ stable from release to release of the containerd project.`

containerd CLI
`
app.DisableSliceFlagSeparator = true
app.EnableBashCompletion = true
app.Flags = []cli.Flag{
cli.BoolFlag{
&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,
EnvVar: "CONTAINERD_ADDRESS",
&cli.StringFlag{
Name: "address",
Aliases: []string{"a"},
Usage: "address for containerd's GRPC server",
Value: defaults.DefaultAddress,
EnvVars: []string{"CONTAINERD_ADDRESS"},
},
cli.DurationFlag{
&cli.DurationFlag{
Name: "timeout",
Usage: "total timeout for ctr commands",
},
cli.DurationFlag{
&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,
&cli.StringFlag{
Name: "namespace",
Aliases: []string{"n"},
Usage: "namespace to use with commands",
Value: namespaces.Default,
EnvVars: []string{namespaces.NamespaceEnvVar},
},
}
app.Commands = append([]cli.Command{
app.Commands = append([]*cli.Command{
plugins.Command,
versionCmd.Command,
containers.Command,
Expand All @@ -116,7 +119,7 @@ containerd CLI
ociCmd.Command,
}, extraCmds...)
app.Before = func(context *cli.Context) error {
if context.GlobalBool("debug") {
if context.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/ctr/app/main_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package app

import "github.com/containerd/containerd/cmd/ctr/commands/shim"
import "github.com/containerd/containerd/v2/cmd/ctr/commands/shim"

func init() {
extraCmds = append(extraCmds, shim.Command)
Expand Down
4 changes: 2 additions & 2 deletions cmd/ctr/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"path/filepath"
"strings"

"github.com/containerd/containerd/pkg/atomicfile"
"github.com/containerd/containerd/v2/pkg/atomicfile"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// ObjectWithLabelArgs returns the first arg and a LabelArgs object
Expand Down
14 changes: 7 additions & 7 deletions cmd/ctr/commands/containers/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ import (
"errors"
"fmt"

"github.com/containerd/containerd"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/errdefs"
"github.com/urfave/cli"
containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/cmd/ctr/commands"
"github.com/containerd/errdefs"
"github.com/urfave/cli/v2"
)

var checkpointCommand = cli.Command{
Name: "checkpoint",
Usage: "checkpoint a container",
ArgsUsage: "CONTAINER REF",
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "rw",
Usage: "include the rw layer in the checkpoint",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "image",
Usage: "include the image in the checkpoint",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "task",
Usage: "checkpoint container task",
},
Expand Down
53 changes: 27 additions & 26 deletions cmd/ctr/commands/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@ import (
"strings"
"text/tabwriter"

"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/cmd/ctr/commands"
"github.com/containerd/containerd/v2/core/containers"
"github.com/containerd/containerd/v2/pkg/cio"
"github.com/containerd/errdefs"
"github.com/containerd/imgcrypt/cmd/ctr/commands/flags"
"github.com/containerd/imgcrypt/cmd/ctr/commands/run"
"github.com/containerd/typeurl"
"github.com/urfave/cli"
"github.com/containerd/log"
"github.com/containerd/typeurl/v2"
"github.com/urfave/cli/v2"
)

// Command is the cli command for managing containers
var Command = cli.Command{
var Command = &cli.Command{
Name: "containers",
Usage: "manage containers",
Aliases: []string{"c", "container"},
Subcommands: []cli.Command{
createCommand,
deleteCommand,
infoCommand,
listCommand,
setLabelsCommand,
checkpointCommand,
restoreCommand,
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(append(commands.SnapshotterFlags, commands.ContainerFlags...), flags.ImageDecryptionFlags...),
Flags: append(commands.RuntimeFlags, append(append(commands.SnapshotterFlags, commands.ContainerFlags...), flags.ImageDecryptionFlags...)...),
Action: func(context *cli.Context) error {
var (
id string
Expand Down Expand Up @@ -97,14 +97,15 @@ var listCommand = cli.Command{
Usage: "list containers",
ArgsUsage: "[flags] [<filter>, ...]",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "quiet, q",
Usage: "print only the container id",
&cli.BoolFlag{
Name: "quiet",
Aliases: []string{"q"},
Usage: "print only the container id",
},
},
Action: func(context *cli.Context) error {
var (
filters = context.Args()
filters = context.Args().Slice()
quiet = context.Bool("quiet")
)
client, ctx, cancel, err := commands.NewClient(context)
Expand Down Expand Up @@ -151,7 +152,7 @@ var deleteCommand = cli.Command{
ArgsUsage: "[flags] CONTAINER [CONTAINER, ...]",
Aliases: []string{"del", "remove", "rm"},
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "keep-snapshot",
Usage: "do not clean up snapshot with container",
},
Expand All @@ -171,7 +172,7 @@ var deleteCommand = cli.Command{
if context.NArg() == 0 {
return fmt.Errorf("must specify at least one container to delete: %w", errdefs.ErrInvalidArgument)
}
for _, arg := range context.Args() {
for _, arg := range context.Args().Slice() {
if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil {
if exitErr == nil {
exitErr = err
Expand Down Expand Up @@ -249,7 +250,7 @@ var infoCommand = cli.Command{
Usage: "get info about a container",
ArgsUsage: "CONTAINER",
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "spec",
Usage: "only display the spec",
},
Expand Down Expand Up @@ -281,7 +282,7 @@ var infoCommand = cli.Command{
return nil
}

if info.Spec != nil && info.Spec.Value != nil {
if info.Spec != nil && info.Spec.GetValue() != nil {
v, err := typeurl.UnmarshalAny(info.Spec)
if err != nil {
return err
Expand Down
14 changes: 7 additions & 7 deletions cmd/ctr/commands/containers/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ package containers
import (
"errors"

"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/errdefs"
"github.com/urfave/cli"
containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/cmd/ctr/commands"
"github.com/containerd/containerd/v2/pkg/cio"
"github.com/containerd/errdefs"
"github.com/urfave/cli/v2"
)

var restoreCommand = cli.Command{
Name: "restore",
Usage: "restore a container from checkpoint",
ArgsUsage: "CONTAINER REF",
Flags: []cli.Flag{
cli.BoolFlag{
&cli.BoolFlag{
Name: "rw",
Usage: "restore the rw layer from the checkpoint",
},
cli.BoolFlag{
&cli.BoolFlag{
Name: "live",
Usage: "restore the runtime and memory data from the checkpoint",
},
Expand Down
12 changes: 6 additions & 6 deletions cmd/ctr/commands/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
package flags

import (
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

var (
// ImageDecryptionFlags are cli flags needed when decrypting an image
ImageDecryptionFlags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "gpg-homedir",
Usage: "The GPG homedir to use; by default gpg uses ~/.gnupg",
}, cli.StringFlag{
}, &cli.StringFlag{
Name: "gpg-version",
Usage: "The GPG version (\"v1\" or \"v2\"), default will make an educated guess",
}, cli.BoolFlag{
}, &cli.BoolFlag{
Name: "skip-decrypt-auth",
Usage: "Indicates if check authorization for use of images should be skipped i.e. for use in node key model",
},
cli.StringSliceFlag{
&cli.StringSliceFlag{
Name: "key",
Usage: "A secret key's filename and an optional password separated by colon; this option may be provided multiple times",
}, cli.StringSliceFlag{
}, &cli.StringSliceFlag{
Name: "dec-recipient",
Usage: "Recipient of the image; used only for PKCS7 and must be an x509 certificate",
},
Expand Down
Loading
Loading