-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datasource/sites): support sites list #160
Conversation
4d95f13
to
7b810e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for the reviewer...
go build -o terraform-provider-sigsci | ||
build: clean | ||
go build -o bin/terraform-provider-sigsci | ||
@sh -c "'$(CURDIR)/scripts/generate-dev-overrides.sh'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enables me to locally test the provider.
"blacklist_uri": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Reference to the site's blacklist", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: The API has a blocklist
field but it's not implemented in the go-sigsci
API client.
return err | ||
} | ||
|
||
d.SetId("list_sites") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously I was dynamically generating a dynamic ID but opted for a static ID as I don't imagine there will be multiple instances of the sigsci_sites
data source. If we do think that is a possibility then we should make this dynamically generated (possibly using something like https://github.com/google/uuid to generate the ID).
if filter != "" { | ||
for idx, site := range results { | ||
if site["name"] == filter || site["display_name"] == filter { | ||
return results[idx : idx+1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation for the filter
attribute is 'match only one', e.g. the first site that matches is returned.
If we want the filter to return multiple potential sites, then the implementation should be updated.
@@ -38,7 +38,7 @@ func expandStringArray(entries *schema.Set) []string { | |||
} | |||
|
|||
func flattenDetections(detections []sigsci.Detection) []interface{} { | |||
var detectionsSet = make([]interface{}, len(detections)) | |||
detectionsSet := make([]interface{}, len(detections)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My editor made a bunch of automated refactors.
LGTM, thank you @Integralist! |
Fixes part of @sjparkinson issue reported here #111