Skip to content

Commit

Permalink
Add remaining default_route_action subfields to `google_compute_reg…
Browse files Browse the repository at this point in the history
…ion_url_map` resource (GoogleCloudPlatform#6676)

* Add `defaultRouteAction.urlRewrite` to `google_compute_region_url_map` resource

* Add `defaultRouteAction.corsPolicy` to `google_compute_region_url_map` resource

* Add `cors_policy` to acceptance test

* Add `defaultRouteAction.faultInjectionPolicy` to `google_compute_region_url_map` resource, update generated test

* Fix bug where `defaultRouteAction.timeout` was incorrectly nested

* Fix misspelled field in acceptance test

* Add `at_least_one_of` logic present in the global version of UrlMap resource

* Update `defaultRouteAction` test to include `timeout` field

* Update `defaultRouteAction` test to include `url_rewrite` field

* Update `defaultRouteAction` test to include `cors_policy` field (excluding regex subfield)

* Add missing `at_least_one_of` entries inside the `defaultRouteAction` property

* Update values used for `url_rewrite` in Url Map tests and examples

* Update values of `host_rewrite` and `path_prefix_rewrite` in acc tests
  • Loading branch information
SarahFrench authored and googlerjk committed Nov 25, 2022
1 parent ccb9840 commit f6e0fb8
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 38 deletions.
295 changes: 287 additions & 8 deletions mmv1/products/compute/api.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions mmv1/products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,15 @@ overrides: !ruby/object:Overrides::ResourceOverrides
pathMatchers.pathRules.urlRedirect.stripQuery: !ruby/object:Overrides::Terraform::PropertyOverride
required: true
description: '{{description}} This field is required to ensure an empty block is not set. The normal default value is false.'
defaultRouteAction.urlRewrite.pathPrefixRewrite: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(1, 1024)'
defaultRouteAction.urlRewrite.hostRewrite: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.StringLenBetween(1, 255)'
defaultRouteAction.timeout.nanos: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntBetween(0, 999999999)'
defaultRouteAction.retryPolicy.numRetries: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntAtLeast(1)'
Expand All @@ -2362,6 +2371,18 @@ overrides: !ruby/object:Overrides::ResourceOverrides
defaultRouteAction.weightedBackendServices.weight: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntBetween(0, 1000)'
defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntBetween(0, 999999999)'
defaultRouteAction.faultInjectionPolicy.delay.percentage: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.FloatBetween(0, 100)'
defaultRouteAction.faultInjectionPolicy.abort.httpStatus: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.IntBetween(200, 599)'
defaultRouteAction.faultInjectionPolicy.abort.percentage: !ruby/object:Overrides::Terraform::PropertyOverride
validation: !ruby/object:Provider::Terraform::Validation
function: 'validation.FloatBetween(0, 100)'
ResourcePolicy: !ruby/object:Overrides::Terraform::ResourceOverride
examples:
- !ruby/object:Provider::Terraform::Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,46 @@ resource "google_compute_region_url_map" "<%= ctx[:primary_resource_id] %>" {
response_headers_to_remove = ["buzz"]
}
}
url_rewrite {
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}

cors_policy {
disabled = false
allow_credentials = true
allow_headers = [
"foobar"
]
allow_methods = [
"GET",
"POST",
]
allow_origins = [
"example.com"
]
expose_headers = [
"foobar"
]
max_age = 60
}
fault_injection_policy {
delay {
fixed_delay {
seconds = 0
nanos = 500
}
percentage = 0.5
}
abort {
http_status = 500
percentage = 0.5
}
}
timeout {
seconds = 0
nanos = 500
}
}

host_rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ resource "google_compute_region_url_map" "<%= ctx[:primary_resource_id] %>" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ resource "google_compute_region_url_map" "<%= ctx[:primary_resource_id] %>" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ resource "google_compute_url_map" "<%= ctx[:primary_resource_id] %>" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_backend_service.home.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ resource "google_compute_region_url_map" "foobar" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.self_link
Expand Down Expand Up @@ -658,8 +658,8 @@ resource "google_compute_region_url_map" "foobar" {
nanos = 760000000
}
url_rewrite {
host_rewrite = "A replacement header again"
path_prefix_rewrite = "A replacement path again"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
weighted_backend_services {
backend_service = google_compute_region_backend_service.home.self_link
Expand Down Expand Up @@ -950,10 +950,30 @@ resource "google_compute_region_url_map" "foobar" {
}
}

timeout {
seconds = 3
nanos = 0
}

url_rewrite {
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}

request_mirror_policy {
backend_service = google_compute_region_backend_service.login.id
}

cors_policy {
allow_origins = [ "https://www.example.com" ]
allow_methods = [ "GET" ]
allow_headers = [ "Content-Type" ]
expose_headers = [ "Authorization" ]
max_age = 600
allow_credentials = true
disabled = false
}

weighted_backend_services {
backend_service = google_compute_region_backend_service.login.id
weight = 200
Expand Down Expand Up @@ -1064,11 +1084,34 @@ resource "google_compute_region_url_map" "foobar" {
}
}

# update to be <1 second
timeout {
seconds = 0
nanos = 10000000 # 0.01 seconds
}

# update both values
url_rewrite {
host_rewrite = "stage.example.com"
path_prefix_rewrite = "/v2/api/"
}

# update backend_service field from 'login' to 'home'
request_mirror_policy {
backend_service = google_compute_region_backend_service.home.id
}

# update policy and disable it
cors_policy {
allow_origins = [ "https://xylophone.example.com", "https://www.example.com" ]
allow_methods = [ "PUT", "GET" ]
allow_headers = [ "Content-Type" ]
expose_headers = [ "Authorization" ]
max_age = 600
allow_credentials = true
disabled = true
}

# Change various fields - marked with comments
weighted_backend_services {
backend_service = google_compute_region_backend_service.login.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ resource "google_compute_url_map" "foobar" {

default_route_action {
url_rewrite {
host_rewrite = "my-new-host"
path_prefix_rewrite = "my-new-path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
}
}
Expand Down Expand Up @@ -655,8 +655,8 @@ resource "google_compute_url_map" "foobar" {

default_route_action {
url_rewrite {
host_rewrite = "a-different-host"
path_prefix_rewrite = "a-different-path"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
}
}
Expand Down Expand Up @@ -684,8 +684,8 @@ resource "google_compute_url_map" "foobar" {

default_route_action {
url_rewrite {
host_rewrite = "my-new-host"
path_prefix_rewrite = "my-new-path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
}
}
Expand All @@ -712,8 +712,8 @@ resource "google_compute_url_map" "foobar" {

default_route_action {
url_rewrite {
host_rewrite = "a-different-host"
path_prefix_rewrite = "a-different-path"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
}
}
Expand Down Expand Up @@ -1055,8 +1055,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = "${google_compute_backend_service.home.self_link}"
Expand Down Expand Up @@ -1174,8 +1174,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 760000000
}
url_rewrite {
host_rewrite = "A replacement header updated"
path_prefix_rewrite = "A replacement path updated"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
weighted_backend_services {
backend_service = "${google_compute_backend_service.home.self_link}"
Expand Down Expand Up @@ -1289,8 +1289,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_backend_service.home.self_link
Expand Down Expand Up @@ -1404,8 +1404,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 760000000
}
url_rewrite {
host_rewrite = "A replacement header updated"
path_prefix_rewrite = "A replacement path updated"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
weighted_backend_services {
backend_service = google_compute_backend_service.home.self_link
Expand Down Expand Up @@ -1510,8 +1510,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 750000000
}
url_rewrite {
host_rewrite = "A replacement header"
path_prefix_rewrite = "A replacement path"
host_rewrite = "dev.example.com"
path_prefix_rewrite = "/v1/api/"
}
weighted_backend_services {
backend_service = google_compute_backend_service.home.self_link
Expand Down Expand Up @@ -1615,8 +1615,8 @@ resource "google_compute_url_map" "foobar" {
nanos = 760000000
}
url_rewrite {
host_rewrite = "A replacement header updated"
path_prefix_rewrite = "A replacement path updated"
host_rewrite = "stage.example.com" # updated
path_prefix_rewrite = "/v2/api/" # updated
}
weighted_backend_services {
backend_service = google_compute_backend_service.home2.self_link
Expand Down

0 comments on commit f6e0fb8

Please sign in to comment.