deps: upgrade to go-set/v2 (#18638)

No functional changes, just cleaning up deprecated usages that are
removed in v2 and replace one call of .Slice with .ForEach to avoid
making the intermediate copy.
This commit is contained in:
Seth Hoenig
2023-10-05 11:56:17 -05:00
committed by GitHub
parent 533f293fa8
commit e3c8700ded
53 changed files with 93 additions and 86 deletions

View File

@@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/helper"
"github.com/posener/complete"
@@ -182,10 +182,10 @@ func (c *ACLTokenCreateCommand) Run(args []string) int {
func generateACLTokenRoleLinks(roleNames, roleIDs []string) []*api.ACLTokenRoleLink {
var tokenLinks []*api.ACLTokenRoleLink
roleNameSet := set.From[string](roleNames).List()
roleNameSet := set.From[string](roleNames).Slice()
roleNameFn := func(name string) *api.ACLTokenRoleLink { return &api.ACLTokenRoleLink{Name: name} }
roleIDsSet := set.From[string](roleIDs).List()
roleIDsSet := set.From[string](roleIDs).Slice()
roleIDFn := func(id string) *api.ACLTokenRoleLink { return &api.ACLTokenRoleLink{ID: id} }
tokenLinks = append(tokenLinks, helper.ConvertSlice(roleNameSet, roleNameFn)...)

View File

@@ -21,7 +21,7 @@ import (
"github.com/armon/go-metrics"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/client/serviceregistration"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/envoy"

View File

@@ -18,7 +18,7 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/dustin/go-humanize/english"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/posener/complete"

View File

@@ -18,7 +18,7 @@ import (
"time"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/command/agent"

View File

@@ -7,7 +7,7 @@ import (
"fmt"
"strings"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/mitchellh/cli"

View File

@@ -7,7 +7,7 @@ import (
"fmt"
"strings"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/posener/complete"
)

View File

@@ -7,7 +7,7 @@ import (
"regexp"
"testing"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/mitchellh/cli"

View File

@@ -15,7 +15,7 @@ import (
"strings"
multierror "github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-set"
"github.com/hashicorp/go-set/v2"
"github.com/hashicorp/hcl"
"github.com/hashicorp/hcl/hcl/ast"
"github.com/hashicorp/nomad/api"
@@ -581,10 +581,12 @@ func formatInvalidVarKeyChars(invalid []string) string {
// Sort the characters for output
charList := make([]string, 0, chars.Size())
for _, k := range chars.List() {
chars.ForEach(func(k string) bool {
// Use %s instead of %q to avoid escaping characters.
charList = append(charList, fmt.Sprintf(`"%s"`, k))
}
return true
})
slices.Sort(charList)
// Build string