-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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 pick-hostname behaviours #2658
add support for pick-hostname behaviours #2658
Conversation
b5e5e61
to
631a4f2
Compare
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.
Hi @mdsills,
Thank you for these new properties. I've left some comments inline and noticed that the docs are showing a change for almost every line on github diff? Could we fix that so only the changes made show up ?
@@ -499,7 +504,7 @@ func resourceArmApplicationGateway() *schema.Resource { | |||
|
|||
"host": { | |||
Type: schema.TypeString, | |||
Required: true, | |||
Optional: true, |
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.
Now that this is optional we should probably add validation somewhere to make sure if this is empty, pick_host_name_from_backend_address
is true.
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.
We should also update the documentation with this change
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.
@katbyte might you have any suggestions re "add validation somewhere"? - it seems like current validation mechanisms are per-property.
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.
@mdsills, in the create function you can check both properties and if neither are set return an error.
Something like:
host := v["pick_host_name_from_backend_address"].(string)
pick := v["pick_host_name_from_backend_address"].(bool)
if !pick && host == "" {
return fmt.Errorf("one of `host` or `pick_host_name_from_backend_http_settings` must be set")
}
if pick && host != "" {
return fmt.Errorf("Only one of `host` or `pick_host_name_from_backend_http_settings` must be set")
}
disclaimer that code might not compile 😅
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.
thanks for the pointer. it's ended up looking rather different, but hopefully still acceptable, or at least a step towards acceptable...
## Example Usage | ||
|
||
```hcl | ||
--- |
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.
Did you reformat the whole markdown file? Looks like the commit introduces many unnecessary lines of changes.
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.
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.
done
@@ -499,7 +504,7 @@ func resourceArmApplicationGateway() *schema.Resource { | |||
|
|||
"host": { | |||
Type: schema.TypeString, | |||
Required: true, | |||
Optional: true, |
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.
@mdsills, in the create function you can check both properties and if neither are set return an error.
Something like:
host := v["pick_host_name_from_backend_address"].(string)
pick := v["pick_host_name_from_backend_address"].(bool)
if !pick && host == "" {
return fmt.Errorf("one of `host` or `pick_host_name_from_backend_http_settings` must be set")
}
if pick && host != "" {
return fmt.Errorf("Only one of `host` or `pick_host_name_from_backend_http_settings` must be set")
}
disclaimer that code might not compile 😅
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.
Thanks @mdsills for the contributions. I have left several comments here and I think we are good to go as soon as they are resolved.
@@ -191,6 +191,8 @@ A `backend_http_settings` block supports the following: | |||
|
|||
* `request_timeout` - (Required) The request timeout in seconds, which must be between 1 and 86400 seconds. | |||
|
|||
* `pick_host_name_from_backend_address` - (Optional) Whether host header should be picked from the host name of the backend server. |
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.
Could we show the default value to optional attributes?
* `pick_host_name_from_backend_address` - (Optional) Whether host header should be picked from the host name of the backend server. | |
* `pick_host_name_from_backend_address` - (Optional) Whether host header should be picked from the host name of the backend server. Defaults to `false`. |
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.
done
@@ -281,6 +283,8 @@ A `probe` block support the following: | |||
|
|||
* `unhealthy_threshold` - (Required) The Unhealthy Threshold for this Probe, which indicates the amount of retries which should be attempted before a node is deemed unhealthy. Possible values are from 1 - 20 seconds. | |||
|
|||
* `pick_host_name_from_backend_http_settings` - (Optional) Whether the host header should be picked from the backend http settings. |
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.
Could we show the default value to optional attributes?
* `pick_host_name_from_backend_http_settings` - (Optional) Whether the host header should be picked from the backend http settings. | |
* `pick_host_name_from_backend_http_settings` - (Optional) Whether the host header should be picked from the backend http settings. Defaults to `false`. |
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.
done
@@ -267,7 +269,7 @@ A `path_rule` block supports the following: | |||
|
|||
A `probe` block support the following: | |||
|
|||
* `host` - (Required) The Hostname used for this Probe. If the Application Gateway is configured for a single site, by default the Host name should be specified as ‘127.0.0.1’, unless otherwise configured in custom probe. | |||
* `host` - (Required) The Hostname used for this Probe. If the Application Gateway is configured for a single site, by default the Host name should be specified as ‘127.0.0.1’, unless otherwise configured in custom probe. Cannot be set if `pick_host_name_from_backend_http_settings` is set to true. |
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.
Could we change the host
to be optional? We also prefer true
to be enquoted.
* `host` - (Required) The Hostname used for this Probe. If the Application Gateway is configured for a single site, by default the Host name should be specified as ‘127.0.0.1’, unless otherwise configured in custom probe. Cannot be set if `pick_host_name_from_backend_http_settings` is set to true. | |
* `host` - (Optional) The Hostname used for this Probe. If the Application Gateway is configured for a single site, by default the Host name should be specified as ‘127.0.0.1’, unless otherwise configured in custom probe. Cannot be set if `pick_host_name_from_backend_http_settings` is set to `true`. |
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.
done. good spot.
Config: testAccAzureRMApplicationGateway_settingsPickHostNameFromBackendAddress(ri, testLocation()), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMApplicationGatewayExists(resourceName), | ||
resource.TestCheckResourceAttrSet(resourceName, "backend_http_settings.0.pick_host_name_from_backend_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.
Could we remove this line because TestCheckResourceAttr
will check the existence?
resource.TestCheckResourceAttrSet(resourceName, "backend_http_settings.0.pick_host_name_from_backend_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.
done
Config: testAccAzureRMApplicationGateway_probesPickHostNameFromBackendHTTPSettings(ri, testLocation()), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMApplicationGatewayExists(resourceName), | ||
resource.TestCheckResourceAttrSet(resourceName, "probe.0.pick_host_name_from_backend_http_settings"), |
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.
Could we remove this line because TestCheckResourceAttr
will check the existence?
resource.TestCheckResourceAttrSet(resourceName, "probe.0.pick_host_name_from_backend_http_settings"), |
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.
done
Thanks for the udpates @mdsills 🙂 LGTM now |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Hi. Am unsure re policy/naming issues. Figured i'd submit PR and declare up-front that i'm happy to follow any helpful feedback and/or let someone else take it over the line. cheers.