Skip to content

Commit

Permalink
use discovery rule
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Dec 2, 2024
1 parent 67494ae commit 4568fb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/web/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,19 +343,19 @@ func (h *Handler) integrationDiscoveryRules(w http.ResponseWriter, r *http.Reque
return nil, trace.Wrap(err)
}

rules, err := collectAutoDiscoverRules(r.Context(), ig.GetName(), startKey, resourceType, clt.DiscoveryConfigClient())
rules, err := collectAutoDiscoveryRules(r.Context(), ig.GetName(), startKey, resourceType, clt.DiscoveryConfigClient())
if err != nil {
return nil, trace.Wrap(err)
}

return rules, nil
}

// collectAutoDiscoverRules will iterate over all DiscoveryConfigs's Matchers and collect the Discover Rules that exist in them for the given integration.
// collectAutoDiscoveryRules will iterate over all DiscoveryConfigs's Matchers and collect the Discovery Rules that exist in them for the given integration.
// It can also be filtered by Matcher Type (eg ec2, rds, eks)
// A Discover Rule is a close match to a DiscoveryConfig's Matcher, except that it will count as many rules as regions exist.
// A Discovery Rule is a close match to a DiscoveryConfig's Matcher, except that it will count as many rules as regions exist.
// Eg if a DiscoveryConfig's Matcher has two regions, then it will output two (almost equal) Rules, one for each Region.
func collectAutoDiscoverRules(
func collectAutoDiscoveryRules(
ctx context.Context,
integrationName string,
nextPage string,
Expand Down
6 changes: 3 additions & 3 deletions lib/web/intgrations_test.go → lib/web/integrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestCollectAWSOIDCAutoDiscoverStats(t *testing.T) {
})
}

func TestCollectAutoDiscoverRules(t *testing.T) {
func TestCollectAutoDiscoveryRules(t *testing.T) {
ctx := context.Background()
integrationName := "my-integration"

Expand All @@ -224,7 +224,7 @@ func TestCollectAutoDiscoverRules(t *testing.T) {
discoveryConfigs: make([]*discoveryconfig.DiscoveryConfig, 0),
}

gotRules, err := collectAutoDiscoverRules(ctx, integrationName, "", "", clt)
gotRules, err := collectAutoDiscoveryRules(ctx, integrationName, "", "", clt)
require.NoError(t, err)
expectedRules := ui.IntegrationDiscoveryRules{}
require.Equal(t, expectedRules, gotRules)
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestCollectAutoDiscoverRules(t *testing.T) {
},
}

got, err := collectAutoDiscoverRules(ctx, integrationName, "", "", clt)
got, err := collectAutoDiscoveryRules(ctx, integrationName, "", "", clt)
require.NoError(t, err)
expectedRules := []ui.IntegrationDiscoveryRule{
{
Expand Down

0 comments on commit 4568fb7

Please sign in to comment.