Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tcsc committed Feb 10, 2025
1 parent b38f3d0 commit 6196718
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 3 additions & 2 deletions tool/tctl/common/plugin/awsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"net/url"
"slices"

"github.com/alecthomas/kingpin/v2"
"github.com/gravitational/trace"
Expand Down Expand Up @@ -71,7 +72,7 @@ func (a *awsICArgs) validate() error {
// in the AWS IC integration itself, because those filter tools are not
// available to OSS builds of tctl.
//
// TODO(tcsc): Move the filter validation somewhere that the that the OSS build can access it.
// TODO(tcsc): Move the canonical filter validation in `e/aws/identitycenter/common` to somewhere where the OSS build can access it.
func parseAWSICNameFilters(names []string) ([]*types.AWSICResourceFilter, error) {
var filters []*types.AWSICResourceFilter
for _, n := range names {
Expand Down Expand Up @@ -117,7 +118,7 @@ func (a *awsICArgs) parseUserFilters() ([]*types.AWSICUserSyncFilter, error) {
}

if len(a.userLabels) > 0 {
result = append(make([]*types.AWSICUserSyncFilter, 0, len(result)+len(a.userLabels)), result...)
result = slices.Grow(result, len(a.userLabels))
for _, labels := range a.userLabels {
result = append(result, &types.AWSICUserSyncFilter{Labels: labels})
}
Expand Down
10 changes: 4 additions & 6 deletions tool/tctl/common/plugin/awsic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package plugin

import (
"math/rand/v2"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -96,16 +95,14 @@ func TestAWSICGroupFilters_Parse(t *testing.T) {
actualFilters, err := cliArgs.parseGroupFilters()

// EXPECT the operation to succeed AND that the returned filters are an
// accurate representation of the command line args, in arbitrary order
// accurate representation of the command line args. Returned filters
// are not expected to have any particular order.
require.NoError(t, err)
expectedFilters := []*types.AWSICResourceFilter{
{Include: &types.AWSICResourceFilter_NameRegex{NameRegex: "alpha"}},
{Include: &types.AWSICResourceFilter_NameRegex{NameRegex: "bravo"}},
{Include: &types.AWSICResourceFilter_NameRegex{NameRegex: "charlie"}},
}
rand.Shuffle(len(expectedFilters), func(i, j int) {
expectedFilters[i], expectedFilters[j] = expectedFilters[j], expectedFilters[i]
})
require.ElementsMatch(t, expectedFilters, actualFilters)
}

Expand Down Expand Up @@ -146,7 +143,8 @@ func TestAWSICAccountFilters_Parse(t *testing.T) {
actualFilters, err := cliArgs.parseAccountFilters()

// EXPECT the operation to succeed AND that the returned filters are an
// accurate representation of the command line args (in arbitrary order)
// accurate representation of the command line args. Returned filters
// are not expected to have any particular order.
require.NoError(t, err)
expectedFilters := []*types.AWSICResourceFilter{
{Include: &types.AWSICResourceFilter_NameRegex{NameRegex: "alpha"}},
Expand Down

0 comments on commit 6196718

Please sign in to comment.