Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion providers/gcp/connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: BUSL-1.1

//go:build debugtest
// +build debugtest

package connection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: BUSL-1.1

//go:build debugtest
// +build debugtest

package gcpinstancesnapshot

Expand Down
4 changes: 2 additions & 2 deletions providers/gcp/resources/artifactregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"errors"
"fmt"
"sort"
"slices"
"time"

artifactregistry "cloud.google.com/go/artifactregistry/apiv1"
Expand Down Expand Up @@ -336,7 +336,7 @@ func newCleanupPolicies(runtime *plugin.Runtime, repoPath string, policies map[s
for id := range policies {
policyIds = append(policyIds, id)
}
sort.Strings(policyIds)
slices.Sort(policyIds)

var result []any
for _, policyId := range policyIds {
Expand Down
6 changes: 3 additions & 3 deletions providers/gcp/resources/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package resources

import (
"sort"
"slices"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -28,9 +28,9 @@ func TestGetDiscoveryTargets(t *testing.T) {
// test auto with other stuff
config.Discover.Targets = []string{"auto", "cloud-dns-zones", "compute-images"}
res := append(Auto, []string{DiscoverCloudDNSZones, DiscoveryComputeImages}...)
sort.Strings(res)
slices.Sort(res)
targets := getDiscoveryTargets(config)
sort.Strings(targets)
slices.Sort(targets)
require.Equal(t, res, targets)

// test just auto
Expand Down
2 changes: 1 addition & 1 deletion providers/gcp/resources/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func subscriptionStateToString(state pubsub.SubscriptionState) string {
}
}

func optionalDurationToTime(d interface{}) time.Time {
func optionalDurationToTime(d any) time.Time {
if d == nil {
return llx.DurationToTime(0)
}
Expand Down
16 changes: 8 additions & 8 deletions providers/gcp/resources/secretmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (g *mqlGcpProjectSecretmanagerService) secrets() ([]any, error) {
return nil, err
}

var replicationDict map[string]interface{}
var replicationDict map[string]any
if s.Replication != nil {
replicationDict, err = secretReplicationToDict(s.Replication)
if err != nil {
Expand All @@ -108,12 +108,12 @@ func (g *mqlGcpProjectSecretmanagerService) secrets() ([]any, error) {
}
}

topicNames := make([]interface{}, 0, len(s.Topics))
topicNames := make([]any, 0, len(s.Topics))
for _, t := range s.Topics {
topicNames = append(topicNames, t.Name)
}

var rotationDict map[string]interface{}
var rotationDict map[string]any
if s.Rotation != nil {
rotationDict, err = convert.JsonToDict(mqlSecretRotation{
NextRotationTime: timestampToString(s.Rotation.NextRotationTime),
Expand All @@ -125,7 +125,7 @@ func (g *mqlGcpProjectSecretmanagerService) secrets() ([]any, error) {
}
}

versionAliasesMap := make(map[string]interface{})
versionAliasesMap := make(map[string]any)
for k, v := range s.VersionAliases {
versionAliasesMap[k] = int64(v)
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func (g *mqlGcpProjectSecretmanagerServiceSecret) versions() ([]any, error) {
return nil, err
}

var cmeStatusDict map[string]interface{}
var cmeStatusDict map[string]any
if v.CustomerManagedEncryption != nil {
cmeStatusDict, err = convert.JsonToDict(mqlCustomerManagedEncryptionStatus{
KmsKeyVersionName: v.CustomerManagedEncryption.KmsKeyVersionName,
Expand Down Expand Up @@ -344,8 +344,8 @@ type mqlCustomerManagedEncryptionStatus struct {
// - Top-level Secret.CustomerManagedEncryption (regionalized secrets)
// - Replication.Automatic.CustomerManagedEncryption (automatic replication)
// - Replication.UserManaged.Replicas[].CustomerManagedEncryption (user-managed replication)
func extractCustomerManagedEncryptionKeys(s *secretmanagerpb.Secret) []interface{} {
var keys []interface{}
func extractCustomerManagedEncryptionKeys(s *secretmanagerpb.Secret) []any {
var keys []any
if s.CustomerManagedEncryption != nil {
keys = append(keys, s.CustomerManagedEncryption.KmsKeyName)
}
Expand All @@ -364,7 +364,7 @@ func extractCustomerManagedEncryptionKeys(s *secretmanagerpb.Secret) []interface
return keys
}

func secretReplicationToDict(r *secretmanagerpb.Replication) (map[string]interface{}, error) {
func secretReplicationToDict(r *secretmanagerpb.Replication) (map[string]any, error) {
if auto := r.GetAutomatic(); auto != nil {
rep := mqlSecretReplication{Type: "AUTOMATIC"}
if auto.CustomerManagedEncryption != nil {
Expand Down
18 changes: 9 additions & 9 deletions providers/gcp/resources/secretmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func TestSecretReplicationToDict_UserManaged(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, "USER_MANAGED", result["type"])
replicas, ok := result["replicas"].([]interface{})
replicas, ok := result["replicas"].([]any)
require.True(t, ok)
require.Len(t, replicas, 2)
r0 := replicas[0].(map[string]interface{})
r0 := replicas[0].(map[string]any)
assert.Equal(t, "us-east1", r0["location"])
assert.Nil(t, r0["customerManagedEncryption"])
r1 := replicas[1].(map[string]interface{})
r1 := replicas[1].(map[string]any)
assert.Equal(t, "europe-west1", r1["location"])
}

Expand Down Expand Up @@ -99,13 +99,13 @@ func TestSecretReplicationToDict_UserManagedWithCMEK(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, result)
assert.Equal(t, "USER_MANAGED", result["type"])
replicas, ok := result["replicas"].([]interface{})
replicas, ok := result["replicas"].([]any)
require.True(t, ok)
require.Len(t, replicas, 2)
r0 := replicas[0].(map[string]interface{})
r0 := replicas[0].(map[string]any)
assert.Equal(t, "us-east1", r0["location"])
assert.Equal(t, "projects/p/locations/us-east1/keyRings/kr/cryptoKeys/key-a", r0["customerManagedEncryption"])
r1 := replicas[1].(map[string]interface{})
r1 := replicas[1].(map[string]any)
assert.Equal(t, "eu-west1", r1["location"])
assert.Equal(t, "projects/p/locations/eu-west1/keyRings/kr/cryptoKeys/key-b", r1["customerManagedEncryption"])
}
Expand All @@ -126,7 +126,7 @@ func TestExtractCustomerManagedEncryptionKeys(t *testing.T) {
},
}
keys := extractCustomerManagedEncryptionKeys(s)
assert.Equal(t, []interface{}{"projects/p/locations/global/keyRings/kr/cryptoKeys/key1"}, keys)
assert.Equal(t, []any{"projects/p/locations/global/keyRings/kr/cryptoKeys/key1"}, keys)
})

t.Run("automatic replication CMEK", func(t *testing.T) {
Expand All @@ -142,7 +142,7 @@ func TestExtractCustomerManagedEncryptionKeys(t *testing.T) {
},
}
keys := extractCustomerManagedEncryptionKeys(s)
assert.Equal(t, []interface{}{"projects/p/locations/global/keyRings/kr/cryptoKeys/key2"}, keys)
assert.Equal(t, []any{"projects/p/locations/global/keyRings/kr/cryptoKeys/key2"}, keys)
})

t.Run("user-managed replication with multiple CMEK keys", func(t *testing.T) {
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestExtractCustomerManagedEncryptionKeys(t *testing.T) {
},
}
keys := extractCustomerManagedEncryptionKeys(s)
assert.Equal(t, []interface{}{
assert.Equal(t, []any{
"projects/p/locations/us-east1/keyRings/kr/cryptoKeys/key-a",
"projects/p/locations/eu-west1/keyRings/kr/cryptoKeys/key-b",
}, keys)
Expand Down
Loading