-
Notifications
You must be signed in to change notification settings - Fork 47
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: Metros Data Source Development #842
base: main
Are you sure you want to change the base?
Conversation
9d7b498
to
98188eb
Compare
c1bf86f
to
d865d04
Compare
# Conflicts: # internal/config/config.go
716b206
to
424d198
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #842 +/- ##
===========================================
+ Coverage 36.13% 49.23% +13.09%
===========================================
Files 184 191 +7
Lines 24491 25172 +681
===========================================
+ Hits 8850 12393 +3543
+ Misses 15480 12371 -3109
- Partials 161 408 +247 ☔ View full report in Codecov by Sentry. |
return fmt.Sprintf(` | ||
|
||
data "equinix_fabric_metro" "metro" { | ||
metro_code = "%[1]s" |
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.
info: the [1] is used when you want to repeat parameters in Sprintf. Otherwise you can omit because it will automatically pick them up in the order they are given after the formatted string.
No change necessary. Just an educational comment.
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.
Only parseMetro
needs to be updated because there are multiple if
blocks that aren't adding any value.
The rest of the comments should just be taken as education and you should avoid changing them to keep your PR review response as straight forward as possible.
Thanks for adding in the metros, @d-bhola !
*name = types.StringValue(metro.GetName()) | ||
} | ||
|
||
if equinixAsn != nil { |
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.
These are not doing what you think they're doing. The models themselves are being checked before assignment. You should be checking the values that are being given from metro
here. It's essentially an empty if
check. You can remove any if
boundary like this and just move their contents into the root of the method scope if the data source was working with this code.
connMetros := make([]ConnectedMetroModel, len(connectedMetros)) | ||
for i, metro := range connectedMetros { | ||
connMetros[i] = ConnectedMetroModel{} | ||
if metro.Href != nil { |
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.
You should resist checking the pointers and instead go for checking for empty strings. So if metro.GetHref() != "" {...
It might work here, so no need to change, but make certain you understand your changes and aren't just getting lucky with the side effects of the code you are writing.
Addition of two data sources in Terraform Provider:
Get Metro By Code
/fabric/v4/metros/{metroCode}
datasources_metro_code.go
GET all Metros
/fabric/v4/metros
datasources_metros.go
Data Source Schema Addition
datasources_schema.go
(same for both data sources)Model Translation and Data Setting
models.go
(same for both data sources)Acceptance Tests
datasources_test.go
Documentation
fabric_metro.md
fabric_metros.md