You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Currently, when an MR is generated from Terrajet, the JSON tags are a consequence of the field type. If it is required, it doesn't have omitempty. If it's optional, it has the omitempty tag. Here is the code that decides it:
In the YAML above, the spec.forProvider.requiredStatusChecks[0].contexts field is optional (so the JSON tag has the omitempty value). It configures which status checks are mandatory to pass before a PR merge can be done.
By applying the YAML above, we expect that the status check my-pipeline-check MUST pass before any PR could be merged. This works as expected.
The problem is that, if I change the contexts field to contexts: [] -- for example:
I would expect that the external API would also have an empty list of status checks. But the Managed Resource code doesn't remove the my-pipeline-check status check from the API.
How could Terrajet help solve your problem?
My hypothesis is that the code is considering the contexts field as not_specified, so it isn't actively forcing the BranchProtection (in the external API) to not have the contexts field filled.
If the hypothesis is correct, we could configure this tags and the code could differ from not_specified, specified and empty_value and configures the external API accordingly.
The text was updated successfully, but these errors were encountered:
What problem are you facing?
Currently, when an MR is generated from Terrajet, the JSON tags are a consequence of the field type. If it is required, it doesn't have
omitempty
. If it's optional, it has theomitempty
tag. Here is the code that decides it:terrajet/pkg/types/builder.go
Lines 273 to 279 in 8d0ed48
This is fine for most use cases for managed resources. But there are some APIs and fields that would be benefited if this behavior can be configured.
The practical use case that I have for this is with the BranchProtection managed resource from GitHub terraform provider.
In the YAML above, the
spec.forProvider.requiredStatusChecks[0].contexts
field is optional (so the JSON tag has theomitempty
value). It configures which status checks are mandatory to pass before a PR merge can be done.By applying the YAML above, we expect that the status check
my-pipeline-check
MUST pass before any PR could be merged. This works as expected.The problem is that, if I change the
contexts
field tocontexts: []
-- for example:I would expect that the external API would also have an empty list of status checks. But the Managed Resource code doesn't remove the
my-pipeline-check
status check from the API.How could Terrajet help solve your problem?
My hypothesis is that the code is considering the
contexts
field asnot_specified
, so it isn't actively forcing the BranchProtection (in the external API) to not have thecontexts
field filled.If the hypothesis is correct, we could configure this tags and the code could differ from
not_specified
,specified
andempty_value
and configures the external API accordingly.The text was updated successfully, but these errors were encountered: