-
Notifications
You must be signed in to change notification settings - Fork 142
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
Do not send 0 subnet
value unless explicitly set
#496
Conversation
|
||
subnet := convertSubnetToInt(v["subnet"].(string)) | ||
// only set zero subnet if the attribute is explicitly set | ||
if v["subnet"].(string) == "0" || subnet != 0 { |
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.
Do you think it might be cleaner to move this logic inside convertSubnetToInt
? Then convertSubnetToInt
could return *int
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.
I think I'm okay with the current
Looks like some of the implementation needs fixing but the principle seems reasonable! |
@bengesoff @Integralist |
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.
LGTM
After we changed the
subnet
type toint
:fastly/go-fastly#288
and updated go-fastly version:
https://github.com/fastly/terraform-provider-fastly/blob/main/CHANGELOG.md#0350-september-15-2021
We started sending
0
subnet value even if the value is not set. This is becauseconvertSubnetToInt
returns the default value (0
) when passing an empty string (""
). Fixing this to only send 0 value when thesubnet
attribute is explicitly set by the user.Also,
flattenAclEntries
function needs to know if the returnedsubnet
value isnull
or anyint
value in order to track them properly in the state file. To do so, we need to make a change in the upstream go-fastly package:fastly/go-fastly#316
Otherwise, we always see
0
subnet value regardless of the actual returned value (i.e.,null
vs0
int value) and save it to the state file, which causes a diff loop.