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 38054ed commit fb8a088
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 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_discover_host_details {
# limit the number of queried items
#
# Required integer.
# For example:
size = 42
# Optional integer.
# Default value:
limit = 10
# Host search 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"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ document "falcon_discover_host_details" {
client_secret = ""
client_cloud = "eu-1"
}
size = 100
limit = 100
}

title = "List of discover host details"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ document "vulnerabilities" {
client_secret = ""
client_cloud = "eu-1"
}
size = 100
limit = 100
}

title = "List of Falcon vulnerabilities"
Expand Down
9 changes: 5 additions & 4 deletions internal/crowdstrike/data_falcon_discover_host_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ func makeFalconDiscoverHostDetailsDataSource(loader ClientLoaderFn) *plugin.Data
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 All @@ -48,9 +49,9 @@ func fetchFalconDiscoverHostDetails(loader ClientLoaderFn) plugin.RetrieveDataFu
Detail: err.Error(),
}}
}
size, _ := params.Args.GetAttrVal("size").AsBigFloat().Int64()
limit, _ := params.Args.GetAttrVal("limit").AsBigFloat().Int64()
queryHostParams := discover.NewQueryHostsParams().WithDefaults()
queryHostParams.SetLimit(&size)
queryHostParams.SetLimit(&limit)
queryHostParams.SetContext(ctx)
queryHostsResponse, err := cli.Discover().QueryHosts(queryHostParams)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (s *CrowdstrikeDiscoverHostDetailsTestSuite) 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 @@ -132,7 +132,7 @@ func (s *CrowdstrikeDiscoverHostDetailsTestSuite) 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 @@ -154,7 +154,7 @@ func (s *CrowdstrikeDiscoverHostDetailsTestSuite) 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 @@ -171,6 +171,6 @@ func (s *CrowdstrikeDiscoverHostDetailsTestSuite) TestMissingArgs() {
).Decode([]diagtest.Assert{
diagtest.IsError,
diagtest.SummaryEquals("Missing required attribute"),
diagtest.DetailContains("size"),
diagtest.DetailContains("limit"),
})
}

0 comments on commit fb8a088

Please sign in to comment.