-
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
Add support for global application in Apphub #12017
Changes from all commits
45c119e
ba4d6bb
b61d5c7
676e4b1
140ab50
c92dc7f
68827f9
7d23c44
c9904f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
func apphubApplicationCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta interface{}) error { | ||
if diff.HasChange("location") || diff.HasChange("scope.0.type") { | ||
location := diff.Get("location") | ||
scope_type := diff.Get("scope.0.type") | ||
|
||
if scope_type == "GLOBAL" { | ||
if location != "global" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the API give an appropriate error in this case? If so, is there a particular pressure to duplicate this validation in the Terraform provider? Adding additional validation at this level can lead to instances where the API requirements change but the Terraform providers lag behind. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API will give an appropriate error in such case. But we wanted terraform plan to perform validation and catch this error. |
||
return fmt.Errorf("Error validating location %s with %s scope type", location, scope_type) | ||
} | ||
} else { | ||
if location == "global" { | ||
return fmt.Errorf("Error validating location %s with %s scope type", location, scope_type) | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should cover this logic somewhere in a test. If we are going to keep it (see my previous comment), let's add an invalid config in https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/services/apphub/resource_apphub_application_test.go and use ExpectError There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
resource "google_apphub_application" "{{$.PrimaryResourceId}}" { | ||
location = "us-east1" | ||
location = "{{index $.Vars "location"}}" | ||
application_id = "{{index $.Vars "application_id"}}" | ||
scope { | ||
type = "REGIONAL" | ||
type = "{{index $.Vars "scope_type"}}" | ||
} | ||
} |
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.
is config_path actually necessary here? This is usually just used in for private overrides. I'm assuming other examples of using this were just accidentally copied over from the private repo
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.
Have updated basic and full examples to remove config_path. But for *_global_basic , we were intending to use the same config as basic with different values.