-
Notifications
You must be signed in to change notification settings - Fork 65
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
Loadbalancer probe #23
Conversation
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 @thetonymaster,
as with lb nat rule this mostly LGTM, i've let some similar comments inline to address and again backported them to azurerm here
ImportState: true, | ||
ImportStateVerify: true, | ||
// location is deprecated and was never actually used | ||
ImportStateVerifyIgnore: []string{"location"}, |
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.
As we have removed the deprecate property, we can probably remove this line.
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureStackLoadBalancerProbe_importBasic(t *testing.T) { |
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.
As with the other resource, feel free to move this import test to the end of the regular test.
return &schema.Resource{ | ||
Create: resourceArmLoadBalancerProbeCreate, | ||
Read: resourceArmLoadBalancerProbeRead, | ||
Update: resourceArmLoadBalancerProbeCreate, |
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 this to resourceArmLoadBalancerProbeCreateUpdate
?
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: 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 get some validation here? at the very least a ValidateFunc: validation.NoZeroValues,
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: 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.
As well here: ValidateFunc: azure.ValidateResourceID,
|
||
d.Set("name", config.Name) | ||
d.Set("resource_group_name", id.ResourceGroup) | ||
d.Set("protocol", config.ProbePropertiesFormat.Protocol) |
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 get a nil check on config.ProbePropertiesFormat
?
if properties := config.ProbePropertiesFormat; properties != nil {
d.Set("protocol", properties.Protocol)
d.Set("interval_in_seconds", properties.IntervalInSeconds)
d.Set("number_of_probes", properties.NumberOfProbes)
d.Set("port", properties.Port)
d.Set("request_path", properties.RequestPath)
}
d.Set("port", config.ProbePropertiesFormat.Port) | ||
d.Set("request_path", config.ProbePropertiesFormat.RequestPath) | ||
|
||
var load_balancer_rules []string |
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.
And add nill checks here too:
var load_balancer_rules []string
if rules := properties.LoadBalancingRules; rules != nil {
for _, ruleConfig := range *rules {
if id := ruleConfig.ID; id != nil {
load_balancer_rules = append(load_balancer_rules, *id)
}
}
}
d.Set("load_balancer_rules", load_balancer_rules)
return nil | ||
} | ||
|
||
func expandAzureRmLoadBalancerProbe(d *schema.ResourceData, lb *network.LoadBalancer) (*network.Probe, error) { |
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.
This function never returns an error so we can remove that return value.
It also doesn't use lb *network.LoadBalancer
so it could also be removed.
ProbePropertiesFormat: &properties, | ||
} | ||
|
||
return &probe, nil |
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.
This could be written as:
return &network.Probe{
Name: utils.String(d.Get("name").(string)),
ProbePropertiesFormat: &properties,
}
Type: schema.TypeInt, | ||
Optional: true, | ||
Default: 15, | ||
}, |
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 get some validation here too?
ValidateFunc: validation.IntAtLeast(5),
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.
Just one comment WRT to using the SDK values for validation. I'll quickly update that myself however and get this merged 🙂
StateFunc: ignoreCaseStateFunc, | ||
DiffSuppressFunc: ignoreCaseDiffSuppressFunc, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
"Tcp", |
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 please use the SDK values here? ie string(network.ProbeProtocolHTTP),
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 👉 [email protected]. Thanks! |
No description provided.