-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Upstream firewalls DSF update to allow unknown values #5526
Upstream firewalls DSF update to allow unknown values #5526
Conversation
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 2 files changed, 62 insertions(+), 2 deletions(-)) |
Based on the identified problem with this ( The code below also passes the unit test I wrote, but I'm curious how it would behave if a static/known range (present in state) were then replaced with a dynamic/unknown one. update: I've added a test for the scenario we're discussing (valid _, tagsOk := diff.GetOk("source_tags")
_, rangesOk := diff.GetOk("source_ranges")
_, sasOk := diff.GetOk("source_service_accounts")
_, tagsExist := diff.GetOkExists("source_tags")
_, rangesExist := diff.GetOkExists("source_ranges")
_, sasExist := diff.GetOkExists("source_service_accounts")
oldLength, newLength := diff.GetChange("source_ranges.#")
if oldInt, ok := oldLength.(int); ok && oldInt > 0 {
if newInt, ok := newLength.(int); !ok || newInt == 0 {
// Ensure that ranges are not flagged as present if they are later removed.
rangesExist = false
}
}
if !tagsOk && !rangesOk && !sasOk && !tagsExist && !rangesExist && !sasExist {
return fmt.Errorf("one of source_tags, source_ranges, or source_service_accounts must be defined")
} Here's the above expanded to check all fields, which also passes both of the existing tests. for _, fld := range []string{"source_tags", "source_ranges", "source_service_accounts"} {
if _, ok := diff.GetOk(fld); ok {
return nil
}
if _, ok := diff.GetOkExists(fld); !ok {
continue
}
oldLength, newLength := diff.GetChange(fld + ".#")
if oldInt, ok := oldLength.(int); ok && oldInt > 0 {
if newInt, ok := newLength.(int); !ok || newInt == 0 {
// Ensure that fields are not flagged as present if they are later removed.
continue
}
}
return nil
}
return fmt.Errorf("one of source_tags, source_ranges, or source_service_accounts must be defined") |
Any progress on this? I imagine there's not much activity until after the holiday period now, but this is still a blocker for terraform-google-modules/terraform-google-kubernetes-engine#1071. |
/gcbrun |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 3 files changed, 93 insertions(+), 33 deletions(-)) |
I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic|TestAccApigeeEnvironmentIamBindingGenerated|TestAccApigeeEnvironmentIamMemberGenerated|TestAccApigeeEnvironmentIamPolicyGenerated|TestAccCloudFunctionsFunction_vpcConnector|TestAccComputeFirewall_moduleOutput|TestAccContainerNodePool_withInvalidUpgradeSettings You can view the result here: https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=235101 |
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
} | ||
|
||
resource "google_compute_address" "foobar" { | ||
name = "%s-address" |
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.
nit: the spacing in this resource is tabbed rather than 2 spaces
Upstreams: hashicorp/terraform-provider-google#10668
It's unclear to me if this is the best that we can do, it's not quite correct, but probably a better failure mode than exists right now
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)