cleanup more helper updates (#14638)

* cleanup: refactor MapStringStringSliceValueSet to be cleaner

* cleanup: replace SliceStringToSet with actual set

* cleanup: replace SliceStringSubset with real set

* cleanup: replace SliceStringContains with slices.Contains

* cleanup: remove unused function SliceStringHasPrefix

* cleanup: fixup StringHasPrefixInSlice doc string

* cleanup: refactor SliceSetDisjoint to use real set

* cleanup: replace CompareSliceSetString with SliceSetEq

* cleanup: replace CompareMapStringString with maps.Equal

* cleanup: replace CopyMapStringString with CopyMap

* cleanup: replace CopyMapStringInterface with CopyMap

* cleanup: fixup more CopyMapStringString and CopyMapStringInt

* cleanup: replace CopySliceString with slices.Clone

* cleanup: remove unused CopySliceInt

* cleanup: refactor CopyMapStringSliceString to be generic as CopyMapOfSlice

* cleanup: replace CopyMap with maps.Clone

* cleanup: run go mod tidy
This commit is contained in:
Seth Hoenig
2022-09-21 14:53:25 -05:00
committed by GitHub
parent 9e0987a86c
commit ff1a30fe8d
42 changed files with 239 additions and 529 deletions

View File

@@ -30,6 +30,8 @@ import (
"github.com/hashicorp/nomad/helper/escapingfs"
"github.com/hashicorp/nomad/version"
"github.com/posener/complete"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
type OperatorDebugCommand struct {
@@ -334,7 +336,7 @@ func ServerPredictor(factory ApiClientFactory) complete.Predictor {
func (c *OperatorDebugCommand) queryOpts() *api.QueryOptions {
qo := new(api.QueryOptions)
*qo = *c.opts
qo.Params = helper.CopyMapStringString(c.opts.Params)
qo.Params = maps.Clone(c.opts.Params)
return qo
}
@@ -1527,7 +1529,7 @@ func filterServerMembers(serverMembers *api.ServerMembers, serverIDs string, reg
// "leader" is a special case which Nomad handles in the API. If "leader"
// appears in serverIDs, add it to membersFound and remove it from the list
// so that it isn't processed by the range loop
if helper.SliceStringContains(prefixes, "leader") {
if slices.Contains(prefixes, "leader") {
membersFound = append(membersFound, "leader")
helper.RemoveEqualFold(&prefixes, "leader")
}