From c69a9586c5da5253927a405c346033fa491a91d0 Mon Sep 17 00:00:00 2001 From: Jonny Stoten Date: Wed, 8 May 2024 10:28:19 +0100 Subject: [PATCH] Remove string contains func (it's in the stdlib) --- internal/util/strings.go | 10 ---------- pkg/policy/policy.go | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 internal/util/strings.go diff --git a/internal/util/strings.go b/internal/util/strings.go deleted file mode 100644 index b0320b9..0000000 --- a/internal/util/strings.go +++ /dev/null @@ -1,10 +0,0 @@ -package util - -func StringInSlice(str string, list []string) bool { - for _, v := range list { - if v == str { - return true - } - } - return false -} diff --git a/pkg/policy/policy.go b/pkg/policy/policy.go index ceb8de3..f45ecf7 100644 --- a/pkg/policy/policy.go +++ b/pkg/policy/policy.go @@ -6,10 +6,10 @@ import ( "os" "path" "path/filepath" + "slices" "strings" "github.com/distribution/reference" - "github.com/docker/attest/internal/util" "github.com/docker/attest/pkg/oci" "github.com/docker/attest/pkg/tuf" @@ -148,7 +148,7 @@ func findPolicyMatch(named reference.Named, mappings *PolicyMappings) (*PolicyMa } // now search mirrors for _, mirror := range mappings.Mirrors { - if util.StringInSlice(reference.Domain(named), mirror.Mirror.Domains) && + if slices.Contains(mirror.Mirror.Domains, reference.Domain(named)) && strings.HasPrefix(reference.Path(named), mirror.Mirror.Prefix) { for _, mapping := range mappings.Policies { if mapping.Name == mirror.Name {