Open cbhoffman opened 8 months ago
Love to get your feedback on this @joaomper-TE @shahid-te
I'm happy to make a PR depending on the direction you want to go with this.
Hey @cbhoffman and thanks for reporting this! And it does seem that the problem is exactly what you reported.
We will open a bug on our side and will take care of it in the near-future.
What versions are you using?
Currently 2.0.2
What did you expect to happen?
After setting "use-public-bgp" to "true" within our DNS Server test. We expect to see the correct output within the console.
What actually happened?
The tf plan produces expected result. However, no change is made in the console. After tf deploy, the terraform state shows as "false" for the resource. Every subsequent tf plan execution shows a change on the resource amending the "false" default value to "true".
After looking at the SDK, the problem is how the SDK struct field names are mapped to the TF provider schema. Specifically, the problem is with the "CamelCaseToUnderscore" function, that runs within the "ResourceBuildStruct" function.
For example: Within the SDK, in the AgentServer struct, the field name is "UsePublicBGP". After the CamelCaseToUnderscore function is executed it produces a result of "use_publicbgp". This does not match the expected value in the tf provider schema ("use_public_bgp"). This is why our configured value doesn't go any further and why we aren't seeing the expected result being produced in the thousandeyes console.
The CamelCaseToUnderscore function does not seem to handle struct field names where there are multiple capital case letters at the end of the field name. Besides "UsePublicBGP", there are other examples of SDK struct field names which might cause the same problem:
For example:
Terraform code to reproduce the bug
Any additional comments or code?
Potential Solution Ideas
Within this repo:
Amend the problem schema field names
For example:
Refactor the CamelCaseToUnderscore function
Within the SDK repo:
Amend the Struct field names
Steps to reproduce the bug
Isolate the "CamelCaseToUnderscore" function to recreate what happens when the SDK struct field values are mapped to the provider schema.
You will see that some names won't match as expected.