Skip to content
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

Add datacenters data resource #540

Merged

Conversation

smaeda-ks
Copy link
Contributor

@smaeda-ks smaeda-ks commented Feb 9, 2022

maybe related: #523

$ FASTLY_API_KEY=**** make testacc TESTARGS='-run=TestAccFastlyDataSourceDatacenters'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccFastlyDataSourceDatacenters -parallel=4 -timeout 360m -ldflags="-X=github.com/fastly/terraform-provider-fastly/version.ProviderVersion=acc"
?   	github.com/fastly/terraform-provider-fastly	[no test files]
=== RUN   TestAccFastlyDataSourceDatacenters
=== PAUSE TestAccFastlyDataSourceDatacenters
=== CONT  TestAccFastlyDataSourceDatacenters
--- PASS: TestAccFastlyDataSourceDatacenters (1.34s)
PASS
ok  	github.com/fastly/terraform-provider-fastly/fastly	2.193s
?   	github.com/fastly/terraform-provider-fastly/fastly/hashcode	[no test files]
?   	github.com/fastly/terraform-provider-fastly/version	[no test files]

Copy link
Collaborator

@Integralist Integralist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @smaeda-ks for opening this PR. I had some questions, but otherwise this LGTM.

return diag.Errorf("error fetching datacenters: %s", err)
}
hashBase, _ := json.Marshal(datacenters)
hashString := strconv.Itoa(hashcode.String(string(hashBase)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern across the code base so far has been to use fmt.Sprintf("%d", hashcode.String(...)) although that feels a bit ...hacky (for reasons I can't articulate) compared to using strconv.Itoa.

Seems others have written about the performance implications of using fmt.Sprintf (https://medium.com/swlh/bad-go-frivolous-sprintf-2ad28fedf1a0) and so it's probably worth at some point us updating the code to use strconv.Itoa.

@Integralist Integralist added the enhancement New feature or request label Feb 11, 2022
@Integralist Integralist merged commit def8187 into fastly:main Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants