Skip to content

Commit

Permalink
refactor: rename size to limit
Browse files Browse the repository at this point in the history
  • Loading branch information
anasmuhmd committed Oct 23, 2024
1 parent 2977f96 commit 4613673
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ The data source supports the following execution arguments:
data falcon_intel_indicators {
# limit the number of queried items
#
# Required integer.
# For example:
size = 42
# Optional integer.
# Default value:
limit = 10
# Indicators filter expression using Falcon Query Language (FQL)
#
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
],
"arguments": [
"filter",
"size",
"limit",
"sort"
]
},
Expand Down
9 changes: 5 additions & 4 deletions internal/crowdstrike/data_falcon_intel_indicators.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ func makeFalconIntelIndicatorsDataSource(loader ClientLoaderFn) *plugin.DataSour
Args: &dataspec.RootSpec{
Attrs: []*dataspec.AttrSpec{
{
Name: "size",
Name: "limit",
Type: cty.Number,
Constraints: constraint.Integer | constraint.RequiredNonNull,
Constraints: constraint.Integer,
DefaultVal: cty.NumberIntVal(10),
Doc: "limit the number of queried items",
},
{
Expand Down Expand Up @@ -53,9 +54,9 @@ func fetchFalconIntelIndicatorsData(loader ClientLoaderFn) plugin.RetrieveDataFu
Detail: err.Error(),
}}
}
size, _ := params.Args.GetAttrVal("size").AsBigFloat().Int64()
limit, _ := params.Args.GetAttrVal("limit").AsBigFloat().Int64()
apiParams := intel.NewQueryIntelIndicatorEntitiesParams().WithDefaults()
apiParams.SetLimit(&size)
apiParams.SetLimit(&limit)
apiParams.SetContext(ctx)
if filter := params.Args.GetAttrVal("filter"); !filter.IsNull() {
filterStr := filter.AsString()
Expand Down
17 changes: 3 additions & 14 deletions internal/crowdstrike/data_falcon_intel_indicators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *CrowdstrikeIntelIndicatorsTestSuite) TestBasic() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.Datasource().Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
s.Require().Nil(diags)
Expand Down Expand Up @@ -125,7 +125,7 @@ func (s *CrowdstrikeIntelIndicatorsTestSuite) TestPayloadErrors() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.Datasource().Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
diagtest.Asserts{{
Expand All @@ -148,7 +148,7 @@ func (s *CrowdstrikeIntelIndicatorsTestSuite) TestError() {
SetAttr("client_secret", cty.StringVal("test")).
Decode(),
Args: plugintest.NewTestDecoder(s.T(), s.Datasource().Args).
SetAttr("size", cty.NumberIntVal(10)).
SetAttr("limit", cty.NumberIntVal(10)).
Decode(),
})
diagtest.Asserts{{
Expand All @@ -157,14 +157,3 @@ func (s *CrowdstrikeIntelIndicatorsTestSuite) TestError() {
diagtest.DetailContains("something went wrong"),
}}.AssertMatch(s.T(), diags, nil)
}

func (s *CrowdstrikeIntelIndicatorsTestSuite) TestMissingArgs() {
plugintest.NewTestDecoder(
s.T(),
s.Datasource().Args,
).Decode([]diagtest.Assert{
diagtest.IsError,
diagtest.SummaryEquals("Missing required attribute"),
diagtest.DetailContains("size"),
})
}

0 comments on commit 4613673

Please sign in to comment.