refact (kms): convert to the new stdlib slices pkg (#3836)
This commit is contained in:
2 files changed
+7
-11
No files matched your search
@@ -4,6 +4,7 @@
|
||||
package authmethods_test
|
||||
|
||||
import (
|
||||
stdcmp "cmp"
|
||||
"context"
|
||||
"crypto/ed25519"
|
||||
"crypto/rand"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -32,7 +34,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/authmethods"
|
||||
scopepb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
"golang.org/x/exp/slices"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/testing/protocmp"
|
||||
@@ -351,13 +352,8 @@ func TestList(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
sorterFn := func(a *pb.AuthMethod, b *pb.AuthMethod) bool {
|
||||
switch {
|
||||
case a.GetId() > b.GetId():
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
sorterFn := func(a *pb.AuthMethod, b *pb.AuthMethod) int {
|
||||
return stdcmp.Compare(a.GetId(), b.GetId())
|
||||
}
|
||||
cpSorted := func(ams []*pb.AuthMethod) []*pb.AuthMethod {
|
||||
cp := make([]*pb.AuthMethod, 0, len(ams))
|
||||
|
||||
+3
-3
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
"github.com/hashicorp/go-dbw"
|
||||
wrappingKms "github.com/hashicorp/go-kms-wrapping/extras/kms/v2"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// Kms is a way to access wrappers for a given scope and purpose. Since keys can
|
||||
@@ -600,8 +600,8 @@ keyLoop:
|
||||
return false, errors.New(ctx, errors.KeyNotFound, op, "key version was not found in the scope")
|
||||
}
|
||||
// Sort versions just in case they aren't already sorted
|
||||
slices.SortFunc(foundKey.Versions, func(i, j wrappingKms.KeyVersion) bool {
|
||||
return i.Version < j.Version
|
||||
slices.SortFunc(foundKey.Versions, func(i, j wrappingKms.KeyVersion) int {
|
||||
return int(i.Version) - int(j.Version)
|
||||
})
|
||||
if foundKey.Versions[len(foundKey.Versions)-1].Id == keyVersionId {
|
||||
// Attempted to destroy currently active key
|
||||
|
||||
Reference in new issue
Block a user