From 83dbbc3a512e5fc3d854acb589e1fd4c3a2b9acc Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 23 Apr 2024 11:16:40 +0200 Subject: [PATCH] Replace golang.org/x/exp/slices with slices from std Use "slices" from the standard library, this package was added in go 1.21 so we can use it now. Signed-off-by: Paul Holzinger --- cmd/podman/containers/create.go | 2 +- cmd/podman/containers/ps.go | 2 +- cmd/podman/farm/create.go | 2 +- cmd/podman/farm/update.go | 2 +- cmd/podman/images/save.go | 2 +- cmd/podman/images/trust_set.go | 2 +- cmd/podman/system/connection/list.go | 2 +- cmd/podman/system/connection/remove.go | 2 +- libpod/container_internal.go | 2 +- libpod/container_internal_common.go | 2 +- libpod/container_top_linux.go | 2 +- libpod/kube.go | 2 +- libpod/networking_common.go | 2 +- libpod/runtime_ctr.go | 2 +- libpod/runtime_pod.go | 2 +- pkg/bindings/manifests/manifests.go | 2 +- pkg/bindings/test/networks_test.go | 2 +- pkg/bindings/test/pods_test.go | 2 +- pkg/bindings/test/volumes_test.go | 2 +- pkg/domain/filters/containers.go | 2 +- pkg/domain/filters/pods.go | 2 +- pkg/domain/infra/abi/images_list.go | 2 +- pkg/domain/infra/abi/manifest.go | 5 ++--- pkg/domain/infra/abi/network.go | 2 +- pkg/domain/infra/tunnel/manifest.go | 2 +- pkg/machine/e2e/config_test.go | 2 +- pkg/machine/e2e/list_test.go | 2 +- pkg/specgen/container_validate.go | 2 +- pkg/specgen/generate/kube/kube.go | 2 +- pkg/specgen/generate/ports.go | 2 +- pkg/specgen/generate/security_linux.go | 2 +- pkg/specgen/namespaces.go | 2 +- test/e2e/common_test.go | 2 +- 33 files changed, 34 insertions(+), 35 deletions(-) diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index 48eace09e0..5edeb2afac 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "slices" "strconv" "strings" @@ -23,7 +24,6 @@ import ( "github.com/containers/podman/v5/pkg/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "golang.org/x/exp/slices" "golang.org/x/term" ) diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index 5741288ebb..c247adf68e 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "slices" "strconv" "strings" "time" @@ -20,7 +21,6 @@ import ( "github.com/docker/go-units" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/cmd/podman/farm/create.go b/cmd/podman/farm/create.go index 6e7c493797..a0171c860e 100644 --- a/cmd/podman/farm/create.go +++ b/cmd/podman/farm/create.go @@ -2,13 +2,13 @@ package farm import ( "fmt" + "slices" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" "github.com/containers/podman/v5/cmd/podman/registry" "github.com/containers/podman/v5/cmd/podman/validate" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/cmd/podman/farm/update.go b/cmd/podman/farm/update.go index aecdf00aeb..66ced176c2 100644 --- a/cmd/podman/farm/update.go +++ b/cmd/podman/farm/update.go @@ -3,6 +3,7 @@ package farm import ( "errors" "fmt" + "slices" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" @@ -10,7 +11,6 @@ import ( "github.com/containers/podman/v5/cmd/podman/registry" "github.com/containers/podman/v5/cmd/podman/validate" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go index 529b050530..9124fc43cf 100644 --- a/cmd/podman/images/save.go +++ b/cmd/podman/images/save.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "slices" "strings" "github.com/containers/common/pkg/completion" @@ -14,7 +15,6 @@ import ( "github.com/containers/podman/v5/libpod/define" "github.com/containers/podman/v5/pkg/domain/entities" "github.com/spf13/cobra" - "golang.org/x/exp/slices" "golang.org/x/term" ) diff --git a/cmd/podman/images/trust_set.go b/cmd/podman/images/trust_set.go index a7acf21122..67ae1d32e0 100644 --- a/cmd/podman/images/trust_set.go +++ b/cmd/podman/images/trust_set.go @@ -4,13 +4,13 @@ import ( "fmt" "net/url" "regexp" + "slices" "github.com/containers/common/pkg/completion" "github.com/containers/podman/v5/cmd/podman/common" "github.com/containers/podman/v5/cmd/podman/registry" "github.com/containers/podman/v5/pkg/domain/entities" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/cmd/podman/system/connection/list.go b/cmd/podman/system/connection/list.go index 75dd8846df..24e6b29d29 100644 --- a/cmd/podman/system/connection/list.go +++ b/cmd/podman/system/connection/list.go @@ -3,6 +3,7 @@ package connection import ( "fmt" "os" + "slices" "sort" "github.com/containers/common/pkg/completion" @@ -13,7 +14,6 @@ import ( "github.com/containers/podman/v5/cmd/podman/system" "github.com/containers/podman/v5/cmd/podman/validate" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/cmd/podman/system/connection/remove.go b/cmd/podman/system/connection/remove.go index 75975b9a0b..225b1f038f 100644 --- a/cmd/podman/system/connection/remove.go +++ b/cmd/podman/system/connection/remove.go @@ -2,13 +2,13 @@ package connection import ( "errors" + "slices" "github.com/containers/common/pkg/config" "github.com/containers/podman/v5/cmd/podman/common" "github.com/containers/podman/v5/cmd/podman/registry" "github.com/containers/podman/v5/cmd/podman/system" "github.com/spf13/cobra" - "golang.org/x/exp/slices" ) var ( diff --git a/libpod/container_internal.go b/libpod/container_internal.go index fc0d001e9a..ffb060b92c 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -11,6 +11,7 @@ import ( "io/fs" "os" "path/filepath" + "slices" "strconv" "strings" "time" @@ -49,7 +50,6 @@ import ( "github.com/opencontainers/runtime-tools/generate" "github.com/opencontainers/selinux/go-selinux/label" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" "golang.org/x/sys/unix" ) diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index f0f6278536..2ec7c0040e 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -15,6 +15,7 @@ import ( "path" "path/filepath" "runtime" + "slices" "strconv" "strings" "syscall" @@ -57,7 +58,6 @@ import ( "github.com/opencontainers/selinux/go-selinux" "github.com/opencontainers/selinux/go-selinux/label" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" "golang.org/x/sys/unix" cdi "tags.cncf.io/container-device-interface/pkg/cdi" ) diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go index c1d78cd4e1..7dff973186 100644 --- a/libpod/container_top_linux.go +++ b/libpod/container_top_linux.go @@ -11,6 +11,7 @@ import ( "os/exec" "path/filepath" "runtime" + "slices" "strconv" "strings" "syscall" @@ -22,7 +23,6 @@ import ( "github.com/containers/storage/pkg/reexec" "github.com/google/shlex" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" "golang.org/x/sys/unix" ) diff --git a/libpod/kube.go b/libpod/kube.go index c040fef0c2..ca43aba5dc 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -9,6 +9,7 @@ import ( "math/rand" "os" "reflect" + "slices" "sort" "strconv" "strings" @@ -29,7 +30,6 @@ import ( "github.com/containers/podman/v5/pkg/util" "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) // GenerateForKube takes a slice of libpod containers and generates diff --git a/libpod/networking_common.go b/libpod/networking_common.go index 5756b71f13..6bd32a3d95 100644 --- a/libpod/networking_common.go +++ b/libpod/networking_common.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "regexp" + "slices" "sort" "github.com/containers/common/libnetwork/etchosts" @@ -18,7 +19,6 @@ import ( "github.com/containers/podman/v5/pkg/rootless" "github.com/containers/storage/pkg/lockfile" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) // convertPortMappings will remove the HostIP part from the ports when running inside podman machine. diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 664737ff6a..8770d572ee 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -10,6 +10,7 @@ import ( "os" "path" "path/filepath" + "slices" "strings" "time" @@ -30,7 +31,6 @@ import ( spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/generate" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) // Contains the public Runtime API for containers diff --git a/libpod/runtime_pod.go b/libpod/runtime_pod.go index 86b0780df2..086dba0bdb 100644 --- a/libpod/runtime_pod.go +++ b/libpod/runtime_pod.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" + "slices" "time" "github.com/containers/podman/v5/libpod/define" - "golang.org/x/exp/slices" ) // Contains the public Runtime API for pods diff --git a/pkg/bindings/manifests/manifests.go b/pkg/bindings/manifests/manifests.go index c77dceaf13..9ac41a85eb 100644 --- a/pkg/bindings/manifests/manifests.go +++ b/pkg/bindings/manifests/manifests.go @@ -11,6 +11,7 @@ import ( "net/textproto" "os" "path/filepath" + "slices" "strconv" "strings" "sync" @@ -25,7 +26,6 @@ import ( "github.com/containers/podman/v5/pkg/errorhandling" dockerAPI "github.com/docker/docker/api/types" jsoniter "github.com/json-iterator/go" - "golang.org/x/exp/slices" ) // Create creates a manifest for the given name. Optional images to be associated with diff --git a/pkg/bindings/test/networks_test.go b/pkg/bindings/test/networks_test.go index c7b61aee28..194bfaf40a 100644 --- a/pkg/bindings/test/networks_test.go +++ b/pkg/bindings/test/networks_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "slices" "time" "github.com/containers/common/libnetwork/types" @@ -13,7 +14,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" - "golang.org/x/exp/slices" ) var _ = Describe("Podman networks", func() { diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go index 9db33af529..f621379114 100644 --- a/pkg/bindings/test/pods_test.go +++ b/pkg/bindings/test/pods_test.go @@ -3,6 +3,7 @@ package bindings_test import ( "fmt" "net/http" + "slices" "strings" "time" @@ -16,7 +17,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" - "golang.org/x/exp/slices" ) var _ = Describe("Podman pods", func() { diff --git a/pkg/bindings/test/volumes_test.go b/pkg/bindings/test/volumes_test.go index 7fc64178b4..ce9a8ff92f 100644 --- a/pkg/bindings/test/volumes_test.go +++ b/pkg/bindings/test/volumes_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "slices" "time" "github.com/containers/podman/v5/pkg/bindings" @@ -14,7 +15,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" - "golang.org/x/exp/slices" ) var _ = Describe("Podman volumes", func() { diff --git a/pkg/domain/filters/containers.go b/pkg/domain/filters/containers.go index d69b46fa32..b4a683631c 100644 --- a/pkg/domain/filters/containers.go +++ b/pkg/domain/filters/containers.go @@ -5,6 +5,7 @@ package filters import ( "errors" "fmt" + "slices" "strconv" "strings" "time" @@ -13,7 +14,6 @@ import ( "github.com/containers/common/pkg/util" "github.com/containers/podman/v5/libpod" "github.com/containers/podman/v5/libpod/define" - "golang.org/x/exp/slices" ) // GenerateContainerFilterFuncs return ContainerFilter functions based of filter. diff --git a/pkg/domain/filters/pods.go b/pkg/domain/filters/pods.go index 3529f01276..c009028868 100644 --- a/pkg/domain/filters/pods.go +++ b/pkg/domain/filters/pods.go @@ -5,6 +5,7 @@ package filters import ( "errors" "fmt" + "slices" "strconv" "strings" @@ -12,7 +13,6 @@ import ( "github.com/containers/common/pkg/util" "github.com/containers/podman/v5/libpod" "github.com/containers/podman/v5/libpod/define" - "golang.org/x/exp/slices" ) // GeneratePodFilterFunc takes a filter and filtervalue (key, value) diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go index 47eeea4e37..6f6d575711 100644 --- a/pkg/domain/infra/abi/images_list.go +++ b/pkg/domain/infra/abi/images_list.go @@ -3,11 +3,11 @@ package abi import ( "context" "fmt" + "slices" "github.com/containers/common/libimage" "github.com/containers/podman/v5/libpod/define" "github.com/containers/podman/v5/pkg/domain/entities" - "golang.org/x/exp/slices" ) func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) { diff --git a/pkg/domain/infra/abi/manifest.go b/pkg/domain/infra/abi/manifest.go index db638e1ed9..144740ec88 100644 --- a/pkg/domain/infra/abi/manifest.go +++ b/pkg/domain/infra/abi/manifest.go @@ -4,13 +4,13 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" "os" "path" + "slices" "strings" - "errors" - "github.com/containers/common/libimage" cp "github.com/containers/image/v5/copy" "github.com/containers/image/v5/docker" @@ -26,7 +26,6 @@ import ( "github.com/opencontainers/go-digest" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) // ManifestCreate implements logic for creating manifest lists via ImageEngine diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go index 3db382448d..c39b9c600b 100644 --- a/pkg/domain/infra/abi/network.go +++ b/pkg/domain/infra/abi/network.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "slices" "strconv" "github.com/containers/common/libnetwork/pasta" @@ -12,7 +13,6 @@ import ( netutil "github.com/containers/common/libnetwork/util" "github.com/containers/podman/v5/libpod/define" "github.com/containers/podman/v5/pkg/domain/entities" - "golang.org/x/exp/slices" ) func (ic *ContainerEngine) NetworkUpdate(ctx context.Context, netName string, options entities.NetworkUpdateOptions) error { diff --git a/pkg/domain/infra/tunnel/manifest.go b/pkg/domain/infra/tunnel/manifest.go index e042364290..ac5aa2a6f1 100644 --- a/pkg/domain/infra/tunnel/manifest.go +++ b/pkg/domain/infra/tunnel/manifest.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "slices" "strings" "github.com/containers/image/v5/types" @@ -11,7 +12,6 @@ import ( "github.com/containers/podman/v5/pkg/bindings/manifests" "github.com/containers/podman/v5/pkg/domain/entities" envLib "github.com/containers/podman/v5/pkg/env" - "golang.org/x/exp/slices" ) // ManifestCreate implements manifest create via ImageEngine diff --git a/pkg/machine/e2e/config_test.go b/pkg/machine/e2e/config_test.go index 3a65417d3a..ddfeb16662 100644 --- a/pkg/machine/e2e/config_test.go +++ b/pkg/machine/e2e/config_test.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "path/filepath" + "slices" "strconv" "strings" "time" @@ -18,7 +19,6 @@ import ( "github.com/onsi/gomega/format" . "github.com/onsi/gomega/gexec" "github.com/onsi/gomega/types" - "golang.org/x/exp/slices" ) var originalHomeDir = os.Getenv("HOME") diff --git a/pkg/machine/e2e/list_test.go b/pkg/machine/e2e/list_test.go index 03a20ce554..fe6c48b100 100644 --- a/pkg/machine/e2e/list_test.go +++ b/pkg/machine/e2e/list_test.go @@ -1,6 +1,7 @@ package e2e_test import ( + "slices" "strconv" "strings" "time" @@ -10,7 +11,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" - "golang.org/x/exp/slices" ) var _ = Describe("podman machine list", func() { diff --git a/pkg/specgen/container_validate.go b/pkg/specgen/container_validate.go index f740719af4..251932590a 100644 --- a/pkg/specgen/container_validate.go +++ b/pkg/specgen/container_validate.go @@ -3,10 +3,10 @@ package specgen import ( "errors" "fmt" + "slices" "strings" "github.com/containers/podman/v5/libpod/define" - "golang.org/x/exp/slices" ) var ( diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index d3b8e3df89..ec5cc10420 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -12,6 +12,7 @@ import ( "os" "regexp" "runtime" + "slices" "strconv" "strings" "time" @@ -37,7 +38,6 @@ import ( "github.com/docker/go-units" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" "sigs.k8s.io/yaml" ) diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index 0218050e03..0575fc7c5e 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -5,6 +5,7 @@ package generate import ( "fmt" "net" + "slices" "sort" "strings" @@ -14,7 +15,6 @@ import ( "github.com/containers/podman/v5/pkg/specgenutil" "github.com/containers/podman/v5/utils" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) const ( diff --git a/pkg/specgen/generate/security_linux.go b/pkg/specgen/generate/security_linux.go index a04508586c..3a8076b464 100644 --- a/pkg/specgen/generate/security_linux.go +++ b/pkg/specgen/generate/security_linux.go @@ -4,6 +4,7 @@ package generate import ( "fmt" + "slices" "strings" "github.com/containers/common/libimage" @@ -17,7 +18,6 @@ import ( "github.com/opencontainers/runtime-tools/generate" "github.com/opencontainers/selinux/go-selinux/label" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" ) // setLabelOpts sets the label options of the SecurityConfig according to the diff --git a/pkg/specgen/namespaces.go b/pkg/specgen/namespaces.go index 8d4179dcec..f685ab3e8c 100644 --- a/pkg/specgen/namespaces.go +++ b/pkg/specgen/namespaces.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net" + "slices" "strings" "github.com/containers/common/libnetwork/types" @@ -16,7 +17,6 @@ import ( storageTypes "github.com/containers/storage/types" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/generate" - "golang.org/x/exp/slices" ) type NamespaceMode string diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 86e18dccb7..64a8891da9 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -12,6 +12,7 @@ import ( "os" "os/exec" "path/filepath" + "slices" "sort" "strconv" "strings" @@ -32,7 +33,6 @@ import ( . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" "github.com/sirupsen/logrus" - "golang.org/x/exp/slices" "golang.org/x/sys/unix" )