Skip to content
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

Merged
merged 9 commits into from
Aug 9, 2018
Merged

Loadbalancer probe #23

merged 9 commits into from
Aug 9, 2018

Conversation

thetonymaster
Copy link
Contributor

No description provided.

Copy link
Collaborator

@katbyte katbyte left a 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"},
Copy link
Collaborator

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) {
Copy link
Collaborator

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,
Copy link
Collaborator

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,
},
Copy link
Collaborator

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,
},
Copy link
Collaborator

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)
Copy link
Collaborator

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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
Copy link
Collaborator

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,
},
Copy link
Collaborator

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),

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thetonymaster,

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",
Copy link
Collaborator

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),

@katbyte
Copy link
Collaborator

katbyte commented Aug 9, 2018

Tests all pass:

screen shot 2018-08-09 at 12 12 11

@katbyte katbyte merged commit c599770 into hashicorp:master Aug 9, 2018
katbyte added a commit that referenced this pull request Aug 9, 2018
@katbyte katbyte added this to the 0.3.0 milestone Aug 13, 2018
@ghost
Copy link

ghost commented Jun 27, 2019

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!

@ghost ghost locked and limited conversation to collaborators Jun 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants