[dep] bump golang.org/x/exp (#18102)
There are some refactorings that have to be made in the getter and state where the api changed in `slices` * Bump golang.org/x/exp * Bump golang.org/x/exp in api * Update job_endpoint_test * [feedback] unexport sort function
This commit is contained in:
parent
9fda7305b7
commit
bac4d112d1
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/mitchellh/go-testing-interface v1.14.1
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/shoenig/test v0.6.6
|
||||
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a
|
||||
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
|
@ -36,8 +36,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a h1:tlXy25amD5A7gOfbXdqCGN5k8ESEed/Ee1E5RcrYnqU=
|
||||
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 h1:/yRP+0AN7mf5DkD3BAI6TOFnd51gEoDEb8o35jIFtgw=
|
||||
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
|
@ -109,13 +109,19 @@ func (p *parameters) Equal(o *parameters) bool {
|
|||
return false
|
||||
case p.TaskDir != o.TaskDir:
|
||||
return false
|
||||
case !maps.EqualFunc(p.Headers, o.Headers, slices.Equal[string]):
|
||||
case !maps.EqualFunc(p.Headers, o.Headers, headersCompareFn):
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func headersCompareFn(a []string, b []string) bool {
|
||||
slices.Sort(a)
|
||||
slices.Sort(b)
|
||||
return slices.Equal(a, b)
|
||||
}
|
||||
|
||||
const (
|
||||
// stop privilege escalation via setuid/setgid
|
||||
// https://github.com/hashicorp/nomad/issues/6176
|
||||
|
|
|
@ -135,6 +135,14 @@ func TestParameters_Equal_headers(t *testing.T) {
|
|||
// equal
|
||||
must.Equal(t, p1, p2)
|
||||
|
||||
// equal
|
||||
must.Equal(t, p1, ¶meters{
|
||||
Headers: map[string][]string{
|
||||
"West": {"California"},
|
||||
"East": {"Florida", "New York"},
|
||||
},
|
||||
})
|
||||
|
||||
// not equal
|
||||
p2.Headers["East"] = []string{"New York"}
|
||||
must.NotEqual(t, p1, p2)
|
||||
|
|
|
@ -267,8 +267,22 @@ func TestJobEndpoint_Register_NonOverlapping(t *testing.T) {
|
|||
return false, fmt.Errorf("expected 2 allocs but found %d:\n%v", n, allocResp.Allocations)
|
||||
}
|
||||
|
||||
slices.SortFunc(allocResp.Allocations, func(a, b *structs.AllocListStub) bool {
|
||||
return a.CreateIndex < b.CreateIndex
|
||||
slices.SortFunc(allocResp.Allocations, func(a, b *structs.AllocListStub) int {
|
||||
var result int
|
||||
// cmp(a, b) should return
|
||||
// a positive number when a > b
|
||||
if a.CreateIndex > b.CreateIndex {
|
||||
result = 1
|
||||
}
|
||||
// a negative number when a < b,
|
||||
if a.CreateIndex < b.CreateIndex {
|
||||
result = -1
|
||||
}
|
||||
// zero when a == b.
|
||||
result = 0
|
||||
|
||||
// invert the comparison to sort descending.
|
||||
return result * -1
|
||||
})
|
||||
|
||||
if alloc.ID != allocResp.Allocations[0].ID {
|
||||
|
|
|
@ -5521,8 +5521,18 @@ func (s *StateStore) pruneJobSubmissions(namespace, jobID string, txn *txn) erro
|
|||
}
|
||||
|
||||
// sort by job modify index descending so we can just keep the first N
|
||||
slices.SortFunc(stored, func(a, b lang.Pair[uint64, uint64]) bool {
|
||||
return a.First > b.First
|
||||
slices.SortFunc(stored, func(a, b lang.Pair[uint64, uint64]) int {
|
||||
var cmp int = 0
|
||||
if a.First < b.First {
|
||||
cmp = -1
|
||||
}
|
||||
if a.First > b.First {
|
||||
cmp = +1
|
||||
}
|
||||
|
||||
// Convert the sort into a descending sort by inverting the sign
|
||||
cmp = cmp * -1
|
||||
return cmp
|
||||
})
|
||||
|
||||
// remove the outdated submission versions
|
||||
|
|
Loading…
Reference in New Issue