From 32675f9837d585d957849cabf72a4afd83cbd19c Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 11:12:43 -0700 Subject: [PATCH 1/6] Revert "remove imports of errdefs package" This reverts commit f5ce2f2049204e1792756b156299eb3470379692. Signed-off-by: Derek McGowan --- sandbox/bridge.go | 2 +- services/introspection/service.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sandbox/bridge.go b/sandbox/bridge.go index 5ff19b9badee..3c1a9c2fd0e5 100644 --- a/sandbox/bridge.go +++ b/sandbox/bridge.go @@ -24,7 +24,7 @@ import ( "google.golang.org/grpc" api "github.com/containerd/containerd/api/runtime/sandbox/v1" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) // NewClient returns a new sandbox client that handles both GRPC and TTRPC clients. diff --git a/services/introspection/service.go b/services/introspection/service.go index 62d2f2d79548..71b24aa7dca3 100644 --- a/services/introspection/service.go +++ b/services/introspection/service.go @@ -17,16 +17,16 @@ package introspection import ( - "context" + context "context" "errors" "google.golang.org/grpc" api "github.com/containerd/containerd/api/services/introspection/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/services" - "github.com/containerd/errdefs" ) func init() { From ae80077e80712ba27c162d85498bc7180710c210 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 11:13:58 -0700 Subject: [PATCH 2/6] Revert "golangci-lint: enable depguard for packages that moved" This reverts commit 136e1b72d8330d43b9cedf051a0b745cf70df9ee. Signed-off-by: Derek McGowan --- .golangci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fb8b972f7a7a..498383ba616b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -66,8 +66,6 @@ linters-settings: rules: main: deny: - - pkg: "github.com/containerd/containerd/errdefs" - desc: The containerd errdefs package was migrated to a separate module. Use github.com/containerd/errdefs instead. - pkg: "github.com/containerd/containerd/log" desc: The containerd log package was migrated to a separate module. Use github.com/containerd/log instead. - pkg: "github.com/containerd/containerd/platforms" From 51939238f648806330c67a0294b5b75c79956d75 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 11:14:41 -0700 Subject: [PATCH 3/6] Revert "errdefs: denote deprecation as a godoc comment" This reverts commit c7d5e430a4dc9e7fb3a0241adfb5477466f09c59. Signed-off-by: Derek McGowan --- errdefs/errdefs_deprecated.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/errdefs/errdefs_deprecated.go b/errdefs/errdefs_deprecated.go index a88cb8b18933..c6a0d843ebef 100644 --- a/errdefs/errdefs_deprecated.go +++ b/errdefs/errdefs_deprecated.go @@ -24,8 +24,6 @@ // // The functions ToGRPC and FromGRPC can be used to map server-side and // client-side errors to the correct types. -// -// Deprecated: use [github.com/containerd/errdefs]. package errdefs import ( From e82d201b3ffb87c15d2b7be2eb2e0c7bfa99d114 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 22:12:42 -0700 Subject: [PATCH 4/6] Revert "replace uses of github.com/containerd/containerd/errdefs" This reverts commit 308341a4464bd723630d3df19a5df20aa252af9f. Signed-off-by: Derek McGowan --- client.go | 21 ++++++++++--------- cmd/containerd/command/main.go | 9 ++++---- cmd/containerd/command/publish.go | 2 +- cmd/containerd/command/service_windows.go | 2 +- cmd/ctr/commands/containers/checkpoint.go | 2 +- cmd/ctr/commands/containers/containers.go | 2 +- cmd/ctr/commands/containers/restore.go | 2 +- cmd/ctr/commands/content/content.go | 9 ++++---- cmd/ctr/commands/content/fetch.go | 13 ++++++------ cmd/ctr/commands/images/images.go | 9 ++++---- cmd/ctr/commands/images/mount.go | 9 ++++---- cmd/ctr/commands/images/tag.go | 2 +- cmd/ctr/commands/images/unmount.go | 5 +++-- cmd/ctr/commands/namespaces/namespaces.go | 5 +++-- cmd/ctr/commands/signals.go | 2 +- container.go | 2 +- container_opts.go | 2 +- container_opts_unix.go | 2 +- containerstore.go | 2 +- content/helpers.go | 5 +++-- content/helpers_test.go | 2 +- content/local/locks.go | 2 +- content/local/readerat.go | 2 +- content/local/store.go | 7 ++++--- content/local/store_test.go | 2 +- content/local/writer.go | 5 +++-- content/proxy/content_store.go | 2 +- content/proxy/content_writer.go | 2 +- content/testsuite/testsuite.go | 7 ++++--- contrib/diffservice/service.go | 2 +- contrib/snapshotservice/service.go | 2 +- diff/apply/apply_linux.go | 2 +- diff/lcow/lcow.go | 9 ++++---- diff/proxy/differ.go | 2 +- diff/walking/differ.go | 9 ++++---- diff/windows/windows.go | 11 +++++----- events.go | 2 +- events/exchange/exchange.go | 9 ++++---- events/exchange/exchange_test.go | 2 +- filters/parser.go | 2 +- identifiers/validate.go | 2 +- identifiers/validate_test.go | 2 +- image.go | 13 ++++++------ image_store.go | 2 +- images/archive/exporter.go | 9 ++++---- images/archive/importer.go | 2 +- images/converter/uncompress/uncompress.go | 2 +- images/handlers.go | 5 +++-- images/image.go | 5 +++-- images/mediatypes.go | 2 +- import.go | 9 ++++---- integration/client/client_test.go | 7 ++++--- integration/client/container_linux_test.go | 3 ++- integration/client/container_test.go | 2 +- integration/client/content_test.go | 2 +- integration/client/export_test.go | 9 ++++---- integration/client/go.mod | 2 +- integration/client/image_test.go | 7 ++++--- integration/client/lease_test.go | 2 +- integration/containerd_image_test.go | 2 +- labels/validate.go | 2 +- labels/validate_test.go | 2 +- leases/proxy/manager.go | 2 +- metadata/containers.go | 2 +- metadata/containers_test.go | 13 ++++++------ metadata/content.go | 11 +++++----- metadata/content_test.go | 2 +- metadata/db_test.go | 15 ++++++------- metadata/images.go | 2 +- metadata/images_test.go | 2 +- metadata/leases.go | 2 +- metadata/leases_test.go | 2 +- metadata/namespaces.go | 2 +- metadata/plugin/plugin.go | 5 +++-- metadata/sandbox.go | 2 +- metadata/sandbox_test.go | 2 +- metadata/snapshot.go | 7 ++++--- metadata/snapshot_test.go | 2 +- metrics/cgroups/v1/cgroups.go | 9 ++++---- namespaces.go | 2 +- namespaces/context.go | 2 +- oci/spec_opts_test.go | 2 +- pkg/cri/instrument/instrumented_service.go | 7 ++++--- pkg/cri/nri/nri_api_linux.go | 18 +++++++++------- pkg/cri/opts/container.go | 5 +++-- pkg/cri/opts/spec_nonwindows.go | 2 +- pkg/cri/sbserver/container_execsync.go | 9 ++++---- pkg/cri/sbserver/container_remove.go | 7 ++++--- pkg/cri/sbserver/container_start.go | 7 ++++--- pkg/cri/sbserver/container_stats_list.go | 9 ++++---- pkg/cri/sbserver/container_status.go | 2 +- pkg/cri/sbserver/container_stop.go | 10 ++++----- .../sbserver/container_update_resources.go | 5 ++--- pkg/cri/sbserver/events.go | 2 +- pkg/cri/sbserver/helpers.go | 4 ++-- pkg/cri/sbserver/helpers_test.go | 2 +- pkg/cri/sbserver/image_pull.go | 7 ++++--- pkg/cri/sbserver/image_remove.go | 2 +- pkg/cri/sbserver/image_status.go | 8 +++---- pkg/cri/sbserver/podsandbox/controller.go | 5 +++-- pkg/cri/sbserver/podsandbox/recover.go | 6 +++--- pkg/cri/sbserver/podsandbox/sandbox_delete.go | 5 +++-- pkg/cri/sbserver/podsandbox/sandbox_run.go | 5 +++-- pkg/cri/sbserver/podsandbox/sandbox_status.go | 2 +- pkg/cri/sbserver/podsandbox/sandbox_stop.go | 2 +- pkg/cri/sbserver/restart.go | 13 ++++++------ pkg/cri/sbserver/sandbox_portforward_other.go | 2 +- pkg/cri/sbserver/sandbox_remove.go | 3 ++- pkg/cri/sbserver/sandbox_stats_linux.go | 5 +++-- pkg/cri/sbserver/sandbox_stats_list.go | 5 +++-- pkg/cri/sbserver/sandbox_stats_other.go | 2 +- pkg/cri/sbserver/sandbox_stats_windows.go | 9 ++++---- pkg/cri/sbserver/sandbox_status.go | 5 +++-- pkg/cri/sbserver/sandbox_stop.go | 2 +- pkg/cri/sbserver/snapshots.go | 2 +- pkg/cri/server/bandwidth/fake_shaper.go | 2 +- pkg/cri/server/bandwidth/unsupported.go | 2 +- pkg/cri/server/container_execsync.go | 9 ++++---- pkg/cri/server/container_remove.go | 7 ++++--- pkg/cri/server/container_start.go | 7 ++++--- pkg/cri/server/container_stats_list_other.go | 2 +- pkg/cri/server/container_status.go | 2 +- pkg/cri/server/container_stop.go | 10 ++++----- pkg/cri/server/container_update_resources.go | 6 +++--- pkg/cri/server/events.go | 2 +- pkg/cri/server/helpers.go | 2 +- pkg/cri/server/helpers_test.go | 2 +- pkg/cri/server/image_pull.go | 7 ++++--- pkg/cri/server/image_remove.go | 2 +- pkg/cri/server/image_status.go | 8 +++---- pkg/cri/server/restart.go | 8 +++---- pkg/cri/server/sandbox_portforward_other.go | 2 +- pkg/cri/server/sandbox_remove.go | 5 +++-- pkg/cri/server/sandbox_run.go | 5 +++-- pkg/cri/server/sandbox_stats_linux.go | 5 +++-- pkg/cri/server/sandbox_stats_list.go | 5 +++-- pkg/cri/server/sandbox_stats_other.go | 2 +- pkg/cri/server/sandbox_stats_windows.go | 9 ++++---- pkg/cri/server/sandbox_status.go | 2 +- pkg/cri/server/sandbox_stop.go | 7 ++++--- pkg/cri/server/snapshots.go | 2 +- pkg/cri/store/container/container.go | 2 +- pkg/cri/store/container/container_test.go | 2 +- pkg/cri/store/image/image.go | 12 +++++------ pkg/cri/store/image/image_test.go | 2 +- pkg/cri/store/sandbox/sandbox.go | 2 +- pkg/cri/store/sandbox/sandbox_test.go | 2 +- pkg/cri/store/snapshot/snapshot.go | 2 +- pkg/cri/store/snapshot/snapshot_test.go | 2 +- pkg/nri/domain.go | 5 +++-- pkg/process/deleted_state.go | 2 +- pkg/process/exec.go | 2 +- pkg/process/utils.go | 2 +- pkg/transfer/image/imagestore.go | 4 ++-- pkg/transfer/image/imagestore_test.go | 2 +- pkg/transfer/local/import.go | 4 ++-- pkg/transfer/local/pull.go | 7 ++++--- pkg/transfer/local/push.go | 9 ++++---- pkg/transfer/local/transfer.go | 2 +- pkg/transfer/plugins/plugins.go | 2 +- pkg/unpack/unpacker.go | 17 ++++++++------- plugin/context.go | 2 +- plugins/sandbox/controller.go | 10 ++++----- plugins/streaming/manager.go | 2 +- plugins/transfer/plugin.go | 7 ++++--- process.go | 2 +- pull.go | 5 +++-- remotes/docker/authorizer.go | 5 +++-- remotes/docker/config/hosts.go | 5 +++-- remotes/docker/fetcher.go | 5 +++-- remotes/docker/httpreadseeker.go | 3 ++- remotes/docker/pusher.go | 9 ++++---- remotes/docker/pusher_test.go | 2 +- remotes/docker/resolver.go | 9 ++++---- remotes/docker/schema1/converter.go | 13 ++++++------ remotes/docker/status.go | 2 +- remotes/handlers.go | 9 ++++---- rootfs/apply.go | 9 ++++---- runtime/nsmap.go | 2 +- runtime/v1/linux/process.go | 2 +- runtime/v1/linux/runtime.go | 2 +- runtime/v1/linux/task.go | 7 ++++--- runtime/v1/shim/service.go | 2 +- runtime/v2/example/example.go | 2 +- runtime/v2/manager.go | 9 ++++---- runtime/v2/process.go | 2 +- runtime/v2/runc/container.go | 2 +- runtime/v2/runc/task/service.go | 2 +- runtime/v2/runc/v1/service.go | 2 +- runtime/v2/shim.go | 4 ++-- runtime/v2/shim/shim_windows.go | 2 +- runtime/v2/shim/util.go | 2 +- runtime/v2/shim_load.go | 5 +++-- runtime/v2/shim_test.go | 2 +- sandbox/proxy/controller.go | 7 ++++--- sandbox/proxy/store.go | 2 +- sandbox/store.go | 2 +- services/containers/local.go | 2 +- .../content/contentserver/contentserver.go | 11 +++++----- services/diff/local.go | 2 +- services/events/service.go | 2 +- services/events/ttrpc.go | 2 +- services/images/local.go | 5 +++-- services/introspection/introspection.go | 5 +++-- services/introspection/local.go | 3 +-- services/leases/service.go | 2 +- services/namespaces/local.go | 2 +- services/sandbox/controller_service.go | 5 +++-- services/sandbox/store_service.go | 5 +++-- services/server/config/config.go | 2 +- services/snapshots/service.go | 2 +- services/streaming/service.go | 9 ++++---- services/tasks/local.go | 4 ++-- services/transfer/service.go | 15 ++++++------- snapshots/devmapper/metadata.go | 2 +- snapshots/devmapper/snapshotter.go | 7 ++++--- snapshots/lcow/lcow.go | 9 ++++---- snapshots/proxy/proxy.go | 2 +- snapshots/storage/bolt.go | 2 +- snapshots/storage/metastore_test.go | 2 +- snapshots/testsuite/testsuite.go | 11 +++++----- snapshots/windows/windows.go | 11 +++++----- task.go | 2 +- task_opts.go | 2 +- tracing/plugin/otlp.go | 11 +++++----- transfer.go | 2 +- 226 files changed, 572 insertions(+), 484 deletions(-) diff --git a/client.go b/client.go index 13dc4da8c9ed..69614712ec67 100644 --- a/client.go +++ b/client.go @@ -27,6 +27,16 @@ import ( "sync" "time" + "github.com/containerd/platforms" + "github.com/containerd/typeurl/v2" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/opencontainers/runtime-spec/specs-go" + "golang.org/x/sync/semaphore" + "google.golang.org/grpc" + "google.golang.org/grpc/backoff" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/health/grpc_health_v1" + containersapi "github.com/containerd/containerd/api/services/containers/v1" contentapi "github.com/containerd/containerd/api/services/content/v1" diffapi "github.com/containerd/containerd/api/services/diff/v1" @@ -44,6 +54,7 @@ import ( "github.com/containerd/containerd/content" contentproxy "github.com/containerd/containerd/content/proxy" "github.com/containerd/containerd/defaults" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/images" "github.com/containerd/containerd/leases" @@ -59,16 +70,6 @@ import ( "github.com/containerd/containerd/services/introspection" "github.com/containerd/containerd/snapshots" snproxy "github.com/containerd/containerd/snapshots/proxy" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - "github.com/containerd/typeurl/v2" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/opencontainers/runtime-spec/specs-go" - "golang.org/x/sync/semaphore" - "google.golang.org/grpc" - "google.golang.org/grpc/backoff" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/health/grpc_health_v1" ) func init() { diff --git a/cmd/containerd/command/main.go b/cmd/containerd/command/main.go index 65d11e0d5fda..519e5849db44 100644 --- a/cmd/containerd/command/main.go +++ b/cmd/containerd/command/main.go @@ -27,17 +27,18 @@ import ( "runtime" "time" + "github.com/containerd/log" + "github.com/urfave/cli" + "google.golang.org/grpc/grpclog" + "github.com/containerd/containerd/defaults" + "github.com/containerd/containerd/errdefs" _ "github.com/containerd/containerd/metrics" // import containerd build info "github.com/containerd/containerd/mount" "github.com/containerd/containerd/services/server" srvconfig "github.com/containerd/containerd/services/server/config" "github.com/containerd/containerd/sys" "github.com/containerd/containerd/version" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/urfave/cli" - "google.golang.org/grpc/grpclog" ) const usage = ` diff --git a/cmd/containerd/command/publish.go b/cmd/containerd/command/publish.go index 70d4503fc3a0..269a8cc82af6 100644 --- a/cmd/containerd/command/publish.go +++ b/cmd/containerd/command/publish.go @@ -25,11 +25,11 @@ import ( "time" eventsapi "github.com/containerd/containerd/api/services/events/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/dialer" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/urfave/cli" "google.golang.org/grpc" "google.golang.org/grpc/backoff" diff --git a/cmd/containerd/command/service_windows.go b/cmd/containerd/command/service_windows.go index 768cab42d47f..08193a14a7a2 100644 --- a/cmd/containerd/command/service_windows.go +++ b/cmd/containerd/command/service_windows.go @@ -24,8 +24,8 @@ import ( "path/filepath" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/services/server" - "github.com/containerd/errdefs" "github.com/sirupsen/logrus" "github.com/urfave/cli" "golang.org/x/sys/windows" diff --git a/cmd/ctr/commands/containers/checkpoint.go b/cmd/ctr/commands/containers/checkpoint.go index 886baa545ee6..3d616c13773e 100644 --- a/cmd/ctr/commands/containers/checkpoint.go +++ b/cmd/ctr/commands/containers/checkpoint.go @@ -22,7 +22,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/containers/containers.go b/cmd/ctr/commands/containers/containers.go index 480be5bd6973..5ad88840dabe 100644 --- a/cmd/ctr/commands/containers/containers.go +++ b/cmd/ctr/commands/containers/containers.go @@ -28,7 +28,7 @@ import ( "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/cmd/ctr/commands/run" "github.com/containerd/containerd/containers" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/typeurl/v2" "github.com/urfave/cli" diff --git a/cmd/ctr/commands/containers/restore.go b/cmd/ctr/commands/containers/restore.go index 72e57fc42a48..d4bd5a4dac0c 100644 --- a/cmd/ctr/commands/containers/restore.go +++ b/cmd/ctr/commands/containers/restore.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/cio" "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/cmd/ctr/commands/tasks" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) diff --git a/cmd/ctr/commands/content/content.go b/cmd/ctr/commands/content/content.go index 6a726736c2dd..23f8f4427d01 100644 --- a/cmd/ctr/commands/content/content.go +++ b/cmd/ctr/commands/content/content.go @@ -27,15 +27,16 @@ import ( "text/tabwriter" "time" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" "github.com/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/urfave/cli" + + "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/remotes" ) var ( diff --git a/cmd/ctr/commands/content/fetch.go b/cmd/ctr/commands/content/fetch.go index 82bd847e75d6..2c09400c0f16 100644 --- a/cmd/ctr/commands/content/fetch.go +++ b/cmd/ctr/commands/content/fetch.go @@ -26,18 +26,19 @@ import ( "text/tabwriter" "time" + "github.com/containerd/log" + "github.com/containerd/platforms" + "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/urfave/cli" + "github.com/containerd/containerd" "github.com/containerd/containerd/cmd/ctr/commands" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/progress" "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" - "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/urfave/cli" ) var fetchCommand = cli.Command{ diff --git a/cmd/ctr/commands/images/images.go b/cmd/ctr/commands/images/images.go index 94136f0bd035..dc8925b7730e 100644 --- a/cmd/ctr/commands/images/images.go +++ b/cmd/ctr/commands/images/images.go @@ -24,13 +24,14 @@ import ( "strings" "text/tabwriter" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/images" - "github.com/containerd/containerd/pkg/progress" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" "github.com/urfave/cli" + + "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" + "github.com/containerd/containerd/pkg/progress" ) // Command is the cli command for managing images diff --git a/cmd/ctr/commands/images/mount.go b/cmd/ctr/commands/images/mount.go index 4a64cbed1f88..6d8edda6bf3a 100644 --- a/cmd/ctr/commands/images/mount.go +++ b/cmd/ctr/commands/images/mount.go @@ -20,14 +20,15 @@ import ( "fmt" "time" + "github.com/containerd/platforms" + "github.com/opencontainers/image-spec/identity" + "github.com/urfave/cli" + "github.com/containerd/containerd" "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/mount" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - "github.com/opencontainers/image-spec/identity" - "github.com/urfave/cli" ) var mountCommand = cli.Command{ diff --git a/cmd/ctr/commands/images/tag.go b/cmd/ctr/commands/images/tag.go index a938d54cfe24..40b42926c4ee 100644 --- a/cmd/ctr/commands/images/tag.go +++ b/cmd/ctr/commands/images/tag.go @@ -22,8 +22,8 @@ import ( "github.com/urfave/cli" "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/transfer/image" - "github.com/containerd/errdefs" ) var tagCommand = cli.Command{ diff --git a/cmd/ctr/commands/images/unmount.go b/cmd/ctr/commands/images/unmount.go index fa0687d0f17b..853b44cf2af5 100644 --- a/cmd/ctr/commands/images/unmount.go +++ b/cmd/ctr/commands/images/unmount.go @@ -19,11 +19,12 @@ package images import ( "fmt" + "github.com/urfave/cli" + "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/mount" - "github.com/containerd/errdefs" - "github.com/urfave/cli" ) var unmountCommand = cli.Command{ diff --git a/cmd/ctr/commands/namespaces/namespaces.go b/cmd/ctr/commands/namespaces/namespaces.go index 653ed9a031b9..d94b7cdefec9 100644 --- a/cmd/ctr/commands/namespaces/namespaces.go +++ b/cmd/ctr/commands/namespaces/namespaces.go @@ -24,10 +24,11 @@ import ( "strings" "text/tabwriter" - "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/urfave/cli" + + "github.com/containerd/containerd/cmd/ctr/commands" + "github.com/containerd/containerd/errdefs" ) // Command is the cli command for managing namespaces diff --git a/cmd/ctr/commands/signals.go b/cmd/ctr/commands/signals.go index dc66e9aeac2b..311608c26cb7 100644 --- a/cmd/ctr/commands/signals.go +++ b/cmd/ctr/commands/signals.go @@ -23,7 +23,7 @@ import ( "syscall" "github.com/containerd/containerd" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/sirupsen/logrus" ) diff --git a/container.go b/container.go index cad1037384af..7863b742bce6 100644 --- a/container.go +++ b/container.go @@ -29,11 +29,11 @@ import ( tasktypes "github.com/containerd/containerd/api/types/task" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/oci" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/fifo" "github.com/containerd/typeurl/v2" ver "github.com/opencontainers/image-spec/specs-go" diff --git a/container_opts.go b/container_opts.go index 0cbf6c20f2fe..4a937032f566 100644 --- a/container_opts.go +++ b/container_opts.go @@ -24,12 +24,12 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/oci" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/opencontainers/image-spec/identity" v1 "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/container_opts_unix.go b/container_opts_unix.go index e0e8bad88632..016c1a9258d9 100644 --- a/container_opts_unix.go +++ b/container_opts_unix.go @@ -26,8 +26,8 @@ import ( "syscall" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" - "github.com/containerd/errdefs" "github.com/opencontainers/image-spec/identity" ) diff --git a/containerstore.go b/containerstore.go index c0cca190732d..331a6f41de04 100644 --- a/containerstore.go +++ b/containerstore.go @@ -23,9 +23,9 @@ import ( containersapi "github.com/containerd/containerd/api/services/containers/v1" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/content/helpers.go b/content/helpers.go index f4763847d394..93bcdde106e4 100644 --- a/content/helpers.go +++ b/content/helpers.go @@ -24,11 +24,12 @@ import ( "sync" "time" - "github.com/containerd/containerd/pkg/randutil" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/pkg/randutil" ) var ErrReset = errors.New("writer has been reset") diff --git a/content/helpers_test.go b/content/helpers_test.go index b23d32d9dd4e..cb003c337bab 100644 --- a/content/helpers_test.go +++ b/content/helpers_test.go @@ -25,7 +25,7 @@ import ( "strings" "testing" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/opencontainers/go-digest" "github.com/stretchr/testify/assert" ) diff --git a/content/local/locks.go b/content/local/locks.go index 4caffcc02f46..1e59f39b30dd 100644 --- a/content/local/locks.go +++ b/content/local/locks.go @@ -21,7 +21,7 @@ import ( "sync" "time" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) // Handles locking references diff --git a/content/local/readerat.go b/content/local/readerat.go index 7918844b19bd..899e85c0ba87 100644 --- a/content/local/readerat.go +++ b/content/local/readerat.go @@ -22,7 +22,7 @@ import ( "os" "github.com/containerd/containerd/content" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) // readerat implements io.ReaderAt in a completely stateless manner by opening diff --git a/content/local/store.go b/content/local/store.go index feecec79fc7e..e1baee4c274c 100644 --- a/content/local/store.go +++ b/content/local/store.go @@ -27,12 +27,13 @@ import ( "sync" "time" + "github.com/containerd/log" + "github.com/sirupsen/logrus" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/pkg/randutil" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/sirupsen/logrus" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/content/local/store_test.go b/content/local/store_test.go index 1358f24b05c3..48ad54a0b706 100644 --- a/content/local/store_test.go +++ b/content/local/store_test.go @@ -34,9 +34,9 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/content/testsuite" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/randutil" "github.com/containerd/containerd/pkg/testutil" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/content/local/writer.go b/content/local/writer.go index f82b131e1672..0cd8f2d04bbd 100644 --- a/content/local/writer.go +++ b/content/local/writer.go @@ -26,10 +26,11 @@ import ( "runtime" "time" - "github.com/containerd/containerd/content" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/opencontainers/go-digest" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" ) // writer represents a write transaction against the blob store. diff --git a/content/proxy/content_store.go b/content/proxy/content_store.go index d666fa959e81..8e7fb42cf0a5 100644 --- a/content/proxy/content_store.go +++ b/content/proxy/content_store.go @@ -22,9 +22,9 @@ import ( contentapi "github.com/containerd/containerd/api/services/content/v1" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" protobuftypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/content/proxy/content_writer.go b/content/proxy/content_writer.go index 8d72f8e9dd54..185115b0a43e 100644 --- a/content/proxy/content_writer.go +++ b/content/proxy/content_writer.go @@ -23,8 +23,8 @@ import ( contentapi "github.com/containerd/containerd/api/services/content/v1" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" digest "github.com/opencontainers/go-digest" ) diff --git a/content/testsuite/testsuite.go b/content/testsuite/testsuite.go index baddeebdee4c..8a5cbbbc5ae5 100644 --- a/content/testsuite/testsuite.go +++ b/content/testsuite/testsuite.go @@ -28,13 +28,14 @@ import ( "testing" "time" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/pkg/testutil" - "github.com/containerd/errdefs" "github.com/containerd/log/logtest" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/stretchr/testify/assert" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/pkg/testutil" ) const ( diff --git a/contrib/diffservice/service.go b/contrib/diffservice/service.go index 878852023702..2d5329c62491 100644 --- a/contrib/diffservice/service.go +++ b/contrib/diffservice/service.go @@ -22,8 +22,8 @@ import ( diffapi "github.com/containerd/containerd/api/services/diff/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/contrib/snapshotservice/service.go b/contrib/snapshotservice/service.go index 41d4c9dddaae..a649d73dfec8 100644 --- a/contrib/snapshotservice/service.go +++ b/contrib/snapshotservice/service.go @@ -21,11 +21,11 @@ import ( snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" ) var empty = &ptypes.Empty{} diff --git a/diff/apply/apply_linux.go b/diff/apply/apply_linux.go index 99f3278de9f2..48b4f70fe035 100644 --- a/diff/apply/apply_linux.go +++ b/diff/apply/apply_linux.go @@ -27,8 +27,8 @@ import ( "golang.org/x/sys/unix" "github.com/containerd/containerd/archive" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" - "github.com/containerd/errdefs" ) func apply(ctx context.Context, mounts []mount.Mount, r io.Reader, sync bool) (retErr error) { diff --git a/diff/lcow/lcow.go b/diff/lcow/lcow.go index c60d4037c61b..05088ef6749a 100644 --- a/diff/lcow/lcow.go +++ b/diff/lcow/lcow.go @@ -30,15 +30,16 @@ import ( "github.com/Microsoft/go-winio/pkg/security" "github.com/Microsoft/hcsshim/ext4/tar2ext4" + "github.com/containerd/log" + digest "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" - "github.com/containerd/errdefs" - "github.com/containerd/log" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) const ( diff --git a/diff/proxy/differ.go b/diff/proxy/differ.go index 1b0056865cd7..1492dc67384a 100644 --- a/diff/proxy/differ.go +++ b/diff/proxy/differ.go @@ -22,11 +22,11 @@ import ( diffapi "github.com/containerd/containerd/api/services/diff/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/epoch" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/diff/walking/differ.go b/diff/walking/differ.go index 35da1533bd53..0127fc452b7a 100644 --- a/diff/walking/differ.go +++ b/diff/walking/differ.go @@ -25,17 +25,18 @@ import ( "io" "time" + "github.com/containerd/log" + digest "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/archive" "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/epoch" - "github.com/containerd/errdefs" - "github.com/containerd/log" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) type walkingDiff struct { diff --git a/diff/windows/windows.go b/diff/windows/windows.go index 8a327121c6b1..56b360f24a5e 100644 --- a/diff/windows/windows.go +++ b/diff/windows/windows.go @@ -28,20 +28,21 @@ import ( "time" "github.com/Microsoft/go-winio" + "github.com/containerd/log" + "github.com/containerd/platforms" + "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/archive" "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/epoch" "github.com/containerd/containerd/plugin" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" - "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func init() { diff --git a/events.go b/events.go index a1dabb5de785..eec9661fa44c 100644 --- a/events.go +++ b/events.go @@ -19,10 +19,10 @@ package containerd import ( "context" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" eventsapi "github.com/containerd/containerd/api/services/events/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/protobuf" ) diff --git a/events/exchange/exchange.go b/events/exchange/exchange.go index 38c41f39571a..b39044909529 100644 --- a/events/exchange/exchange.go +++ b/events/exchange/exchange.go @@ -22,14 +22,15 @@ import ( "strings" "time" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + goevents "github.com/docker/go-events" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - goevents "github.com/docker/go-events" ) // Exchange broadcasts events diff --git a/events/exchange/exchange_test.go b/events/exchange/exchange_test.go index 0a68b7a91f05..422586cf3083 100644 --- a/events/exchange/exchange_test.go +++ b/events/exchange/exchange_test.go @@ -23,10 +23,10 @@ import ( "time" eventstypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" ) diff --git a/filters/parser.go b/filters/parser.go index f07fd33bd2dd..32767909b1c9 100644 --- a/filters/parser.go +++ b/filters/parser.go @@ -20,7 +20,7 @@ import ( "fmt" "io" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) /* diff --git a/identifiers/validate.go b/identifiers/validate.go index 0acbf3fc4bb4..cbd3a52ba9e2 100644 --- a/identifiers/validate.go +++ b/identifiers/validate.go @@ -28,7 +28,7 @@ import ( "fmt" "regexp" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) const ( diff --git a/identifiers/validate_test.go b/identifiers/validate_test.go index 615e6ab7d2b0..77f926c0c389 100644 --- a/identifiers/validate_test.go +++ b/identifiers/validate_test.go @@ -20,7 +20,7 @@ import ( "strings" "testing" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) func TestValidIdentifiers(t *testing.T) { diff --git a/image.go b/image.go index 914ab35a7067..2497a3c14470 100644 --- a/image.go +++ b/image.go @@ -24,19 +24,20 @@ import ( "strings" "sync/atomic" + "github.com/containerd/platforms" + "github.com/opencontainers/go-digest" + "github.com/opencontainers/image-spec/identity" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "golang.org/x/sync/semaphore" + "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/pkg/kmutex" "github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - "github.com/opencontainers/go-digest" - "github.com/opencontainers/image-spec/identity" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "golang.org/x/sync/semaphore" ) // Image describes an image used by containers diff --git a/image_store.go b/image_store.go index 120d8d54dba8..524a7a6727a4 100644 --- a/image_store.go +++ b/image_store.go @@ -21,11 +21,11 @@ import ( imagesapi "github.com/containerd/containerd/api/services/images/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/epoch" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/protobuf/types/known/timestamppb" diff --git a/images/archive/exporter.go b/images/archive/exporter.go index 016c147f3958..3d53aca8e64f 100644 --- a/images/archive/exporter.go +++ b/images/archive/exporter.go @@ -26,15 +26,16 @@ import ( "sort" "strings" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/images" - "github.com/containerd/containerd/labels" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispecs "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" + "github.com/containerd/containerd/labels" ) type exportOptions struct { diff --git a/images/archive/importer.go b/images/archive/importer.go index fe6d451999b5..99712da7406f 100644 --- a/images/archive/importer.go +++ b/images/archive/importer.go @@ -29,9 +29,9 @@ import ( "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" diff --git a/images/converter/uncompress/uncompress.go b/images/converter/uncompress/uncompress.go index 7c1669ae90e3..ceb998fb8ff6 100644 --- a/images/converter/uncompress/uncompress.go +++ b/images/converter/uncompress/uncompress.go @@ -23,10 +23,10 @@ import ( "github.com/containerd/containerd/archive/compression" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/converter" "github.com/containerd/containerd/labels" - "github.com/containerd/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/images/handlers.go b/images/handlers.go index 7a34cc5440c3..a685092e2cb2 100644 --- a/images/handlers.go +++ b/images/handlers.go @@ -22,12 +22,13 @@ import ( "fmt" "sort" - "github.com/containerd/containerd/content" - "github.com/containerd/errdefs" "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/errgroup" "golang.org/x/sync/semaphore" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" ) var ( diff --git a/images/image.go b/images/image.go index a13710e7485d..b934e3496189 100644 --- a/images/image.go +++ b/images/image.go @@ -23,12 +23,13 @@ import ( "sort" "time" - "github.com/containerd/containerd/content" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" ) // Image provides the model for how containerd views container images. diff --git a/images/mediatypes.go b/images/mediatypes.go index cd51aa5ebbdf..d3b28d42dc61 100644 --- a/images/mediatypes.go +++ b/images/mediatypes.go @@ -22,7 +22,7 @@ import ( "sort" "strings" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/import.go b/import.go index 1472f489e14e..79c87fdd4c7e 100644 --- a/import.go +++ b/import.go @@ -21,13 +21,14 @@ import ( "encoding/json" "io" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/images" - "github.com/containerd/containerd/images/archive" - "github.com/containerd/errdefs" "github.com/containerd/platforms" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" + "github.com/containerd/containerd/images/archive" ) type importOpts struct { diff --git a/integration/client/client_test.go b/integration/client/client_test.go index 3d0e63c182b7..2c00fb0400f6 100644 --- a/integration/client/client_test.go +++ b/integration/client/client_test.go @@ -32,16 +32,17 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" + "github.com/containerd/log" + "github.com/containerd/platforms" + . "github.com/containerd/containerd" "github.com/containerd/containerd/defaults" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" imagelist "github.com/containerd/containerd/integration/images" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/testutil" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" ) var ( diff --git a/integration/client/container_linux_test.go b/integration/client/container_linux_test.go index db69456de805..98a63588c379 100644 --- a/integration/client/container_linux_test.go +++ b/integration/client/container_linux_test.go @@ -34,9 +34,11 @@ import ( "github.com/containerd/cgroups/v3" "github.com/containerd/cgroups/v3/cgroup1" cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2" + . "github.com/containerd/containerd" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/integration/failpoint" "github.com/containerd/containerd/oci" "github.com/containerd/containerd/pkg/fifosync" @@ -44,7 +46,6 @@ import ( "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/sys" - "github.com/containerd/errdefs" "github.com/opencontainers/runtime-spec/specs-go" "github.com/stretchr/testify/assert" diff --git a/integration/client/container_test.go b/integration/client/container_test.go index 4b5035acdf4e..3135cabcc87f 100644 --- a/integration/client/container_test.go +++ b/integration/client/container_test.go @@ -35,6 +35,7 @@ import ( apievents "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/cio" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/oci" @@ -43,7 +44,6 @@ import ( _ "github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/continuity/fs" - "github.com/containerd/errdefs" "github.com/containerd/go-runc" "github.com/containerd/log/logtest" "github.com/containerd/platforms" diff --git a/integration/client/content_test.go b/integration/client/content_test.go index 4c06afb67b89..ffcb1b810031 100644 --- a/integration/client/content_test.go +++ b/integration/client/content_test.go @@ -25,8 +25,8 @@ import ( . "github.com/containerd/containerd" "github.com/containerd/containerd/content" "github.com/containerd/containerd/content/testsuite" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" ) func newContentStore(ctx context.Context, root string) (context.Context, content.Store, func() error, error) { diff --git a/integration/client/export_test.go b/integration/client/export_test.go index 85f2020bad91..d926387c9987 100644 --- a/integration/client/export_test.go +++ b/integration/client/export_test.go @@ -25,15 +25,16 @@ import ( "strings" "testing" + "github.com/containerd/platforms" + "github.com/google/uuid" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + . "github.com/containerd/containerd" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/archive" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - "github.com/google/uuid" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func TestExportAllCases(t *testing.T) { diff --git a/integration/client/go.mod b/integration/client/go.mod index 691214ef6953..3e6fb6884331 100644 --- a/integration/client/go.mod +++ b/integration/client/go.mod @@ -10,7 +10,6 @@ require ( github.com/containerd/containerd v1.7.17 // see replace; the actual version of containerd is replaced with the code at the root of this repository github.com/containerd/containerd/api v1.7.19 github.com/containerd/continuity v0.4.2 - github.com/containerd/errdefs v0.1.0 github.com/containerd/go-runc v1.0.0 github.com/containerd/log v0.1.0 github.com/containerd/platforms v0.2.1 @@ -33,6 +32,7 @@ require ( github.com/cilium/ebpf v0.9.1 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/containerd/console v1.0.3 // indirect + github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/fifo v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/integration/client/image_test.go b/integration/client/image_test.go index 2411325fc8d7..d32a4bd132f6 100644 --- a/integration/client/image_test.go +++ b/integration/client/image_test.go @@ -23,13 +23,14 @@ import ( "strings" "testing" + "github.com/containerd/platforms" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + . "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" imagelist "github.com/containerd/containerd/integration/images" "github.com/containerd/containerd/labels" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func TestImageIsUnpacked(t *testing.T) { diff --git a/integration/client/lease_test.go b/integration/client/lease_test.go index 28e5e17aa4cf..455e128141e7 100644 --- a/integration/client/lease_test.go +++ b/integration/client/lease_test.go @@ -21,10 +21,10 @@ import ( "testing" . "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" imagelist "github.com/containerd/containerd/integration/images" "github.com/containerd/containerd/leases" - "github.com/containerd/errdefs" "github.com/opencontainers/image-spec/identity" ) diff --git a/integration/containerd_image_test.go b/integration/containerd_image_test.go index ee382eace12e..171ea493800a 100644 --- a/integration/containerd_image_test.go +++ b/integration/containerd_image_test.go @@ -26,10 +26,10 @@ import ( "time" "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/integration/images" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/cri/labels" - "github.com/containerd/errdefs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/labels/validate.go b/labels/validate.go index 6f23cdd7c65e..f83b5dde294d 100644 --- a/labels/validate.go +++ b/labels/validate.go @@ -19,7 +19,7 @@ package labels import ( "fmt" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) const ( diff --git a/labels/validate_test.go b/labels/validate_test.go index 16be11df3fcd..628f2fd7af50 100644 --- a/labels/validate_test.go +++ b/labels/validate_test.go @@ -20,7 +20,7 @@ import ( "strings" "testing" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/stretchr/testify/assert" ) diff --git a/leases/proxy/manager.go b/leases/proxy/manager.go index 342db9426799..ae42d8eb102c 100644 --- a/leases/proxy/manager.go +++ b/leases/proxy/manager.go @@ -20,9 +20,9 @@ import ( "context" leasesapi "github.com/containerd/containerd/api/services/leases/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" ) type proxyManager struct { diff --git a/metadata/containers.go b/metadata/containers.go index 8929ebf97fad..d97d9c6cd1ac 100644 --- a/metadata/containers.go +++ b/metadata/containers.go @@ -24,6 +24,7 @@ import ( "time" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/labels" @@ -31,7 +32,6 @@ import ( "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/containers_test.go b/metadata/containers_test.go index 5afa2d26f476..78c70ed88eaf 100644 --- a/metadata/containers_test.go +++ b/metadata/containers_test.go @@ -25,12 +25,6 @@ import ( "testing" "time" - "github.com/containerd/containerd/containers" - "github.com/containerd/containerd/filters" - "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/protobuf" - "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/containerd/log/logtest" "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" @@ -38,6 +32,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" bolt "go.etcd.io/bbolt" + + "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/filters" + "github.com/containerd/containerd/namespaces" + "github.com/containerd/containerd/protobuf" + "github.com/containerd/containerd/protobuf/types" ) func init() { diff --git a/metadata/content.go b/metadata/content.go index e3ccf3f85a13..059c306ccd6e 100644 --- a/metadata/content.go +++ b/metadata/content.go @@ -25,16 +25,17 @@ import ( "sync/atomic" "time" + "github.com/containerd/log" + digest "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + bolt "go.etcd.io/bbolt" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" - "github.com/containerd/log" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - bolt "go.etcd.io/bbolt" ) type contentStore struct { diff --git a/metadata/content_test.go b/metadata/content_test.go index a65ee824193d..8803150bc941 100644 --- a/metadata/content_test.go +++ b/metadata/content_test.go @@ -28,10 +28,10 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/content/local" "github.com/containerd/containerd/content/testsuite" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" bolt "go.etcd.io/bbolt" diff --git a/metadata/db_test.go b/metadata/db_test.go index 9149df0b2850..1256d4353390 100644 --- a/metadata/db_test.go +++ b/metadata/db_test.go @@ -29,9 +29,17 @@ import ( "testing" "time" + "github.com/containerd/log/logtest" + "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + bolt "go.etcd.io/bbolt" + "github.com/containerd/containerd/containers" "github.com/containerd/containerd/content" "github.com/containerd/containerd/content/local" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/gc" "github.com/containerd/containerd/images" "github.com/containerd/containerd/leases" @@ -39,13 +47,6 @@ import ( "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/native" - "github.com/containerd/errdefs" - "github.com/containerd/log/logtest" - "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - bolt "go.etcd.io/bbolt" ) type testOptions struct { diff --git a/metadata/images.go b/metadata/images.go index beba82d07bfd..ff5b624cce75 100644 --- a/metadata/images.go +++ b/metadata/images.go @@ -25,13 +25,13 @@ import ( "sync/atomic" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/epoch" - "github.com/containerd/errdefs" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" bolt "go.etcd.io/bbolt" diff --git a/metadata/images_test.go b/metadata/images_test.go index 5511fd9b5555..8d3ae878e2c6 100644 --- a/metadata/images_test.go +++ b/metadata/images_test.go @@ -23,9 +23,9 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/images" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/metadata/leases.go b/metadata/leases.go index 7c451e7469f6..03fa75af3465 100644 --- a/metadata/leases.go +++ b/metadata/leases.go @@ -24,11 +24,11 @@ import ( "sync/atomic" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" digest "github.com/opencontainers/go-digest" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/leases_test.go b/metadata/leases_test.go index 4cbb1ee6f6ed..56aa0d9f07ab 100644 --- a/metadata/leases_test.go +++ b/metadata/leases_test.go @@ -22,8 +22,8 @@ import ( "fmt" "testing" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/namespaces.go b/metadata/namespaces.go index 8b6174e35482..84eb83f2733e 100644 --- a/metadata/namespaces.go +++ b/metadata/namespaces.go @@ -21,10 +21,10 @@ import ( "fmt" "strings" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/identifiers" l "github.com/containerd/containerd/labels" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/plugin/plugin.go b/metadata/plugin/plugin.go index 4d7aaedd503c..ccfec5fa66b4 100644 --- a/metadata/plugin/plugin.go +++ b/metadata/plugin/plugin.go @@ -22,13 +22,14 @@ import ( "path/filepath" "time" + "github.com/containerd/log" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/pkg/timeout" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/log" bolt "go.etcd.io/bbolt" ) diff --git a/metadata/sandbox.go b/metadata/sandbox.go index 78126b4db9c4..5766647d33e3 100644 --- a/metadata/sandbox.go +++ b/metadata/sandbox.go @@ -23,12 +23,12 @@ import ( "strings" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/namespaces" api "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "go.etcd.io/bbolt" ) diff --git a/metadata/sandbox_test.go b/metadata/sandbox_test.go index 1b57c2f0ffad..711fb0c13abf 100644 --- a/metadata/sandbox_test.go +++ b/metadata/sandbox_test.go @@ -19,9 +19,9 @@ package metadata import ( "testing" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf/types" api "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/google/go-cmp/cmp" ) diff --git a/metadata/snapshot.go b/metadata/snapshot.go index 8388e19c4a90..a44a65cee35f 100644 --- a/metadata/snapshot.go +++ b/metadata/snapshot.go @@ -24,16 +24,17 @@ import ( "sync/atomic" "time" + "github.com/containerd/log" + bolt "go.etcd.io/bbolt" + eventstypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/log" - bolt "go.etcd.io/bbolt" ) const ( diff --git a/metadata/snapshot_test.go b/metadata/snapshot_test.go index 5716b6426af8..0be774800607 100644 --- a/metadata/snapshot_test.go +++ b/metadata/snapshot_test.go @@ -27,6 +27,7 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/mount" @@ -35,7 +36,6 @@ import ( "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/native" "github.com/containerd/containerd/snapshots/testsuite" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" ) diff --git a/metrics/cgroups/v1/cgroups.go b/metrics/cgroups/v1/cgroups.go index 425b9bc06aac..0382ba99fa01 100644 --- a/metrics/cgroups/v1/cgroups.go +++ b/metrics/cgroups/v1/cgroups.go @@ -22,15 +22,16 @@ import ( "context" cgroups "github.com/containerd/cgroups/v3/cgroup1" + "github.com/containerd/log" + "github.com/docker/go-metrics" + "github.com/sirupsen/logrus" + eventstypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime/v1/linux" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/docker/go-metrics" - "github.com/sirupsen/logrus" ) // NewTaskMonitor returns a new cgroups monitor diff --git a/namespaces.go b/namespaces.go index f4cc949d8481..83ee828dd0e3 100644 --- a/namespaces.go +++ b/namespaces.go @@ -21,9 +21,9 @@ import ( "strings" api "github.com/containerd/containerd/api/services/namespaces/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" ) // NewNamespaceStoreFromClient returns a new namespace store diff --git a/namespaces/context.go b/namespaces/context.go index 94ef9408d1d1..e5e23fe43014 100644 --- a/namespaces/context.go +++ b/namespaces/context.go @@ -21,8 +21,8 @@ import ( "fmt" "os" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/identifiers" - "github.com/containerd/errdefs" ) const ( diff --git a/oci/spec_opts_test.go b/oci/spec_opts_test.go index 939fcfd0ef3e..3839887a4ba5 100644 --- a/oci/spec_opts_test.go +++ b/oci/spec_opts_test.go @@ -38,8 +38,8 @@ import ( "github.com/containerd/containerd/containers" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" ) type blob []byte diff --git a/pkg/cri/instrument/instrumented_service.go b/pkg/cri/instrument/instrumented_service.go index 9a44757fa904..826837c3e32e 100644 --- a/pkg/cri/instrument/instrumented_service.go +++ b/pkg/cri/instrument/instrumented_service.go @@ -21,12 +21,13 @@ import ( "errors" "sync" + "github.com/containerd/log" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/services/warning" runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" - "github.com/containerd/log" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/pkg/deprecation" diff --git a/pkg/cri/nri/nri_api_linux.go b/pkg/cri/nri/nri_api_linux.go index 49b40a2bed3d..fdcadf3b04d2 100644 --- a/pkg/cri/nri/nri_api_linux.go +++ b/pkg/cri/nri/nri_api_linux.go @@ -21,25 +21,27 @@ import ( "encoding/json" "fmt" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + "github.com/opencontainers/runtime-spec/specs-go" + runtimespec "github.com/opencontainers/runtime-spec/specs-go" + "github.com/opencontainers/runtime-tools/generate" + cri "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/blockio" "github.com/containerd/containerd/pkg/cri/annotations" "github.com/containerd/containerd/pkg/cri/constants" cstore "github.com/containerd/containerd/pkg/cri/store/container" sstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - "github.com/opencontainers/runtime-spec/specs-go" - runtimespec "github.com/opencontainers/runtime-spec/specs-go" - "github.com/opencontainers/runtime-tools/generate" - cri "k8s.io/cri-api/pkg/apis/runtime/v1" - "github.com/containerd/containerd/pkg/nri" "github.com/containerd/nri/pkg/api" nrigen "github.com/containerd/nri/pkg/runtime-tools/generate" + + "github.com/containerd/containerd/pkg/nri" ) type API struct { diff --git a/pkg/cri/opts/container.go b/pkg/cri/opts/container.go index 21c97b7bd999..adc48b5e1c93 100644 --- a/pkg/cri/opts/container.go +++ b/pkg/cri/opts/container.go @@ -25,12 +25,13 @@ import ( "github.com/containerd/continuity/fs" + "github.com/containerd/log" + "github.com/containerd/containerd" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) // WithNewSnapshot wraps `containerd.WithNewSnapshot` so that if creating the diff --git a/pkg/cri/opts/spec_nonwindows.go b/pkg/cri/opts/spec_nonwindows.go index 00916612a688..4759711d3bd8 100644 --- a/pkg/cri/opts/spec_nonwindows.go +++ b/pkg/cri/opts/spec_nonwindows.go @@ -22,8 +22,8 @@ import ( "context" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/oci" - "github.com/containerd/errdefs" imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/sbserver/container_execsync.go b/pkg/cri/sbserver/container_execsync.go index a6ebddada3f3..f83d992e55b5 100644 --- a/pkg/cri/sbserver/container_execsync.go +++ b/pkg/cri/sbserver/container_execsync.go @@ -24,14 +24,15 @@ import ( "syscall" "time" - "github.com/containerd/containerd" - containerdio "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/oci" - "github.com/containerd/errdefs" "github.com/containerd/log" "k8s.io/client-go/tools/remotecommand" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/oci" + cio "github.com/containerd/containerd/pkg/cri/io" "github.com/containerd/containerd/pkg/cri/util" cioutil "github.com/containerd/containerd/pkg/ioutil" diff --git a/pkg/cri/sbserver/container_remove.go b/pkg/cri/sbserver/container_remove.go index fc52a4aa5f49..1ffcd08af93a 100644 --- a/pkg/cri/sbserver/container_remove.go +++ b/pkg/cri/sbserver/container_remove.go @@ -22,12 +22,13 @@ import ( "fmt" "time" - "github.com/containerd/containerd" - containerstore "github.com/containerd/containerd/pkg/cri/store/container" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" + containerstore "github.com/containerd/containerd/pkg/cri/store/container" ) // RemoveContainer removes the container. diff --git a/pkg/cri/sbserver/container_start.go b/pkg/cri/sbserver/container_start.go index 16a43f616e73..153141b17d78 100644 --- a/pkg/cri/sbserver/container_start.go +++ b/pkg/cri/sbserver/container_start.go @@ -23,13 +23,14 @@ import ( "io" "time" - "github.com/containerd/containerd" - containerdio "github.com/containerd/containerd/cio" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" + cio "github.com/containerd/containerd/pkg/cri/io" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" diff --git a/pkg/cri/sbserver/container_stats_list.go b/pkg/cri/sbserver/container_stats_list.go index 63382d1c9efe..b9342f660218 100644 --- a/pkg/cri/sbserver/container_stats_list.go +++ b/pkg/cri/sbserver/container_stats_list.go @@ -26,14 +26,15 @@ import ( wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" cg1 "github.com/containerd/cgroups/v3/cgroup1/stats" cg2 "github.com/containerd/cgroups/v3/cgroup2/stats" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/cri/store/stats" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" ) diff --git a/pkg/cri/sbserver/container_status.go b/pkg/cri/sbserver/container_status.go index aba04d04dc44..ac4f8489bb3a 100644 --- a/pkg/cri/sbserver/container_status.go +++ b/pkg/cri/sbserver/container_status.go @@ -21,8 +21,8 @@ import ( "encoding/json" "fmt" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" - "github.com/containerd/errdefs" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/sbserver/container_stop.go b/pkg/cri/sbserver/container_stop.go index c59a9f53c48a..8d91408ec2a4 100644 --- a/pkg/cri/sbserver/container_stop.go +++ b/pkg/cri/sbserver/container_stop.go @@ -23,15 +23,15 @@ import ( "syscall" "time" + "github.com/containerd/log" + "github.com/moby/sys/signal" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + eventtypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" - "github.com/containerd/log" - - "github.com/moby/sys/signal" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) // StopContainer stops a running container with a grace period (i.e., timeout). diff --git a/pkg/cri/sbserver/container_update_resources.go b/pkg/cri/sbserver/container_update_resources.go index ab3b67f9e704..3bedeebe4e24 100644 --- a/pkg/cri/sbserver/container_update_resources.go +++ b/pkg/cri/sbserver/container_update_resources.go @@ -23,15 +23,14 @@ import ( gocontext "context" "fmt" + "github.com/containerd/log" "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" "github.com/containerd/containerd" "github.com/containerd/containerd/containers" - "github.com/containerd/errdefs" - "github.com/containerd/log" - + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" ctrdutil "github.com/containerd/containerd/pkg/cri/util" ) diff --git a/pkg/cri/sbserver/events.go b/pkg/cri/sbserver/events.go index 9c34dd3a8927..996af5ee70d5 100644 --- a/pkg/cri/sbserver/events.go +++ b/pkg/cri/sbserver/events.go @@ -27,13 +27,13 @@ import ( eventtypes "github.com/containerd/containerd/api/events" apitasks "github.com/containerd/containerd/api/services/tasks/v1" containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/pkg/cri/constants" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/sbserver/helpers.go b/pkg/cri/sbserver/helpers.go index eef800f17b6c..402247072e45 100644 --- a/pkg/cri/sbserver/helpers.go +++ b/pkg/cri/sbserver/helpers.go @@ -28,11 +28,13 @@ import ( "time" "github.com/containerd/typeurl/v2" + docker "github.com/distribution/reference" runtimespec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" "github.com/containerd/containerd" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" clabels "github.com/containerd/containerd/labels" criconfig "github.com/containerd/containerd/pkg/cri/config" containerstore "github.com/containerd/containerd/pkg/cri/store/container" @@ -41,8 +43,6 @@ import ( "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" - docker "github.com/distribution/reference" runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options" imagedigest "github.com/opencontainers/go-digest" diff --git a/pkg/cri/sbserver/helpers_test.go b/pkg/cri/sbserver/helpers_test.go index ca7d8e8384db..008d80bde8c3 100644 --- a/pkg/cri/sbserver/helpers_test.go +++ b/pkg/cri/sbserver/helpers_test.go @@ -27,6 +27,7 @@ import ( runtime "k8s.io/cri-api/pkg/apis/runtime/v1" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/oci" criconfig "github.com/containerd/containerd/pkg/cri/config" containerstore "github.com/containerd/containerd/pkg/cri/store/container" @@ -35,7 +36,6 @@ import ( "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" docker "github.com/distribution/reference" diff --git a/pkg/cri/sbserver/image_pull.go b/pkg/cri/sbserver/image_pull.go index 2d40e5606d09..e8dead03f909 100644 --- a/pkg/cri/sbserver/image_pull.go +++ b/pkg/cri/sbserver/image_pull.go @@ -39,7 +39,11 @@ import ( imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/log" + distribution "github.com/distribution/reference" + "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" containerdimages "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/cri/annotations" criconfig "github.com/containerd/containerd/pkg/cri/config" @@ -48,9 +52,6 @@ import ( "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/config" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" - "github.com/containerd/log" - distribution "github.com/distribution/reference" ) // For image management: diff --git a/pkg/cri/sbserver/image_remove.go b/pkg/cri/sbserver/image_remove.go index 4ae93f999237..b43655c490d2 100644 --- a/pkg/cri/sbserver/image_remove.go +++ b/pkg/cri/sbserver/image_remove.go @@ -20,9 +20,9 @@ import ( "context" "fmt" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/sbserver/image_status.go b/pkg/cri/sbserver/image_status.go index 8ca2546e5055..86ed23a15e6d 100644 --- a/pkg/cri/sbserver/image_status.go +++ b/pkg/cri/sbserver/image_status.go @@ -21,13 +21,13 @@ import ( "encoding/json" "fmt" - imagestore "github.com/containerd/containerd/pkg/cri/store/image" - "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" "github.com/containerd/log" - imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + imagestore "github.com/containerd/containerd/pkg/cri/store/image" + "github.com/containerd/containerd/tracing" ) // ImageStatus returns the status of the image, returns nil if the image isn't present. diff --git a/pkg/cri/sbserver/podsandbox/controller.go b/pkg/cri/sbserver/podsandbox/controller.go index 7dcebf361249..3320375a2d93 100644 --- a/pkg/cri/sbserver/podsandbox/controller.go +++ b/pkg/cri/sbserver/podsandbox/controller.go @@ -25,8 +25,11 @@ import ( "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/platforms" + "github.com/containerd/containerd" eventtypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/oci" criconfig "github.com/containerd/containerd/pkg/cri/config" imagestore "github.com/containerd/containerd/pkg/cri/store/image" @@ -35,8 +38,6 @@ import ( osinterface "github.com/containerd/containerd/pkg/os" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" ) // CRIService interface contains things required by controller, but not yet refactored from criService. diff --git a/pkg/cri/sbserver/podsandbox/recover.go b/pkg/cri/sbserver/podsandbox/recover.go index 21c69d7cc288..291d982d98d1 100644 --- a/pkg/cri/sbserver/podsandbox/recover.go +++ b/pkg/cri/sbserver/podsandbox/recover.go @@ -22,15 +22,15 @@ import ( goruntime "runtime" "time" - "github.com/containerd/containerd/pkg/netns" + "github.com/containerd/log" "github.com/containerd/typeurl/v2" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" - "github.com/containerd/errdefs" - "github.com/containerd/log" + "github.com/containerd/containerd/pkg/netns" ) // loadContainerTimeout is the default timeout for loading a container/sandbox. diff --git a/pkg/cri/sbserver/podsandbox/sandbox_delete.go b/pkg/cri/sbserver/podsandbox/sandbox_delete.go index ba2387301423..a490fb21a76b 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_delete.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_delete.go @@ -20,10 +20,11 @@ import ( "context" "fmt" + "github.com/containerd/log" + "github.com/containerd/containerd" apitasks "github.com/containerd/containerd/api/services/tasks/v1" - "github.com/containerd/errdefs" - "github.com/containerd/log" + "github.com/containerd/containerd/errdefs" ) func (c *Controller) Shutdown(ctx context.Context, sandboxID string) error { diff --git a/pkg/cri/sbserver/podsandbox/sandbox_run.go b/pkg/cri/sbserver/podsandbox/sandbox_run.go index 3d010814e9b0..352b638bdd8f 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_run.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_run.go @@ -29,8 +29,11 @@ import ( "github.com/opencontainers/selinux/go-selinux" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/log" + "github.com/containerd/containerd" containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/cri/annotations" criconfig "github.com/containerd/containerd/pkg/cri/config" customopts "github.com/containerd/containerd/pkg/cri/opts" @@ -38,8 +41,6 @@ import ( ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/sandbox" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func init() { diff --git a/pkg/cri/sbserver/podsandbox/sandbox_status.go b/pkg/cri/sbserver/podsandbox/sandbox_status.go index e0e018bef77d..dceb657a1303 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_status.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_status.go @@ -23,9 +23,9 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/go-cni" "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/sbserver/podsandbox/sandbox_stop.go b/pkg/cri/sbserver/podsandbox/sandbox_stop.go index 8fa146d68748..51d4eb228952 100644 --- a/pkg/cri/sbserver/podsandbox/sandbox_stop.go +++ b/pkg/cri/sbserver/podsandbox/sandbox_stop.go @@ -25,11 +25,11 @@ import ( "github.com/sirupsen/logrus" eventtypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" ) func (c *Controller) Stop(ctx context.Context, sandboxID string, _ ...sandbox.StopOpt) error { diff --git a/pkg/cri/sbserver/restart.go b/pkg/cri/sbserver/restart.go index 502a2cecee33..f984e56779ca 100644 --- a/pkg/cri/sbserver/restart.go +++ b/pkg/cri/sbserver/restart.go @@ -24,18 +24,19 @@ import ( "sync" "time" + "github.com/containerd/log" + "github.com/containerd/platforms" + "github.com/containerd/typeurl/v2" + "golang.org/x/sync/errgroup" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" containerdimages "github.com/containerd/containerd/images" criconfig "github.com/containerd/containerd/pkg/cri/config" "github.com/containerd/containerd/pkg/cri/sbserver/podsandbox" "github.com/containerd/containerd/pkg/netns" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" - "github.com/containerd/typeurl/v2" - "golang.org/x/sync/errgroup" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" cio "github.com/containerd/containerd/pkg/cri/io" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/sbserver/sandbox_portforward_other.go b/pkg/cri/sbserver/sandbox_portforward_other.go index 211c3586672c..cadbae0c8a49 100644 --- a/pkg/cri/sbserver/sandbox_portforward_other.go +++ b/pkg/cri/sbserver/sandbox_portforward_other.go @@ -23,7 +23,7 @@ import ( "fmt" "io" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) // portForward uses netns to enter the sandbox namespace, and forwards a stream inside the diff --git a/pkg/cri/sbserver/sandbox_remove.go b/pkg/cri/sbserver/sandbox_remove.go index b79ec6649b2c..9de19552a361 100644 --- a/pkg/cri/sbserver/sandbox_remove.go +++ b/pkg/cri/sbserver/sandbox_remove.go @@ -21,9 +21,10 @@ import ( "fmt" "time" - "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/containerd/errdefs" + "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/sbserver/sandbox_stats_linux.go b/pkg/cri/sbserver/sandbox_stats_linux.go index 3b0bde5d8678..282c563d0f88 100644 --- a/pkg/cri/sbserver/sandbox_stats_linux.go +++ b/pkg/cri/sbserver/sandbox_stats_linux.go @@ -24,12 +24,13 @@ import ( "github.com/containerd/cgroups/v3" "github.com/containerd/cgroups/v3/cgroup1" cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2" - sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containernetworking/plugins/pkg/ns" "github.com/vishvananda/netlink" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) func (c *criService) podSandboxStats( diff --git a/pkg/cri/sbserver/sandbox_stats_list.go b/pkg/cri/sbserver/sandbox_stats_list.go index e548537016b6..862506fd7113 100644 --- a/pkg/cri/sbserver/sandbox_stats_list.go +++ b/pkg/cri/sbserver/sandbox_stats_list.go @@ -20,11 +20,12 @@ import ( "context" "fmt" - sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/hashicorp/go-multierror" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) // ListPodSandboxStats returns stats of all ready sandboxes. diff --git a/pkg/cri/sbserver/sandbox_stats_other.go b/pkg/cri/sbserver/sandbox_stats_other.go index 3b45b8e1598a..8a249a485708 100644 --- a/pkg/cri/sbserver/sandbox_stats_other.go +++ b/pkg/cri/sbserver/sandbox_stats_other.go @@ -22,8 +22,8 @@ import ( "context" "fmt" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/sbserver/sandbox_stats_windows.go b/pkg/cri/sbserver/sandbox_stats_windows.go index 951301aac852..4ed0332fb6d2 100644 --- a/pkg/cri/sbserver/sandbox_stats_windows.go +++ b/pkg/cri/sbserver/sandbox_stats_windows.go @@ -24,15 +24,16 @@ import ( "github.com/Microsoft/hcsshim" wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" "github.com/Microsoft/hcsshim/hcn" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/pkg/cri/store/stats" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) func (c *criService) podSandboxStats( diff --git a/pkg/cri/sbserver/sandbox_status.go b/pkg/cri/sbserver/sandbox_status.go index 10250096c11a..0b84b43e728a 100644 --- a/pkg/cri/sbserver/sandbox_status.go +++ b/pkg/cri/sbserver/sandbox_status.go @@ -21,9 +21,10 @@ import ( "fmt" "time" - sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) // PodSandboxStatus returns the status of the PodSandbox. diff --git a/pkg/cri/sbserver/sandbox_stop.go b/pkg/cri/sbserver/sandbox_stop.go index 930eb31652a9..7cf826138244 100644 --- a/pkg/cri/sbserver/sandbox_stop.go +++ b/pkg/cri/sbserver/sandbox_stop.go @@ -22,10 +22,10 @@ import ( "fmt" "time" - "github.com/containerd/errdefs" "github.com/containerd/log" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) diff --git a/pkg/cri/sbserver/snapshots.go b/pkg/cri/sbserver/snapshots.go index 1f0dbfcaf39c..e8cb943da8c8 100644 --- a/pkg/cri/sbserver/snapshots.go +++ b/pkg/cri/sbserver/snapshots.go @@ -21,8 +21,8 @@ import ( "fmt" "time" + "github.com/containerd/containerd/errdefs" snapshot "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/sirupsen/logrus" snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot" diff --git a/pkg/cri/server/bandwidth/fake_shaper.go b/pkg/cri/server/bandwidth/fake_shaper.go index 58e4e1ab47e4..99bfd338a75d 100644 --- a/pkg/cri/server/bandwidth/fake_shaper.go +++ b/pkg/cri/server/bandwidth/fake_shaper.go @@ -33,7 +33,7 @@ limitations under the License. package bandwidth import ( - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "k8s.io/apimachinery/pkg/api/resource" ) diff --git a/pkg/cri/server/bandwidth/unsupported.go b/pkg/cri/server/bandwidth/unsupported.go index 29e9765f628e..26bda16ef449 100644 --- a/pkg/cri/server/bandwidth/unsupported.go +++ b/pkg/cri/server/bandwidth/unsupported.go @@ -35,7 +35,7 @@ limitations under the License. package bandwidth import ( - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "k8s.io/apimachinery/pkg/api/resource" ) diff --git a/pkg/cri/server/container_execsync.go b/pkg/cri/server/container_execsync.go index 7688165718f1..4f0b3284892f 100644 --- a/pkg/cri/server/container_execsync.go +++ b/pkg/cri/server/container_execsync.go @@ -24,14 +24,15 @@ import ( "syscall" "time" - "github.com/containerd/containerd" - containerdio "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/oci" - "github.com/containerd/errdefs" "github.com/containerd/log" "k8s.io/client-go/tools/remotecommand" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/oci" + cio "github.com/containerd/containerd/pkg/cri/io" "github.com/containerd/containerd/pkg/cri/util" cioutil "github.com/containerd/containerd/pkg/ioutil" diff --git a/pkg/cri/server/container_remove.go b/pkg/cri/server/container_remove.go index bd83bd07e39d..5fa8328de7cb 100644 --- a/pkg/cri/server/container_remove.go +++ b/pkg/cri/server/container_remove.go @@ -22,12 +22,13 @@ import ( "fmt" "time" - "github.com/containerd/containerd" - containerstore "github.com/containerd/containerd/pkg/cri/store/container" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" + containerstore "github.com/containerd/containerd/pkg/cri/store/container" ) // RemoveContainer removes the container. diff --git a/pkg/cri/server/container_start.go b/pkg/cri/server/container_start.go index ff821589dc14..1c04dc4559fb 100644 --- a/pkg/cri/server/container_start.go +++ b/pkg/cri/server/container_start.go @@ -23,13 +23,14 @@ import ( "io" "time" - "github.com/containerd/containerd" - containerdio "github.com/containerd/containerd/cio" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" + cio "github.com/containerd/containerd/pkg/cri/io" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" diff --git a/pkg/cri/server/container_stats_list_other.go b/pkg/cri/server/container_stats_list_other.go index a9d6729007c1..7f1fe2e3c870 100644 --- a/pkg/cri/server/container_stats_list_other.go +++ b/pkg/cri/server/container_stats_list_other.go @@ -22,7 +22,7 @@ import ( "fmt" "github.com/containerd/containerd/api/types" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" containerstore "github.com/containerd/containerd/pkg/cri/store/container" diff --git a/pkg/cri/server/container_status.go b/pkg/cri/server/container_status.go index 517f82a86f14..ed3ba2929203 100644 --- a/pkg/cri/server/container_status.go +++ b/pkg/cri/server/container_status.go @@ -21,8 +21,8 @@ import ( "encoding/json" "fmt" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" - "github.com/containerd/errdefs" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/container_stop.go b/pkg/cri/server/container_stop.go index 72a1b63779eb..e4091d808a73 100644 --- a/pkg/cri/server/container_stop.go +++ b/pkg/cri/server/container_stop.go @@ -23,15 +23,15 @@ import ( "syscall" "time" + "github.com/containerd/log" + "github.com/moby/sys/signal" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + eventtypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" - "github.com/containerd/log" - - "github.com/moby/sys/signal" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) // StopContainer stops a running container with a grace period (i.e., timeout). diff --git a/pkg/cri/server/container_update_resources.go b/pkg/cri/server/container_update_resources.go index e4f1e00989b8..e875d7236f02 100644 --- a/pkg/cri/server/container_update_resources.go +++ b/pkg/cri/server/container_update_resources.go @@ -23,14 +23,14 @@ import ( gocontext "context" "fmt" - "github.com/containerd/containerd" - "github.com/containerd/containerd/containers" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/typeurl/v2" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" ctrdutil "github.com/containerd/containerd/pkg/cri/util" ) diff --git a/pkg/cri/server/events.go b/pkg/cri/server/events.go index 5699a1e19b59..f7f7d7234e43 100644 --- a/pkg/cri/server/events.go +++ b/pkg/cri/server/events.go @@ -27,13 +27,13 @@ import ( eventtypes "github.com/containerd/containerd/api/events" apitasks "github.com/containerd/containerd/api/services/tasks/v1" containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/pkg/cri/constants" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go index 7bdb4aff025f..8e8c33a91a30 100644 --- a/pkg/cri/server/helpers.go +++ b/pkg/cri/server/helpers.go @@ -28,6 +28,7 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" clabels "github.com/containerd/containerd/labels" criconfig "github.com/containerd/containerd/pkg/cri/config" containerstore "github.com/containerd/containerd/pkg/cri/store/container" @@ -37,7 +38,6 @@ import ( "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" docker "github.com/distribution/reference" runtimespec "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/cri/server/helpers_test.go b/pkg/cri/server/helpers_test.go index a411e67b1398..64931cb5f11e 100644 --- a/pkg/cri/server/helpers_test.go +++ b/pkg/cri/server/helpers_test.go @@ -25,6 +25,7 @@ import ( "time" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/oci" criconfig "github.com/containerd/containerd/pkg/cri/config" containerstore "github.com/containerd/containerd/pkg/cri/store/container" @@ -33,7 +34,6 @@ import ( "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/linux/runctypes" runcoptions "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" docker "github.com/distribution/reference" diff --git a/pkg/cri/server/image_pull.go b/pkg/cri/server/image_pull.go index 679f03abb65d..6b321515bd70 100644 --- a/pkg/cri/server/image_pull.go +++ b/pkg/cri/server/image_pull.go @@ -39,8 +39,12 @@ import ( imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/log" + distribution "github.com/distribution/reference" + "github.com/containerd/containerd" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" containerdimages "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/cri/annotations" criconfig "github.com/containerd/containerd/pkg/cri/config" @@ -49,9 +53,6 @@ import ( "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/config" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" - "github.com/containerd/log" - distribution "github.com/distribution/reference" ) // For image management: diff --git a/pkg/cri/server/image_remove.go b/pkg/cri/server/image_remove.go index 011d86c5c135..e10062a31834 100644 --- a/pkg/cri/server/image_remove.go +++ b/pkg/cri/server/image_remove.go @@ -20,9 +20,9 @@ import ( "context" "fmt" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/server/image_status.go b/pkg/cri/server/image_status.go index c55bc52ada7e..31520233f874 100644 --- a/pkg/cri/server/image_status.go +++ b/pkg/cri/server/image_status.go @@ -21,13 +21,13 @@ import ( "encoding/json" "fmt" - imagestore "github.com/containerd/containerd/pkg/cri/store/image" - "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" "github.com/containerd/log" - imagespec "github.com/opencontainers/image-spec/specs-go/v1" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + imagestore "github.com/containerd/containerd/pkg/cri/store/image" + "github.com/containerd/containerd/tracing" ) // ImageStatus returns the status of the image, returns nil if the image isn't present. diff --git a/pkg/cri/server/restart.go b/pkg/cri/server/restart.go index 9af38fa7fa66..76471471beb0 100644 --- a/pkg/cri/server/restart.go +++ b/pkg/cri/server/restart.go @@ -24,16 +24,16 @@ import ( "sync" "time" - "github.com/containerd/containerd" - containerdio "github.com/containerd/containerd/cio" - containerdimages "github.com/containerd/containerd/images" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" "golang.org/x/sync/errgroup" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd" + containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" + containerdimages "github.com/containerd/containerd/images" cio "github.com/containerd/containerd/pkg/cri/io" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" diff --git a/pkg/cri/server/sandbox_portforward_other.go b/pkg/cri/server/sandbox_portforward_other.go index 2c7fbc1b56c8..9ba3fe16286d 100644 --- a/pkg/cri/server/sandbox_portforward_other.go +++ b/pkg/cri/server/sandbox_portforward_other.go @@ -23,7 +23,7 @@ import ( "fmt" "io" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" ) // portForward uses netns to enter the sandbox namespace, and forwards a stream inside the diff --git a/pkg/cri/server/sandbox_remove.go b/pkg/cri/server/sandbox_remove.go index 430181bfd6c4..d796c560c982 100644 --- a/pkg/cri/server/sandbox_remove.go +++ b/pkg/cri/server/sandbox_remove.go @@ -21,10 +21,11 @@ import ( "fmt" "time" - "github.com/containerd/containerd" - "github.com/containerd/errdefs" "github.com/containerd/log" + "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" + "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/server/sandbox_run.go b/pkg/cri/server/sandbox_run.go index 9c52f51a9a29..c68cb6fd797f 100644 --- a/pkg/cri/server/sandbox_run.go +++ b/pkg/cri/server/sandbox_run.go @@ -34,8 +34,11 @@ import ( "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/log" + "github.com/containerd/containerd" containerdio "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/cri/annotations" criconfig "github.com/containerd/containerd/pkg/cri/config" customopts "github.com/containerd/containerd/pkg/cri/opts" @@ -44,8 +47,6 @@ import ( "github.com/containerd/containerd/pkg/cri/util" "github.com/containerd/containerd/pkg/netns" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func init() { diff --git a/pkg/cri/server/sandbox_stats_linux.go b/pkg/cri/server/sandbox_stats_linux.go index 1cc6f01baf8d..173b251cfd8f 100644 --- a/pkg/cri/server/sandbox_stats_linux.go +++ b/pkg/cri/server/sandbox_stats_linux.go @@ -24,12 +24,13 @@ import ( "github.com/containerd/cgroups/v3" "github.com/containerd/cgroups/v3/cgroup1" cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2" - sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containernetworking/plugins/pkg/ns" "github.com/vishvananda/netlink" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + + "github.com/containerd/containerd/errdefs" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ) func (c *criService) podSandboxStats( diff --git a/pkg/cri/server/sandbox_stats_list.go b/pkg/cri/server/sandbox_stats_list.go index 4e070bddc279..4d53e57715c3 100644 --- a/pkg/cri/server/sandbox_stats_list.go +++ b/pkg/cri/server/sandbox_stats_list.go @@ -21,12 +21,13 @@ import ( "errors" "fmt" - sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/ttrpc" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/errdefs" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" + "github.com/hashicorp/go-multierror" ) diff --git a/pkg/cri/server/sandbox_stats_other.go b/pkg/cri/server/sandbox_stats_other.go index 883e922e36e2..3ecdaa4bf47f 100644 --- a/pkg/cri/server/sandbox_stats_other.go +++ b/pkg/cri/server/sandbox_stats_other.go @@ -22,8 +22,8 @@ import ( "context" "fmt" + "github.com/containerd/containerd/errdefs" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/server/sandbox_stats_windows.go b/pkg/cri/server/sandbox_stats_windows.go index 571834ecc569..3803d9d29641 100644 --- a/pkg/cri/server/sandbox_stats_windows.go +++ b/pkg/cri/server/sandbox_stats_windows.go @@ -24,15 +24,16 @@ import ( "github.com/Microsoft/hcsshim" wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats" "github.com/Microsoft/hcsshim/hcn" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" containerstore "github.com/containerd/containerd/pkg/cri/store/container" sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" "github.com/containerd/containerd/pkg/cri/store/stats" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) func (c *criService) podSandboxStats( diff --git a/pkg/cri/server/sandbox_status.go b/pkg/cri/server/sandbox_status.go index eed7eb4c509d..06091cca2254 100644 --- a/pkg/cri/server/sandbox_status.go +++ b/pkg/cri/server/sandbox_status.go @@ -22,7 +22,7 @@ import ( "fmt" "github.com/containerd/containerd" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" cni "github.com/containerd/go-cni" runtimespec "github.com/opencontainers/runtime-spec/specs-go" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/server/sandbox_stop.go b/pkg/cri/server/sandbox_stop.go index 893ce90c5f5b..1d73aa8a0b75 100644 --- a/pkg/cri/server/sandbox_stop.go +++ b/pkg/cri/server/sandbox_stop.go @@ -23,12 +23,13 @@ import ( "syscall" "time" - eventtypes "github.com/containerd/containerd/api/events" - "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" "github.com/containerd/log" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + eventtypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/protobuf" + sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox" ctrdutil "github.com/containerd/containerd/pkg/cri/util" ) diff --git a/pkg/cri/server/snapshots.go b/pkg/cri/server/snapshots.go index 7c2159bf5d50..ed672752ff88 100644 --- a/pkg/cri/server/snapshots.go +++ b/pkg/cri/server/snapshots.go @@ -21,8 +21,8 @@ import ( "fmt" "time" + "github.com/containerd/containerd/errdefs" snapshot "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/sirupsen/logrus" snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot" diff --git a/pkg/cri/store/container/container.go b/pkg/cri/store/container/container.go index 727357842111..524b58291612 100644 --- a/pkg/cri/store/container/container.go +++ b/pkg/cri/store/container/container.go @@ -20,12 +20,12 @@ import ( "sync" "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" cio "github.com/containerd/containerd/pkg/cri/io" "github.com/containerd/containerd/pkg/cri/store" "github.com/containerd/containerd/pkg/cri/store/label" "github.com/containerd/containerd/pkg/cri/store/stats" "github.com/containerd/containerd/pkg/truncindex" - "github.com/containerd/errdefs" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" ) diff --git a/pkg/cri/store/container/container_test.go b/pkg/cri/store/container/container_test.go index d90728e6f030..6f7bd69b6b62 100644 --- a/pkg/cri/store/container/container_test.go +++ b/pkg/cri/store/container/container_test.go @@ -21,10 +21,10 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" cio "github.com/containerd/containerd/pkg/cri/io" "github.com/containerd/containerd/pkg/cri/store/label" "github.com/containerd/containerd/pkg/cri/store/stats" - "github.com/containerd/errdefs" "github.com/opencontainers/selinux/go-selinux" assertlib "github.com/stretchr/testify/assert" diff --git a/pkg/cri/store/image/image.go b/pkg/cri/store/image/image.go index 89761c62a929..118a4784774d 100644 --- a/pkg/cri/store/image/image.go +++ b/pkg/cri/store/image/image.go @@ -21,17 +21,17 @@ import ( "fmt" "sync" - "github.com/containerd/containerd" - "github.com/containerd/containerd/pkg/cri/labels" - "github.com/containerd/containerd/pkg/cri/util" - "github.com/containerd/errdefs" docker "github.com/distribution/reference" - "k8s.io/apimachinery/pkg/util/sets" - imagedigest "github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest/digestset" imageidentity "github.com/opencontainers/image-spec/identity" imagespec "github.com/opencontainers/image-spec/specs-go/v1" + "k8s.io/apimachinery/pkg/util/sets" + + "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/pkg/cri/labels" + "github.com/containerd/containerd/pkg/cri/util" ) // Image contains all resources associated with the image. All fields diff --git a/pkg/cri/store/image/image_test.go b/pkg/cri/store/image/image_test.go index 5376cb6176f7..988f854faef9 100644 --- a/pkg/cri/store/image/image_test.go +++ b/pkg/cri/store/image/image_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "k8s.io/apimachinery/pkg/util/sets" "github.com/opencontainers/go-digest/digestset" diff --git a/pkg/cri/store/sandbox/sandbox.go b/pkg/cri/store/sandbox/sandbox.go index 867f1f87ff52..26dd8f6dba34 100644 --- a/pkg/cri/store/sandbox/sandbox.go +++ b/pkg/cri/store/sandbox/sandbox.go @@ -20,12 +20,12 @@ import ( "sync" "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/cri/store" "github.com/containerd/containerd/pkg/cri/store/label" "github.com/containerd/containerd/pkg/cri/store/stats" "github.com/containerd/containerd/pkg/netns" "github.com/containerd/containerd/pkg/truncindex" - "github.com/containerd/errdefs" ) // Sandbox contains all resources associated with the sandbox. All methods to diff --git a/pkg/cri/store/sandbox/sandbox_test.go b/pkg/cri/store/sandbox/sandbox_test.go index 5b2887b9252e..68ff056eaa20 100644 --- a/pkg/cri/store/sandbox/sandbox_test.go +++ b/pkg/cri/store/sandbox/sandbox_test.go @@ -20,9 +20,9 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/cri/store/label" "github.com/containerd/containerd/pkg/cri/store/stats" - "github.com/containerd/errdefs" assertlib "github.com/stretchr/testify/assert" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" diff --git a/pkg/cri/store/snapshot/snapshot.go b/pkg/cri/store/snapshot/snapshot.go index 598e329fa039..47b1f7e2b002 100644 --- a/pkg/cri/store/snapshot/snapshot.go +++ b/pkg/cri/store/snapshot/snapshot.go @@ -19,8 +19,8 @@ package snapshot import ( "sync" + "github.com/containerd/containerd/errdefs" snapshot "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" ) // Snapshot contains the information about the snapshot. diff --git a/pkg/cri/store/snapshot/snapshot_test.go b/pkg/cri/store/snapshot/snapshot_test.go index 936547b1898c..5c62976c96ec 100644 --- a/pkg/cri/store/snapshot/snapshot_test.go +++ b/pkg/cri/store/snapshot/snapshot_test.go @@ -20,8 +20,8 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" snapshot "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" assertlib "github.com/stretchr/testify/assert" ) diff --git a/pkg/nri/domain.go b/pkg/nri/domain.go index ad4606c8a742..be4436e87f73 100644 --- a/pkg/nri/domain.go +++ b/pkg/nri/domain.go @@ -21,11 +21,12 @@ import ( "fmt" "sync" - "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" "github.com/containerd/log" nri "github.com/containerd/nri/pkg/adaptation" "github.com/sirupsen/logrus" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/namespaces" ) // Domain implements the functions the generic NRI interface needs to diff --git a/pkg/process/deleted_state.go b/pkg/process/deleted_state.go index 32d2b6989e6f..30852104b231 100644 --- a/pkg/process/deleted_state.go +++ b/pkg/process/deleted_state.go @@ -24,8 +24,8 @@ import ( "fmt" "github.com/containerd/console" + "github.com/containerd/containerd/errdefs" google_protobuf "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" ) type deletedState struct { diff --git a/pkg/process/exec.go b/pkg/process/exec.go index a46563e64ead..620ad093a1b0 100644 --- a/pkg/process/exec.go +++ b/pkg/process/exec.go @@ -31,8 +31,8 @@ import ( "golang.org/x/sys/unix" "github.com/containerd/console" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/stdio" - "github.com/containerd/errdefs" "github.com/containerd/fifo" runc "github.com/containerd/go-runc" specs "github.com/opencontainers/runtime-spec/specs-go" diff --git a/pkg/process/utils.go b/pkg/process/utils.go index 90feebc7cf78..b074958cff82 100644 --- a/pkg/process/utils.go +++ b/pkg/process/utils.go @@ -30,7 +30,7 @@ import ( "sync/atomic" "time" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" runc "github.com/containerd/go-runc" "golang.org/x/sys/unix" ) diff --git a/pkg/transfer/image/imagestore.go b/pkg/transfer/image/imagestore.go index a7a6bbe61195..7a3afa389500 100644 --- a/pkg/transfer/image/imagestore.go +++ b/pkg/transfer/image/imagestore.go @@ -20,20 +20,20 @@ import ( "context" "fmt" + "github.com/containerd/platforms" "github.com/containerd/typeurl/v2" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/containerd/containerd/api/types" transfertypes "github.com/containerd/containerd/api/types/transfer" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/images/archive" "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/plugins" "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" ) func init() { diff --git a/pkg/transfer/image/imagestore_test.go b/pkg/transfer/image/imagestore_test.go index 25a560932569..cefa0c1ef7e9 100644 --- a/pkg/transfer/image/imagestore_test.go +++ b/pkg/transfer/image/imagestore_test.go @@ -23,8 +23,8 @@ import ( "sync" "testing" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" - "github.com/containerd/errdefs" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/transfer/local/import.go b/pkg/transfer/local/import.go index c4129695eddb..516c1d349f89 100644 --- a/pkg/transfer/local/import.go +++ b/pkg/transfer/local/import.go @@ -21,14 +21,14 @@ import ( "encoding/json" "fmt" + "github.com/containerd/log" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/unpack" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func (ts *localTransferService) importStream(ctx context.Context, i transfer.ImageImporter, is transfer.ImageStorer, tops *transfer.Config) error { diff --git a/pkg/transfer/local/pull.go b/pkg/transfer/local/pull.go index 28f7daa31f61..1200dc2d350c 100644 --- a/pkg/transfer/local/pull.go +++ b/pkg/transfer/local/pull.go @@ -20,16 +20,17 @@ import ( "context" "fmt" + "github.com/containerd/log" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/unpack" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" - "github.com/containerd/errdefs" - "github.com/containerd/log" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error { diff --git a/pkg/transfer/local/push.go b/pkg/transfer/local/push.go index 798a13581087..6fcce425db08 100644 --- a/pkg/transfer/local/push.go +++ b/pkg/transfer/local/push.go @@ -22,14 +22,15 @@ import ( "sync" "time" + "github.com/containerd/platforms" + "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" - "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func (ts *localTransferService) push(ctx context.Context, ig transfer.ImageGetter, p transfer.ImagePusher, tops *transfer.Config) error { diff --git a/pkg/transfer/local/transfer.go b/pkg/transfer/local/transfer.go index e9a4073d755b..7ca800a62f55 100644 --- a/pkg/transfer/local/transfer.go +++ b/pkg/transfer/local/transfer.go @@ -26,12 +26,12 @@ import ( "golang.org/x/sync/semaphore" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/pkg/kmutex" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/unpack" - "github.com/containerd/errdefs" ) type localTransferService struct { diff --git a/pkg/transfer/plugins/plugins.go b/pkg/transfer/plugins/plugins.go index 1769fea3c121..d122ec368b01 100644 --- a/pkg/transfer/plugins/plugins.go +++ b/pkg/transfer/plugins/plugins.go @@ -21,7 +21,7 @@ import ( "reflect" "sync" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/containerd/typeurl/v2" ) diff --git a/pkg/unpack/unpacker.go b/pkg/unpack/unpacker.go index 76e24f76360e..b250a51350d7 100644 --- a/pkg/unpack/unpacker.go +++ b/pkg/unpack/unpacker.go @@ -28,8 +28,17 @@ import ( "sync/atomic" "time" + "github.com/containerd/log" + "github.com/containerd/platforms" + "github.com/opencontainers/go-digest" + "github.com/opencontainers/image-spec/identity" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "golang.org/x/sync/errgroup" + "golang.org/x/sync/semaphore" + "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" "github.com/containerd/containerd/mount" @@ -37,14 +46,6 @@ import ( "github.com/containerd/containerd/pkg/kmutex" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" - "github.com/opencontainers/go-digest" - "github.com/opencontainers/image-spec/identity" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "golang.org/x/sync/errgroup" - "golang.org/x/sync/semaphore" ) const ( diff --git a/plugin/context.go b/plugin/context.go index d084564ea280..370508d28d15 100644 --- a/plugin/context.go +++ b/plugin/context.go @@ -23,8 +23,8 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" - "github.com/containerd/errdefs" ) // InitContext is used for plugin initialization diff --git a/plugins/sandbox/controller.go b/plugins/sandbox/controller.go index adb1ef24290f..6138f5ee43b2 100644 --- a/plugins/sandbox/controller.go +++ b/plugins/sandbox/controller.go @@ -21,18 +21,18 @@ import ( "fmt" "time" + "github.com/containerd/log" + imagespec "github.com/opencontainers/image-spec/specs-go/v1" + "google.golang.org/protobuf/types/known/anypb" + runtimeAPI "github.com/containerd/containerd/api/runtime/sandbox/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/runtime" v2 "github.com/containerd/containerd/runtime/v2" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" - "github.com/containerd/log" - - imagespec "github.com/opencontainers/image-spec/specs-go/v1" - "google.golang.org/protobuf/types/known/anypb" ) func init() { diff --git a/plugins/streaming/manager.go b/plugins/streaming/manager.go index e80d29a4f9d4..85a4debac8f6 100644 --- a/plugins/streaming/manager.go +++ b/plugins/streaming/manager.go @@ -20,13 +20,13 @@ import ( "context" "sync" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/gc" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/plugin" - "github.com/containerd/errdefs" "github.com/hashicorp/go-multierror" ) diff --git a/plugins/transfer/plugin.go b/plugins/transfer/plugin.go index 51e39e18cec7..8e43561b24e5 100644 --- a/plugins/transfer/plugin.go +++ b/plugins/transfer/plugin.go @@ -19,16 +19,17 @@ package transfer import ( "fmt" + "github.com/containerd/log" + "github.com/containerd/platforms" + "github.com/containerd/containerd" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/pkg/transfer/local" "github.com/containerd/containerd/pkg/unpack" "github.com/containerd/containerd/plugin" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" // Load packages with type registrations _ "github.com/containerd/containerd/pkg/transfer/archive" diff --git a/process.go b/process.go index d17bfb69348b..73d8f8662581 100644 --- a/process.go +++ b/process.go @@ -25,8 +25,8 @@ import ( "github.com/containerd/containerd/api/services/tasks/v1" "github.com/containerd/containerd/cio" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" ) // Process represents a system process diff --git a/pull.go b/pull.go index 75feb764ae61..c5d3e969a9fc 100644 --- a/pull.go +++ b/pull.go @@ -24,14 +24,15 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/semaphore" + "github.com/containerd/platforms" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/pkg/unpack" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" - "github.com/containerd/platforms" ) const ( diff --git a/remotes/docker/authorizer.go b/remotes/docker/authorizer.go index 2fd1118bc77f..2bf388e8cb0c 100644 --- a/remotes/docker/authorizer.go +++ b/remotes/docker/authorizer.go @@ -25,10 +25,11 @@ import ( "strings" "sync" + "github.com/containerd/log" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/remotes/docker/auth" remoteerrors "github.com/containerd/containerd/remotes/errors" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) type dockerAuthorizer struct { diff --git a/remotes/docker/config/hosts.go b/remotes/docker/config/hosts.go index 79a55c96a281..83cfbd32409c 100644 --- a/remotes/docker/config/hosts.go +++ b/remotes/docker/config/hosts.go @@ -32,10 +32,11 @@ import ( "strings" "time" - "github.com/containerd/containerd/remotes/docker" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/pelletier/go-toml" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/remotes/docker" ) // UpdateClientFunc is a function that lets you to amend http Client behavior used by registry clients. diff --git a/remotes/docker/fetcher.go b/remotes/docker/fetcher.go index 3589db3ef91c..c4c401ad1d56 100644 --- a/remotes/docker/fetcher.go +++ b/remotes/docker/fetcher.go @@ -26,11 +26,12 @@ import ( "net/url" "strings" - "github.com/containerd/containerd/images" - "github.com/containerd/errdefs" "github.com/containerd/log" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" ) type dockerFetcher struct { diff --git a/remotes/docker/httpreadseeker.go b/remotes/docker/httpreadseeker.go index 6739e7904e1b..deb888cbc8f5 100644 --- a/remotes/docker/httpreadseeker.go +++ b/remotes/docker/httpreadseeker.go @@ -21,8 +21,9 @@ import ( "fmt" "io" - "github.com/containerd/errdefs" "github.com/containerd/log" + + "github.com/containerd/containerd/errdefs" ) const maxRetry = 3 diff --git a/remotes/docker/pusher.go b/remotes/docker/pusher.go index a27cda0b56c3..f97ab144e8b7 100644 --- a/remotes/docker/pusher.go +++ b/remotes/docker/pusher.go @@ -28,14 +28,15 @@ import ( "sync" "time" + "github.com/containerd/log" + digest "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/remotes" remoteserrors "github.com/containerd/containerd/remotes/errors" - "github.com/containerd/errdefs" - "github.com/containerd/log" - digest "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) type dockerPusher struct { diff --git a/remotes/docker/pusher_test.go b/remotes/docker/pusher_test.go index 44a4ea4f16cb..7ced8ede9659 100644 --- a/remotes/docker/pusher_test.go +++ b/remotes/docker/pusher_test.go @@ -32,9 +32,9 @@ import ( "testing" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/reference" "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" "github.com/containerd/log/logtest" "github.com/opencontainers/go-digest" ocispecv "github.com/opencontainers/image-spec/specs-go" diff --git a/remotes/docker/resolver.go b/remotes/docker/resolver.go index b2b1242140b4..4ca2b921ebc4 100644 --- a/remotes/docker/resolver.go +++ b/remotes/docker/resolver.go @@ -28,6 +28,11 @@ import ( "path" "strings" + "github.com/containerd/log" + "github.com/opencontainers/go-digest" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/reference" "github.com/containerd/containerd/remotes" @@ -35,10 +40,6 @@ import ( remoteerrors "github.com/containerd/containerd/remotes/errors" "github.com/containerd/containerd/tracing" "github.com/containerd/containerd/version" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/opencontainers/go-digest" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) var ( diff --git a/remotes/docker/schema1/converter.go b/remotes/docker/schema1/converter.go index 75bd9875a4c5..b38c738552a5 100644 --- a/remotes/docker/schema1/converter.go +++ b/remotes/docker/schema1/converter.go @@ -32,17 +32,18 @@ import ( "sync" "time" - "github.com/containerd/containerd/archive/compression" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/images" - "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/remotes" - "github.com/containerd/errdefs" "github.com/containerd/log" digest "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/errgroup" + + "github.com/containerd/containerd/archive/compression" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" + "github.com/containerd/containerd/labels" + "github.com/containerd/containerd/remotes" ) const ( diff --git a/remotes/docker/status.go b/remotes/docker/status.go index c7764758f0ef..1a9227725bb3 100644 --- a/remotes/docker/status.go +++ b/remotes/docker/status.go @@ -21,7 +21,7 @@ import ( "sync" "github.com/containerd/containerd/content" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/moby/locker" ) diff --git a/remotes/handlers.go b/remotes/handlers.go index 736a044c735a..365ff5fc00f6 100644 --- a/remotes/handlers.go +++ b/remotes/handlers.go @@ -25,14 +25,15 @@ import ( "strings" "sync" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/images" - "github.com/containerd/containerd/labels" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/semaphore" + + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/images" + "github.com/containerd/containerd/labels" ) type refKeyPrefix struct{} diff --git a/rootfs/apply.go b/rootfs/apply.go index 61f4d7dfb79c..b22011e87e4f 100644 --- a/rootfs/apply.go +++ b/rootfs/apply.go @@ -23,14 +23,15 @@ import ( "fmt" "time" - "github.com/containerd/containerd/diff" - "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/opencontainers/go-digest" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/mount" + "github.com/containerd/containerd/snapshots" ) // Layer represents the descriptors for a layer diff. These descriptions diff --git a/runtime/nsmap.go b/runtime/nsmap.go index 0754575c5e2d..ed172adcc127 100644 --- a/runtime/nsmap.go +++ b/runtime/nsmap.go @@ -21,8 +21,8 @@ import ( "fmt" "sync" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" - "github.com/containerd/errdefs" ) type object interface { diff --git a/runtime/v1/linux/process.go b/runtime/v1/linux/process.go index da12747f29ae..d23e1e1ca241 100644 --- a/runtime/v1/linux/process.go +++ b/runtime/v1/linux/process.go @@ -24,10 +24,10 @@ import ( eventstypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/api/types/task" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/runtime" shim "github.com/containerd/containerd/runtime/v1/shim/v1" - "github.com/containerd/errdefs" "github.com/containerd/ttrpc" ) diff --git a/runtime/v1/linux/runtime.go b/runtime/v1/linux/runtime.go index ab3f02487590..378226f73f93 100644 --- a/runtime/v1/linux/runtime.go +++ b/runtime/v1/linux/runtime.go @@ -30,6 +30,7 @@ import ( eventstypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/metadata" @@ -44,7 +45,6 @@ import ( "github.com/containerd/containerd/runtime/linux/runctypes" v1 "github.com/containerd/containerd/runtime/v1" "github.com/containerd/containerd/runtime/v1/shim/v1" - "github.com/containerd/errdefs" "github.com/containerd/go-runc" "github.com/containerd/log" "github.com/containerd/platforms" diff --git a/runtime/v1/linux/task.go b/runtime/v1/linux/task.go index 4c5779f1d79e..56f90763df4d 100644 --- a/runtime/v1/linux/task.go +++ b/runtime/v1/linux/task.go @@ -26,7 +26,11 @@ import ( "sync" cgroups "github.com/containerd/cgroups/v3/cgroup1" + "github.com/containerd/log" + "github.com/containerd/ttrpc" + eventstypes "github.com/containerd/containerd/api/events" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/protobuf" @@ -34,9 +38,6 @@ import ( "github.com/containerd/containerd/runtime" "github.com/containerd/containerd/runtime/v1/shim/client" "github.com/containerd/containerd/runtime/v1/shim/v1" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/ttrpc" ) // Task on a linux based system diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go index 4d5c55952eab..14b895783778 100644 --- a/runtime/v1/shim/service.go +++ b/runtime/v1/shim/service.go @@ -29,6 +29,7 @@ import ( "github.com/containerd/console" eventstypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/api/types/task" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" @@ -40,7 +41,6 @@ import ( "github.com/containerd/containerd/runtime/linux/runctypes" shimapi "github.com/containerd/containerd/runtime/v1/shim/v1" "github.com/containerd/containerd/sys/reaper" - "github.com/containerd/errdefs" runc "github.com/containerd/go-runc" "github.com/containerd/log" "github.com/containerd/typeurl/v2" diff --git a/runtime/v2/example/example.go b/runtime/v2/example/example.go index 33d1d4579d8a..2d6d66092c52 100644 --- a/runtime/v2/example/example.go +++ b/runtime/v2/example/example.go @@ -23,9 +23,9 @@ import ( "os" taskAPI "github.com/containerd/containerd/api/runtime/task/v2" + "github.com/containerd/containerd/errdefs" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime/v2/shim" - "github.com/containerd/errdefs" ) var ( diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 80c7d68314ea..97ea5f6e4604 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -25,7 +25,12 @@ import ( "strings" "sync" + "github.com/containerd/log" + "github.com/containerd/platforms" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/namespaces" @@ -36,10 +41,6 @@ import ( "github.com/containerd/containerd/runtime" shimbinary "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/platforms" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // Config for the v2 runtime diff --git a/runtime/v2/process.go b/runtime/v2/process.go index 3d37e6a467fb..e2c9a5c0d3ae 100644 --- a/runtime/v2/process.go +++ b/runtime/v2/process.go @@ -22,9 +22,9 @@ import ( "github.com/containerd/containerd/api/runtime/task/v2" tasktypes "github.com/containerd/containerd/api/types/task" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/runtime" - "github.com/containerd/errdefs" "github.com/containerd/ttrpc" ) diff --git a/runtime/v2/runc/container.go b/runtime/v2/runc/container.go index 47fcb76f248e..dcc84f9c13fa 100644 --- a/runtime/v2/runc/container.go +++ b/runtime/v2/runc/container.go @@ -31,12 +31,12 @@ import ( cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2" "github.com/containerd/console" "github.com/containerd/containerd/api/runtime/task/v2" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/process" "github.com/containerd/containerd/pkg/stdio" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" ) diff --git a/runtime/v2/runc/task/service.go b/runtime/v2/runc/task/service.go index 4436cf7d9d30..4f772054fcc5 100644 --- a/runtime/v2/runc/task/service.go +++ b/runtime/v2/runc/task/service.go @@ -32,6 +32,7 @@ import ( eventstypes "github.com/containerd/containerd/api/events" taskAPI "github.com/containerd/containerd/api/runtime/task/v2" "github.com/containerd/containerd/api/types/task" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/oom" oomv1 "github.com/containerd/containerd/pkg/oom/v1" @@ -45,7 +46,6 @@ import ( "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/containerd/sys/reaper" - "github.com/containerd/errdefs" runcC "github.com/containerd/go-runc" "github.com/containerd/ttrpc" "github.com/containerd/typeurl/v2" diff --git a/runtime/v2/runc/v1/service.go b/runtime/v2/runc/v1/service.go index 3efbd11128af..26c68fe262c2 100644 --- a/runtime/v2/runc/v1/service.go +++ b/runtime/v2/runc/v1/service.go @@ -34,6 +34,7 @@ import ( eventstypes "github.com/containerd/containerd/api/events" taskAPI "github.com/containerd/containerd/api/runtime/task/v2" "github.com/containerd/containerd/api/types/task" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/oom" @@ -48,7 +49,6 @@ import ( "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/runtime/v2/shim" "github.com/containerd/containerd/sys/reaper" - "github.com/containerd/errdefs" runcC "github.com/containerd/go-runc" "github.com/containerd/typeurl/v2" "github.com/sirupsen/logrus" diff --git a/runtime/v2/shim.go b/runtime/v2/shim.go index ddeeeeb351b8..bf8a894f5fd2 100644 --- a/runtime/v2/shim.go +++ b/runtime/v2/shim.go @@ -28,6 +28,7 @@ import ( "strings" "time" + "github.com/containerd/log" "github.com/containerd/ttrpc" "github.com/hashicorp/go-multierror" "google.golang.org/grpc" @@ -37,6 +38,7 @@ import ( eventstypes "github.com/containerd/containerd/api/events" "github.com/containerd/containerd/api/runtime/task/v2" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/identifiers" "github.com/containerd/containerd/pkg/dialer" @@ -45,8 +47,6 @@ import ( ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/runtime" client "github.com/containerd/containerd/runtime/v2/shim" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) const ( diff --git a/runtime/v2/shim/shim_windows.go b/runtime/v2/shim/shim_windows.go index 8181b4c8150f..a290a06fb624 100644 --- a/runtime/v2/shim/shim_windows.go +++ b/runtime/v2/shim/shim_windows.go @@ -22,7 +22,7 @@ import ( "net" "os" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/containerd/ttrpc" "github.com/sirupsen/logrus" ) diff --git a/runtime/v2/shim/util.go b/runtime/v2/shim/util.go index addff53cf1aa..de6e873b3748 100644 --- a/runtime/v2/shim/util.go +++ b/runtime/v2/shim/util.go @@ -32,11 +32,11 @@ import ( "github.com/containerd/ttrpc" "github.com/containerd/typeurl/v2" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/atomicfile" "github.com/containerd/containerd/protobuf/proto" "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" ) type CommandConfig struct { diff --git a/runtime/v2/shim_load.go b/runtime/v2/shim_load.go index f69d68f2c99b..ff76cbba9faa 100644 --- a/runtime/v2/shim_load.go +++ b/runtime/v2/shim_load.go @@ -22,11 +22,12 @@ import ( "os" "path/filepath" + "github.com/containerd/log" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/cleanup" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func (m *ShimManager) loadExistingTasks(ctx context.Context) error { diff --git a/runtime/v2/shim_test.go b/runtime/v2/shim_test.go index d3f76388b639..13ca6863407a 100644 --- a/runtime/v2/shim_test.go +++ b/runtime/v2/shim_test.go @@ -21,8 +21,8 @@ import ( "errors" "testing" + "github.com/containerd/containerd/errdefs" client "github.com/containerd/containerd/runtime/v2/shim" - "github.com/containerd/errdefs" ) func TestParseStartResponse(t *testing.T) { diff --git a/sandbox/proxy/controller.go b/sandbox/proxy/controller.go index fe8e95c29843..a18f3e6acff1 100644 --- a/sandbox/proxy/controller.go +++ b/sandbox/proxy/controller.go @@ -19,11 +19,12 @@ package proxy import ( "context" - api "github.com/containerd/containerd/api/services/sandbox/v1" - "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" imagespec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/protobuf/types/known/anypb" + + api "github.com/containerd/containerd/api/services/sandbox/v1" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/sandbox" ) // remoteSandboxController is a low level GRPC client for containerd's sandbox controller service diff --git a/sandbox/proxy/store.go b/sandbox/proxy/store.go index 9544df81057d..64e4a2b32039 100644 --- a/sandbox/proxy/store.go +++ b/sandbox/proxy/store.go @@ -20,8 +20,8 @@ import ( "context" api "github.com/containerd/containerd/api/services/sandbox/v1" + "github.com/containerd/containerd/errdefs" sb "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" ) // remoteSandboxStore is a low-level containerd client to manage sandbox environments metadata diff --git a/sandbox/store.go b/sandbox/store.go index 5d0d42bdb81c..cda646dde279 100644 --- a/sandbox/store.go +++ b/sandbox/store.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" "github.com/containerd/typeurl/v2" ) diff --git a/services/containers/local.go b/services/containers/local.go index 13b98112468c..2c85422d7e98 100644 --- a/services/containers/local.go +++ b/services/containers/local.go @@ -23,12 +23,12 @@ import ( eventstypes "github.com/containerd/containerd/api/events" api "github.com/containerd/containerd/api/services/containers/v1" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/services" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/services/content/contentserver/contentserver.go b/services/content/contentserver/contentserver.go index 4c185aa1ec89..c8f7dded1e38 100644 --- a/services/content/contentserver/contentserver.go +++ b/services/content/contentserver/contentserver.go @@ -22,17 +22,18 @@ import ( "io" "sync" - api "github.com/containerd/containerd/api/services/content/v1" - "github.com/containerd/containerd/content" - "github.com/containerd/containerd/protobuf" - ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/containerd/log" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + api "github.com/containerd/containerd/api/services/content/v1" + "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/protobuf" + ptypes "github.com/containerd/containerd/protobuf/types" ) type service struct { diff --git a/services/diff/local.go b/services/diff/local.go index 6dc5e11155bc..8295b88ee5f2 100644 --- a/services/diff/local.go +++ b/services/diff/local.go @@ -23,10 +23,10 @@ import ( diffapi "github.com/containerd/containerd/api/services/diff/v1" "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/services" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/services/events/service.go b/services/events/service.go index 1e9791068cea..309ad42e05b6 100644 --- a/services/events/service.go +++ b/services/events/service.go @@ -22,12 +22,12 @@ import ( api "github.com/containerd/containerd/api/services/events/v1" apittrpc "github.com/containerd/containerd/api/services/ttrpc/events/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "github.com/containerd/ttrpc" "google.golang.org/grpc" ) diff --git a/services/events/ttrpc.go b/services/events/ttrpc.go index f9bf8e4cc7ca..1b3ceb9432aa 100644 --- a/services/events/ttrpc.go +++ b/services/events/ttrpc.go @@ -20,11 +20,11 @@ import ( "context" api "github.com/containerd/containerd/api/services/ttrpc/events/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" ) type ttrpcService struct { diff --git a/services/images/local.go b/services/images/local.go index 7101fa622cb3..d7ecbf9d6f17 100644 --- a/services/images/local.go +++ b/services/images/local.go @@ -23,8 +23,11 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/containerd/log" + eventstypes "github.com/containerd/containerd/api/events" imagesapi "github.com/containerd/containerd/api/services/images/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/gc" "github.com/containerd/containerd/images" @@ -35,8 +38,6 @@ import ( ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/services" "github.com/containerd/containerd/services/warning" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func init() { diff --git a/services/introspection/introspection.go b/services/introspection/introspection.go index 18fb914d255b..c0b54aa684bd 100644 --- a/services/introspection/introspection.go +++ b/services/introspection/introspection.go @@ -19,10 +19,11 @@ package introspection import ( context "context" + "github.com/containerd/log" + api "github.com/containerd/containerd/api/services/introspection/v1" + "github.com/containerd/containerd/errdefs" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) // Service defines the introspection service interface diff --git a/services/introspection/local.go b/services/introspection/local.go index 8c992047dcfb..90414ed567ee 100644 --- a/services/introspection/local.go +++ b/services/introspection/local.go @@ -30,10 +30,9 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/status" - "github.com/containerd/errdefs" - api "github.com/containerd/containerd/api/services/introspection/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" diff --git a/services/leases/service.go b/services/leases/service.go index 18e21cbd8deb..9cebf73309de 100644 --- a/services/leases/service.go +++ b/services/leases/service.go @@ -20,11 +20,11 @@ import ( "context" api "github.com/containerd/containerd/api/services/leases/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/leases" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" "google.golang.org/grpc" ) diff --git a/services/namespaces/local.go b/services/namespaces/local.go index a027bb54489e..a4a2da05ee22 100644 --- a/services/namespaces/local.go +++ b/services/namespaces/local.go @@ -22,13 +22,13 @@ import ( eventstypes "github.com/containerd/containerd/api/events" api "github.com/containerd/containerd/api/services/namespaces/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/services" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" "google.golang.org/grpc" "google.golang.org/grpc/codes" diff --git a/services/sandbox/controller_service.go b/services/sandbox/controller_service.go index 09ae8f5279d1..d75b4cf92dd9 100644 --- a/services/sandbox/controller_service.go +++ b/services/sandbox/controller_service.go @@ -22,14 +22,15 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/types/known/anypb" + "github.com/containerd/log" + eventtypes "github.com/containerd/containerd/api/events" api "github.com/containerd/containerd/api/services/sandbox/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func init() { diff --git a/services/sandbox/store_service.go b/services/sandbox/store_service.go index 7f1631e1d92f..f17f23d54d5e 100644 --- a/services/sandbox/store_service.go +++ b/services/sandbox/store_service.go @@ -21,12 +21,13 @@ import ( "google.golang.org/grpc" + "github.com/containerd/log" + api "github.com/containerd/containerd/api/services/sandbox/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/sandbox" - "github.com/containerd/errdefs" - "github.com/containerd/log" ) func init() { diff --git a/services/server/config/config.go b/services/server/config/config.go index 063e71c3d547..8876f90170c7 100644 --- a/services/server/config/config.go +++ b/services/server/config/config.go @@ -25,8 +25,8 @@ import ( "github.com/pelletier/go-toml" "github.com/sirupsen/logrus" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/plugin" - "github.com/containerd/errdefs" ) // NOTE: Any new map fields added also need to be handled in mergeConfig. diff --git a/services/snapshots/service.go b/services/snapshots/service.go index 928b5d870176..1289f00ef1cc 100644 --- a/services/snapshots/service.go +++ b/services/snapshots/service.go @@ -24,6 +24,7 @@ import ( snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/pkg/deprecation" "github.com/containerd/containerd/plugin" @@ -32,7 +33,6 @@ import ( "github.com/containerd/containerd/services" "github.com/containerd/containerd/services/warning" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/containerd/log" ) diff --git a/services/streaming/service.go b/services/streaming/service.go index eb30fc7559e1..309885b0763f 100644 --- a/services/streaming/service.go +++ b/services/streaming/service.go @@ -20,15 +20,16 @@ import ( "errors" "io" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + "google.golang.org/grpc" + api "github.com/containerd/containerd/api/services/streaming/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/protobuf" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - "google.golang.org/grpc" ) func init() { diff --git a/services/tasks/local.go b/services/tasks/local.go index 667e936217f2..f086fb50329a 100644 --- a/services/tasks/local.go +++ b/services/tasks/local.go @@ -32,6 +32,7 @@ import ( "github.com/containerd/containerd/archive" "github.com/containerd/containerd/containers" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/images" @@ -50,9 +51,8 @@ import ( "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/containerd/containerd/services" "github.com/containerd/containerd/services/warning" - "github.com/containerd/errdefs" - "github.com/containerd/log" + "github.com/containerd/log" "github.com/containerd/typeurl/v2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/services/transfer/service.go b/services/transfer/service.go index e0e1ed790baa..735f96a935db 100644 --- a/services/transfer/service.go +++ b/services/transfer/service.go @@ -19,20 +19,21 @@ package transfer import ( "context" + "github.com/containerd/log" + "github.com/containerd/typeurl/v2" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/emptypb" + transferapi "github.com/containerd/containerd/api/services/transfer/v1" transferTypes "github.com/containerd/containerd/api/types/transfer" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/plugins" "github.com/containerd/containerd/plugin" ptypes "github.com/containerd/containerd/protobuf/types" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/containerd/typeurl/v2" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/types/known/emptypb" ) func init() { diff --git a/snapshots/devmapper/metadata.go b/snapshots/devmapper/metadata.go index f6dc0e3fb97c..9f5a1cd0d2a2 100644 --- a/snapshots/devmapper/metadata.go +++ b/snapshots/devmapper/metadata.go @@ -25,7 +25,7 @@ import ( "fmt" "strconv" - "github.com/containerd/errdefs" + "github.com/containerd/containerd/errdefs" bolt "go.etcd.io/bbolt" ) diff --git a/snapshots/devmapper/snapshotter.go b/snapshots/devmapper/snapshotter.go index 7ba5d2d93712..d7627bf63dbb 100644 --- a/snapshots/devmapper/snapshotter.go +++ b/snapshots/devmapper/snapshotter.go @@ -28,13 +28,14 @@ import ( "strings" "sync" + "github.com/containerd/log" + "github.com/hashicorp/go-multierror" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/devmapper/dmsetup" "github.com/containerd/containerd/snapshots/storage" - "github.com/containerd/errdefs" - "github.com/containerd/log" - "github.com/hashicorp/go-multierror" ) type fsType string diff --git a/snapshots/lcow/lcow.go b/snapshots/lcow/lcow.go index bb0ab39bb8b5..35ad6a6d7ad9 100644 --- a/snapshots/lcow/lcow.go +++ b/snapshots/lcow/lcow.go @@ -34,14 +34,15 @@ import ( winfs "github.com/Microsoft/go-winio/pkg/fs" "github.com/Microsoft/hcsshim/pkg/go-runhcs" + "github.com/containerd/continuity/fs" + "github.com/containerd/log" + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" - "github.com/containerd/continuity/fs" - "github.com/containerd/errdefs" - "github.com/containerd/log" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) func init() { diff --git a/snapshots/proxy/proxy.go b/snapshots/proxy/proxy.go index 8e3bd1f838bd..3ef3b2698e8e 100644 --- a/snapshots/proxy/proxy.go +++ b/snapshots/proxy/proxy.go @@ -22,11 +22,11 @@ import ( snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/api/types" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/protobuf" protobuftypes "github.com/containerd/containerd/protobuf/types" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" ) // NewSnapshotter returns a new Snapshotter which communicates over a GRPC diff --git a/snapshots/storage/bolt.go b/snapshots/storage/bolt.go index 3e8e8e45efac..894ac2e022fc 100644 --- a/snapshots/storage/bolt.go +++ b/snapshots/storage/bolt.go @@ -24,10 +24,10 @@ import ( "strings" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/filters" "github.com/containerd/containerd/metadata/boltutil" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" bolt "go.etcd.io/bbolt" ) diff --git a/snapshots/storage/metastore_test.go b/snapshots/storage/metastore_test.go index e4a0bf097093..16847068d1b0 100644 --- a/snapshots/storage/metastore_test.go +++ b/snapshots/storage/metastore_test.go @@ -23,8 +23,8 @@ import ( "testing" "time" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/snapshots" - "github.com/containerd/errdefs" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" ) diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index f9fd8bf32d71..29dd6b505706 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -28,15 +28,16 @@ import ( "testing" "time" + "github.com/containerd/continuity/fs/fstest" + "github.com/containerd/log/logtest" + "github.com/stretchr/testify/assert" + + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/pkg/randutil" "github.com/containerd/containerd/pkg/testutil" "github.com/containerd/containerd/snapshots" - "github.com/containerd/continuity/fs/fstest" - "github.com/containerd/errdefs" - "github.com/containerd/log/logtest" - "github.com/stretchr/testify/assert" ) // SnapshotterFunc is used in SnapshotterSuite @@ -553,7 +554,7 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot t.Fatal("intermediate layer removal should fail.") } - // Removal from toplayer to base should not fail. + //Removal from toplayer to base should not fail. err = snapshotter.Remove(ctx, topLayer) if err != nil { t.Fatal(err) diff --git a/snapshots/windows/windows.go b/snapshots/windows/windows.go index 0df2180a9bb6..5332c104d943 100644 --- a/snapshots/windows/windows.go +++ b/snapshots/windows/windows.go @@ -34,15 +34,16 @@ import ( winfs "github.com/Microsoft/go-winio/pkg/fs" "github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim/pkg/ociwclayer" - "github.com/containerd/containerd/mount" - "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/snapshots" - "github.com/containerd/containerd/snapshots/storage" "github.com/containerd/continuity/fs" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/containerd/platforms" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/mount" + "github.com/containerd/containerd/plugin" + "github.com/containerd/containerd/snapshots" + "github.com/containerd/containerd/snapshots/storage" ) func init() { diff --git a/task.go b/task.go index 099afdcf830a..9667a1cf5ae1 100644 --- a/task.go +++ b/task.go @@ -33,6 +33,7 @@ import ( "github.com/containerd/containerd/cio" "github.com/containerd/containerd/content" "github.com/containerd/containerd/diff" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/oci" @@ -42,7 +43,6 @@ import ( "github.com/containerd/containerd/rootfs" "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" digest "github.com/opencontainers/go-digest" is "github.com/opencontainers/image-spec/specs-go" diff --git a/task_opts.go b/task_opts.go index 3774d6592d58..9c88debd3650 100644 --- a/task_opts.go +++ b/task_opts.go @@ -25,11 +25,11 @@ import ( "github.com/containerd/containerd/api/types" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" - "github.com/containerd/errdefs" imagespec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/tracing/plugin/otlp.go b/tracing/plugin/otlp.go index bcb5a141ab81..4b22320103cf 100644 --- a/tracing/plugin/otlp.go +++ b/tracing/plugin/otlp.go @@ -24,11 +24,6 @@ import ( "strconv" "time" - "github.com/containerd/containerd/pkg/deprecation" - "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/services/warning" - "github.com/containerd/containerd/tracing" - "github.com/containerd/errdefs" "github.com/containerd/log" "github.com/sirupsen/logrus" "go.opentelemetry.io/otel" @@ -37,6 +32,12 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/trace" + + "github.com/containerd/containerd/errdefs" + "github.com/containerd/containerd/pkg/deprecation" + "github.com/containerd/containerd/plugin" + "github.com/containerd/containerd/services/warning" + "github.com/containerd/containerd/tracing" ) const exporterPlugin = "otlp" diff --git a/transfer.go b/transfer.go index 412957bb94e2..9979aa75bd9b 100644 --- a/transfer.go +++ b/transfer.go @@ -23,11 +23,11 @@ import ( streamingapi "github.com/containerd/containerd/api/services/streaming/v1" transferapi "github.com/containerd/containerd/api/services/transfer/v1" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/pkg/streaming" "github.com/containerd/containerd/pkg/transfer" "github.com/containerd/containerd/pkg/transfer/proxy" "github.com/containerd/containerd/protobuf" - "github.com/containerd/errdefs" "github.com/containerd/typeurl/v2" ) From d8d27205b50bf4933a60cd9e6ddf3aaa2b56c469 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 22:20:51 -0700 Subject: [PATCH 5/6] Revert "migrate errdefs package to github.com/containerd/errdefs module" This reverts commit 47ff8cfce0768d4f4c98ad05bd72e8f9ad8dfb5c. Signed-off-by: Derek McGowan --- errdefs/errdefs_deprecated.go | 116 ----------- .../containerd/errdefs => errdefs}/errors.go | 0 .../containerd/errdefs => errdefs}/grpc.go | 0 errdefs/grpc_test.go | 103 ++++++++++ go.mod | 1 - go.sum | 2 - integration/client/go.mod | 1 - integration/client/go.sum | 2 - vendor/github.com/containerd/errdefs/LICENSE | 191 ------------------ .../github.com/containerd/errdefs/README.md | 13 -- vendor/modules.txt | 3 - 11 files changed, 103 insertions(+), 329 deletions(-) delete mode 100644 errdefs/errdefs_deprecated.go rename {vendor/github.com/containerd/errdefs => errdefs}/errors.go (100%) rename {vendor/github.com/containerd/errdefs => errdefs}/grpc.go (100%) create mode 100644 errdefs/grpc_test.go delete mode 100644 vendor/github.com/containerd/errdefs/LICENSE delete mode 100644 vendor/github.com/containerd/errdefs/README.md diff --git a/errdefs/errdefs_deprecated.go b/errdefs/errdefs_deprecated.go deleted file mode 100644 index c6a0d843ebef..000000000000 --- a/errdefs/errdefs_deprecated.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 errdefs defines the common errors used throughout containerd -// packages. -// -// Use with fmt.Errorf to add context to an error. -// -// To detect an error class, use the IsXXX functions to tell whether an error -// is of a certain type. -// -// The functions ToGRPC and FromGRPC can be used to map server-side and -// client-side errors to the correct types. -package errdefs - -import ( - "github.com/containerd/errdefs" -) - -// Definitions of common error types used throughout containerd. All containerd -// errors returned by most packages will map into one of these errors classes. -// Packages should return errors of these types when they want to instruct a -// client to take a particular action. -// -// For the most part, we just try to provide local grpc errors. Most conditions -// map very well to those defined by grpc. -var ( - ErrUnknown = errdefs.ErrUnknown - ErrInvalidArgument = errdefs.ErrInvalidArgument - ErrNotFound = errdefs.ErrNotFound - ErrAlreadyExists = errdefs.ErrAlreadyExists - ErrFailedPrecondition = errdefs.ErrFailedPrecondition - ErrUnavailable = errdefs.ErrUnavailable - ErrNotImplemented = errdefs.ErrNotImplemented -) - -// IsInvalidArgument returns true if the error is due to an invalid argument -func IsInvalidArgument(err error) bool { - return errdefs.IsInvalidArgument(err) -} - -// IsNotFound returns true if the error is due to a missing object -func IsNotFound(err error) bool { - return errdefs.IsNotFound(err) -} - -// IsAlreadyExists returns true if the error is due to an already existing -// metadata item -func IsAlreadyExists(err error) bool { - return errdefs.IsAlreadyExists(err) -} - -// IsFailedPrecondition returns true if an operation could not proceed to the -// lack of a particular condition -func IsFailedPrecondition(err error) bool { - return errdefs.IsFailedPrecondition(err) -} - -// IsUnavailable returns true if the error is due to a resource being unavailable -func IsUnavailable(err error) bool { - return errdefs.IsUnavailable(err) -} - -// IsNotImplemented returns true if the error is due to not being implemented -func IsNotImplemented(err error) bool { - return errdefs.IsNotImplemented(err) -} - -// IsCanceled returns true if the error is due to `context.Canceled`. -func IsCanceled(err error) bool { - return errdefs.IsCanceled(err) -} - -// IsDeadlineExceeded returns true if the error is due to -// `context.DeadlineExceeded`. -func IsDeadlineExceeded(err error) bool { - return errdefs.IsDeadlineExceeded(err) -} - -// ToGRPC will attempt to map the backend containerd error into a grpc error, -// using the original error message as a description. -// -// Further information may be extracted from certain errors depending on their -// type. -// -// If the error is unmapped, the original error will be returned to be handled -// by the regular grpc error handling stack. -func ToGRPC(err error) error { - return errdefs.ToGRPC(err) -} - -// ToGRPCf maps the error to grpc error codes, assembling the formatting string -// and combining it with the target error string. -// -// This is equivalent to errdefs.ToGRPC(fmt.Errorf("%s: %w", fmt.Sprintf(format, args...), err)) -func ToGRPCf(err error, format string, args ...interface{}) error { - return errdefs.ToGRPCf(err, format, args...) -} - -// FromGRPC returns the underlying error from a grpc service based on the grpc error code -func FromGRPC(err error) error { - return errdefs.FromGRPC(err) -} diff --git a/vendor/github.com/containerd/errdefs/errors.go b/errdefs/errors.go similarity index 100% rename from vendor/github.com/containerd/errdefs/errors.go rename to errdefs/errors.go diff --git a/vendor/github.com/containerd/errdefs/grpc.go b/errdefs/grpc.go similarity index 100% rename from vendor/github.com/containerd/errdefs/grpc.go rename to errdefs/grpc.go diff --git a/errdefs/grpc_test.go b/errdefs/grpc_test.go new file mode 100644 index 000000000000..8c69a408abf2 --- /dev/null +++ b/errdefs/grpc_test.go @@ -0,0 +1,103 @@ +/* + 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 errdefs + +import ( + "context" + "errors" + "fmt" + "testing" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestGRPCRoundTrip(t *testing.T) { + errShouldLeaveAlone := errors.New("unknown to package") + + for _, testcase := range []struct { + input error + cause error + str string + }{ + { + input: ErrAlreadyExists, + cause: ErrAlreadyExists, + }, + { + input: ErrNotFound, + cause: ErrNotFound, + }, + //nolint:dupword + { + input: fmt.Errorf("test test test: %w", ErrFailedPrecondition), + cause: ErrFailedPrecondition, + str: "test test test: failed precondition", + }, + { + input: status.Errorf(codes.Unavailable, "should be not available"), + cause: ErrUnavailable, + str: "should be not available: unavailable", + }, + { + input: errShouldLeaveAlone, + cause: ErrUnknown, + str: errShouldLeaveAlone.Error() + ": " + ErrUnknown.Error(), + }, + { + input: context.Canceled, + cause: context.Canceled, + str: "context canceled", + }, + { + input: fmt.Errorf("this is a test cancel: %w", context.Canceled), + cause: context.Canceled, + str: "this is a test cancel: context canceled", + }, + { + input: context.DeadlineExceeded, + cause: context.DeadlineExceeded, + str: "context deadline exceeded", + }, + { + input: fmt.Errorf("this is a test deadline exceeded: %w", context.DeadlineExceeded), + cause: context.DeadlineExceeded, + str: "this is a test deadline exceeded: context deadline exceeded", + }, + } { + t.Run(testcase.input.Error(), func(t *testing.T) { + t.Logf("input: %v", testcase.input) + gerr := ToGRPC(testcase.input) + t.Logf("grpc: %v", gerr) + ferr := FromGRPC(gerr) + t.Logf("recovered: %v", ferr) + + if !errors.Is(ferr, testcase.cause) { + t.Fatalf("unexpected cause: !errors.Is(%v, %v)", ferr, testcase.cause) + } + + expected := testcase.str + if expected == "" { + expected = testcase.cause.Error() + } + if ferr.Error() != expected { + t.Fatalf("unexpected string: %q != %q", ferr.Error(), expected) + } + }) + } + +} diff --git a/go.mod b/go.mod index a12092d07279..e1a1ba46b2e0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/containerd/console v1.0.3 github.com/containerd/containerd/api v1.7.19 github.com/containerd/continuity v0.4.2 - github.com/containerd/errdefs v0.1.0 github.com/containerd/fifo v1.1.0 github.com/containerd/go-cni v1.1.9 github.com/containerd/go-runc v1.0.0 diff --git a/go.sum b/go.sum index 044d37b41889..6942f5474bb7 100644 --- a/go.sum +++ b/go.sum @@ -171,8 +171,6 @@ github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= -github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= diff --git a/integration/client/go.mod b/integration/client/go.mod index 3e6fb6884331..abca0ff5f2d3 100644 --- a/integration/client/go.mod +++ b/integration/client/go.mod @@ -32,7 +32,6 @@ require ( github.com/cilium/ebpf v0.9.1 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/containerd/console v1.0.3 // indirect - github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/fifo v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/integration/client/go.sum b/integration/client/go.sum index 3da14962123b..aba064628990 100644 --- a/integration/client/go.sum +++ b/integration/client/go.sum @@ -1304,8 +1304,6 @@ github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EX github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= -github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= github.com/containerd/fifo v1.0.0/go.mod h1:ocF/ME1SX5b1AOlWi9r677YJmCPSwwWnQ9O123vzpE4= github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY= github.com/containerd/fifo v1.1.0/go.mod h1:bmC4NWMbXlt2EZ0Hc7Fx7QzTFxgPID13eH0Qu+MAb2o= diff --git a/vendor/github.com/containerd/errdefs/LICENSE b/vendor/github.com/containerd/errdefs/LICENSE deleted file mode 100644 index 584149b6ee28..000000000000 --- a/vendor/github.com/containerd/errdefs/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/errdefs/README.md b/vendor/github.com/containerd/errdefs/README.md deleted file mode 100644 index bd418c63f98c..000000000000 --- a/vendor/github.com/containerd/errdefs/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# errdefs - -A Go package for defining and checking common containerd errors. - -## Project details - -**errdefs** is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE). -As a containerd sub-project, you will find the: - * [Project governance](https://github.com/containerd/project/blob/main/GOVERNANCE.md), - * [Maintainers](https://github.com/containerd/project/blob/main/MAINTAINERS), - * and [Contributing guidelines](https://github.com/containerd/project/blob/main/CONTRIBUTING.md) - -information in our [`containerd/project`](https://github.com/containerd/project) repository. diff --git a/vendor/modules.txt b/vendor/modules.txt index 959f6dafa3f5..1ae120e379e7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -137,9 +137,6 @@ github.com/containerd/continuity/proto github.com/containerd/continuity/sysx github.com/containerd/continuity/testutil github.com/containerd/continuity/testutil/loopback -# github.com/containerd/errdefs v0.1.0 -## explicit; go 1.20 -github.com/containerd/errdefs # github.com/containerd/fifo v1.1.0 ## explicit; go 1.18 github.com/containerd/fifo From 18403239e8cf0c040d28bf98e434198fd4852f88 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 19 Sep 2024 22:23:26 -0700 Subject: [PATCH 6/6] Synchronize 1.7 error package with errdefs Since errdefs has been updated to also rely on interface compatibility, there is no need to have a breaking errdefs package change in 1.7. Signed-off-by: Derek McGowan --- errdefs/errors.go | 409 ++++++++++++++++++++++++++++++++++++++--- errdefs/errors_test.go | 205 +++++++++++++++++++++ 2 files changed, 585 insertions(+), 29 deletions(-) create mode 100644 errdefs/errors_test.go diff --git a/errdefs/errors.go b/errdefs/errors.go index 876225597082..f654d1964960 100644 --- a/errdefs/errors.go +++ b/errdefs/errors.go @@ -21,9 +21,6 @@ // // To detect an error class, use the IsXXX functions to tell whether an error // is of a certain type. -// -// The functions ToGRPC and FromGRPC can be used to map server-side and -// client-side errors to the correct types. package errdefs import ( @@ -36,57 +33,411 @@ import ( // Packages should return errors of these types when they want to instruct a // client to take a particular action. // -// For the most part, we just try to provide local grpc errors. Most conditions -// map very well to those defined by grpc. +// These errors map closely to grpc errors. var ( - ErrUnknown = errors.New("unknown") // used internally to represent a missed mapping. - ErrInvalidArgument = errors.New("invalid argument") - ErrNotFound = errors.New("not found") - ErrAlreadyExists = errors.New("already exists") - ErrFailedPrecondition = errors.New("failed precondition") - ErrUnavailable = errors.New("unavailable") - ErrNotImplemented = errors.New("not implemented") // represents not supported and unimplemented + ErrUnknown = errUnknown{} + ErrInvalidArgument = errInvalidArgument{} + ErrNotFound = errNotFound{} + ErrAlreadyExists = errAlreadyExists{} + ErrPermissionDenied = errPermissionDenied{} + ErrResourceExhausted = errResourceExhausted{} + ErrFailedPrecondition = errFailedPrecondition{} + ErrConflict = errConflict{} + ErrNotModified = errNotModified{} + ErrAborted = errAborted{} + ErrOutOfRange = errOutOfRange{} + ErrNotImplemented = errNotImplemented{} + ErrInternal = errInternal{} + ErrUnavailable = errUnavailable{} + ErrDataLoss = errDataLoss{} + ErrUnauthenticated = errUnauthorized{} ) +// cancelled maps to Moby's "ErrCancelled" +type cancelled interface { + Cancelled() +} + +// IsCanceled returns true if the error is due to `context.Canceled`. +func IsCanceled(err error) bool { + return errors.Is(err, context.Canceled) || isInterface[cancelled](err) +} + +type errUnknown struct{} + +func (errUnknown) Error() string { return "unknown" } + +func (errUnknown) Unknown() {} + +func (e errUnknown) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// unknown maps to Moby's "ErrUnknown" +type unknown interface { + Unknown() +} + +// IsUnknown returns true if the error is due to an unknown error, +// unhandled condition or unexpected response. +func IsUnknown(err error) bool { + return errors.Is(err, errUnknown{}) || isInterface[unknown](err) +} + +type errInvalidArgument struct{} + +func (errInvalidArgument) Error() string { return "invalid argument" } + +func (errInvalidArgument) InvalidParameter() {} + +func (e errInvalidArgument) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// invalidParameter maps to Moby's "ErrInvalidParameter" +type invalidParameter interface { + InvalidParameter() +} + // IsInvalidArgument returns true if the error is due to an invalid argument func IsInvalidArgument(err error) bool { - return errors.Is(err, ErrInvalidArgument) + return errors.Is(err, ErrInvalidArgument) || isInterface[invalidParameter](err) +} + +// deadlineExceed maps to Moby's "ErrDeadline" +type deadlineExceeded interface { + DeadlineExceeded() +} + +// IsDeadlineExceeded returns true if the error is due to +// `context.DeadlineExceeded`. +func IsDeadlineExceeded(err error) bool { + return errors.Is(err, context.DeadlineExceeded) || isInterface[deadlineExceeded](err) +} + +type errNotFound struct{} + +func (errNotFound) Error() string { return "not found" } + +func (errNotFound) NotFound() {} + +func (e errNotFound) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// notFound maps to Moby's "ErrNotFound" +type notFound interface { + NotFound() } // IsNotFound returns true if the error is due to a missing object func IsNotFound(err error) bool { - return errors.Is(err, ErrNotFound) + return errors.Is(err, ErrNotFound) || isInterface[notFound](err) +} + +type errAlreadyExists struct{} + +func (errAlreadyExists) Error() string { return "already exists" } + +func (errAlreadyExists) AlreadyExists() {} + +func (e errAlreadyExists) WithMessage(msg string) error { + return customMessage{e, msg} +} + +type alreadyExists interface { + AlreadyExists() } // IsAlreadyExists returns true if the error is due to an already existing // metadata item func IsAlreadyExists(err error) bool { - return errors.Is(err, ErrAlreadyExists) + return errors.Is(err, ErrAlreadyExists) || isInterface[alreadyExists](err) +} + +type errPermissionDenied struct{} + +func (errPermissionDenied) Error() string { return "permission denied" } + +func (errPermissionDenied) Forbidden() {} + +func (e errPermissionDenied) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// forbidden maps to Moby's "ErrForbidden" +type forbidden interface { + Forbidden() +} + +// IsPermissionDenied returns true if the error is due to permission denied +// or forbidden (403) response +func IsPermissionDenied(err error) bool { + return errors.Is(err, ErrPermissionDenied) || isInterface[forbidden](err) +} + +type errResourceExhausted struct{} + +func (errResourceExhausted) Error() string { return "resource exhausted" } + +func (errResourceExhausted) ResourceExhausted() {} + +func (e errResourceExhausted) WithMessage(msg string) error { + return customMessage{e, msg} +} + +type resourceExhausted interface { + ResourceExhausted() +} + +// IsResourceExhausted returns true if the error is due to +// a lack of resources or too many attempts. +func IsResourceExhausted(err error) bool { + return errors.Is(err, errResourceExhausted{}) || isInterface[resourceExhausted](err) +} + +type errFailedPrecondition struct{} + +func (e errFailedPrecondition) Error() string { return "failed precondition" } + +func (errFailedPrecondition) FailedPrecondition() {} + +func (e errFailedPrecondition) WithMessage(msg string) error { + return customMessage{e, msg} +} + +type failedPrecondition interface { + FailedPrecondition() } -// IsFailedPrecondition returns true if an operation could not proceed to the -// lack of a particular condition +// IsFailedPrecondition returns true if an operation could not proceed due to +// the lack of a particular condition func IsFailedPrecondition(err error) bool { - return errors.Is(err, ErrFailedPrecondition) + return errors.Is(err, errFailedPrecondition{}) || isInterface[failedPrecondition](err) } -// IsUnavailable returns true if the error is due to a resource being unavailable -func IsUnavailable(err error) bool { - return errors.Is(err, ErrUnavailable) +type errConflict struct{} + +func (errConflict) Error() string { return "conflict" } + +func (errConflict) Conflict() {} + +func (e errConflict) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// conflict maps to Moby's "ErrConflict" +type conflict interface { + Conflict() +} + +// IsConflict returns true if an operation could not proceed due to +// a conflict. +func IsConflict(err error) bool { + return errors.Is(err, errConflict{}) || isInterface[conflict](err) +} + +type errNotModified struct{} + +func (errNotModified) Error() string { return "not modified" } + +func (errNotModified) NotModified() {} + +func (e errNotModified) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// notModified maps to Moby's "ErrNotModified" +type notModified interface { + NotModified() +} + +// IsNotModified returns true if an operation could not proceed due +// to an object not modified from a previous state. +func IsNotModified(err error) bool { + return errors.Is(err, errNotModified{}) || isInterface[notModified](err) +} + +type errAborted struct{} + +func (errAborted) Error() string { return "aborted" } + +func (errAborted) Aborted() {} + +func (e errAborted) WithMessage(msg string) error { + return customMessage{e, msg} +} + +type aborted interface { + Aborted() +} + +// IsAborted returns true if an operation was aborted. +func IsAborted(err error) bool { + return errors.Is(err, errAborted{}) || isInterface[aborted](err) +} + +type errOutOfRange struct{} + +func (errOutOfRange) Error() string { return "out of range" } + +func (errOutOfRange) OutOfRange() {} + +func (e errOutOfRange) WithMessage(msg string) error { + return customMessage{e, msg} +} + +type outOfRange interface { + OutOfRange() +} + +// IsOutOfRange returns true if an operation could not proceed due +// to data being out of the expected range. +func IsOutOfRange(err error) bool { + return errors.Is(err, errOutOfRange{}) || isInterface[outOfRange](err) +} + +type errNotImplemented struct{} + +func (errNotImplemented) Error() string { return "not implemented" } + +func (errNotImplemented) NotImplemented() {} + +func (e errNotImplemented) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// notImplemented maps to Moby's "ErrNotImplemented" +type notImplemented interface { + NotImplemented() } // IsNotImplemented returns true if the error is due to not being implemented func IsNotImplemented(err error) bool { - return errors.Is(err, ErrNotImplemented) + return errors.Is(err, errNotImplemented{}) || isInterface[notImplemented](err) } -// IsCanceled returns true if the error is due to `context.Canceled`. -func IsCanceled(err error) bool { - return errors.Is(err, context.Canceled) +type errInternal struct{} + +func (errInternal) Error() string { return "internal" } + +func (errInternal) System() {} + +func (e errInternal) WithMessage(msg string) error { + return customMessage{e, msg} } -// IsDeadlineExceeded returns true if the error is due to -// `context.DeadlineExceeded`. -func IsDeadlineExceeded(err error) bool { - return errors.Is(err, context.DeadlineExceeded) +// system maps to Moby's "ErrSystem" +type system interface { + System() +} + +// IsInternal returns true if the error returns to an internal or system error +func IsInternal(err error) bool { + return errors.Is(err, errInternal{}) || isInterface[system](err) +} + +type errUnavailable struct{} + +func (errUnavailable) Error() string { return "unavailable" } + +func (errUnavailable) Unavailable() {} + +func (e errUnavailable) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// unavailable maps to Moby's "ErrUnavailable" +type unavailable interface { + Unavailable() +} + +// IsUnavailable returns true if the error is due to a resource being unavailable +func IsUnavailable(err error) bool { + return errors.Is(err, errUnavailable{}) || isInterface[unavailable](err) +} + +type errDataLoss struct{} + +func (errDataLoss) Error() string { return "data loss" } + +func (errDataLoss) DataLoss() {} + +func (e errDataLoss) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// dataLoss maps to Moby's "ErrDataLoss" +type dataLoss interface { + DataLoss() +} + +// IsDataLoss returns true if data during an operation was lost or corrupted +func IsDataLoss(err error) bool { + return errors.Is(err, errDataLoss{}) || isInterface[dataLoss](err) +} + +type errUnauthorized struct{} + +func (errUnauthorized) Error() string { return "unauthorized" } + +func (errUnauthorized) Unauthorized() {} + +func (e errUnauthorized) WithMessage(msg string) error { + return customMessage{e, msg} +} + +// unauthorized maps to Moby's "ErrUnauthorized" +type unauthorized interface { + Unauthorized() +} + +// IsUnauthorized returns true if the error indicates that the user was +// unauthenticated or unauthorized. +func IsUnauthorized(err error) bool { + return errors.Is(err, errUnauthorized{}) || isInterface[unauthorized](err) +} + +func isInterface[T any](err error) bool { + for { + switch x := err.(type) { + case T: + return true + case customMessage: + err = x.err + case interface{ Unwrap() error }: + err = x.Unwrap() + if err == nil { + return false + } + case interface{ Unwrap() []error }: + for _, err := range x.Unwrap() { + if isInterface[T](err) { + return true + } + } + return false + default: + return false + } + } +} + +// customMessage is used to provide a defined error with a custom message. +// The message is not wrapped but can be compared by the `Is(error) bool` interface. +type customMessage struct { + err error + msg string +} + +func (c customMessage) Is(err error) bool { + return c.err == err +} + +func (c customMessage) As(target any) bool { + return errors.As(c.err, target) +} + +func (c customMessage) Error() string { + return c.msg } diff --git a/errdefs/errors_test.go b/errdefs/errors_test.go new file mode 100644 index 000000000000..d4cb0d94ab89 --- /dev/null +++ b/errdefs/errors_test.go @@ -0,0 +1,205 @@ +/* + 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 errdefs + +import ( + "context" + "errors" + "fmt" + "reflect" + "testing" +) + +func TestInvalidArgument(t *testing.T) { + for _, match := range []error{ + ErrInvalidArgument, + &errInvalidArgument{}, + &customInvalidArgument{}, + &wrappedInvalidArgument{errors.New("invalid parameter")}, + } { + if !IsInvalidArgument(match) { + t.Errorf("error did not match invalid argument: %#v", match) + } + } + for _, nonMatch := range []error{ + ErrUnknown, + context.Canceled, + errors.New("invalid argument"), + } { + if IsInvalidArgument(nonMatch) { + t.Errorf("error unexpectedly matched invalid argument: %#v", nonMatch) + } + } +} + +func TestErrorEquivalence(t *testing.T) { + var e1 error = ErrAborted + var e2 error = ErrUnknown + if e1 == e2 { + t.Fatal("should not equal the same error") + } + if errors.Is(e1, e2) { + t.Fatal("errors.Is should not return true") + } + + var e3 error = errAborted{} + if e1 != e3 { + t.Fatal("new instance should be equivalent") + } + if !errors.Is(e1, e3) { + t.Fatal("errors.Is should be true") + } + if !errors.Is(e3, e1) { + t.Fatal("errors.Is should be true") + } + var aborted errAborted + if !errors.As(e1, &aborted) { + t.Fatal("errors.As should be true") + } + + var e4 = ErrAborted.WithMessage("custom message") + if e1 == e4 { + t.Fatal("should not equal the same error") + } + + if !errors.Is(e4, e1) { + t.Fatal("errors.Is should be true, e1 is in the tree of e4") + } + + if errors.Is(e1, e4) { + t.Fatal("errors.Is should be false, e1 is not a custom message") + } + + if !errors.As(e4, &aborted) { + t.Fatal("errors.As should be true") + } + + var custom customMessage + if !errors.As(e4, &custom) { + t.Fatal("errors.As should be true") + } + if custom.msg != "custom message" { + t.Fatalf("unexpected custom message: %q", custom.msg) + } + if custom.err != e1 { + t.Fatalf("unexpected custom message error: %v", custom.err) + } +} + +func TestWithMessage(t *testing.T) { + testErrors := []error{ErrUnknown, + ErrInvalidArgument, + ErrNotFound, + ErrAlreadyExists, + ErrPermissionDenied, + ErrResourceExhausted, + ErrFailedPrecondition, + ErrConflict, + ErrNotModified, + ErrAborted, + ErrOutOfRange, + ErrNotImplemented, + ErrInternal, + ErrUnavailable, + ErrDataLoss, + ErrUnauthenticated, + } + for _, err := range testErrors { + e1 := err + t.Run(err.Error(), func(t *testing.T) { + wm, ok := e1.(interface{ WithMessage(string) error }) + if !ok { + t.Fatal("WithMessage not supported") + } + e2 := wm.WithMessage("custom message") + + if e1 == e2 { + t.Fatal("should not equal the same error") + } + + if !errors.Is(e2, e1) { + t.Fatal("errors.Is should return true") + } + + if errors.Is(e1, e2) { + t.Fatal("errors.Is should be false, e1 is not a custom message") + } + + var raw = reflect.New(reflect.TypeOf(e1)).Interface() + if !errors.As(e2, raw) { + t.Fatal("errors.As should be true") + } + + var custom customMessage + if !errors.As(e2, &custom) { + t.Fatal("errors.As should be true") + } + if custom.msg != "custom message" { + t.Fatalf("unexpected custom message: %q", custom.msg) + } + if custom.err != e1 { + t.Fatalf("unexpected custom message error: %v", custom.err) + } + + }) + } +} + +func TestInterfaceMatch(t *testing.T) { + testCases := []struct { + err error + check func(error) bool + }{ + {ErrUnknown, isInterface[unknown]}, + {ErrInvalidArgument, isInterface[invalidParameter]}, + {ErrNotFound, isInterface[notFound]}, + {ErrAlreadyExists, isInterface[alreadyExists]}, + {ErrPermissionDenied, isInterface[forbidden]}, + {ErrResourceExhausted, isInterface[resourceExhausted]}, + {ErrFailedPrecondition, isInterface[failedPrecondition]}, + {ErrConflict, isInterface[conflict]}, + {ErrNotModified, isInterface[notModified]}, + {ErrAborted, isInterface[aborted]}, + {ErrOutOfRange, isInterface[outOfRange]}, + {ErrNotImplemented, isInterface[notImplemented]}, + {ErrInternal, isInterface[system]}, + {ErrUnavailable, isInterface[unavailable]}, + {ErrDataLoss, isInterface[dataLoss]}, + {ErrUnauthenticated, isInterface[unauthorized]}, + } + + for _, tc := range testCases { + tc := tc + t.Run(fmt.Sprintf("%T", tc.err), func(t *testing.T) { + if !tc.check(tc.err) { + t.Fatal("Error does not match interface") + } + }) + } +} + +type customInvalidArgument struct{} + +func (*customInvalidArgument) Error() string { + return "my own invalid argument" +} + +func (*customInvalidArgument) InvalidParameter() {} + +type wrappedInvalidArgument struct{ error } + +func (*wrappedInvalidArgument) InvalidParameter() {}