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

Add load balancer application rule resource and data source #278

Merged
merged 18 commits into from
Jul 11, 2019

Conversation

Didainius
Copy link
Collaborator

Continuing work on terraform-providers/terraform-provider-vcd#223

This one introduces resource and data source for Load Balancer Application Rule.

go.mod Outdated Show resolved Hide resolved
Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

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

Seems very nice 👍

go.sum Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
return fmt.Errorf("unable to expand load balancer app rule: %s", err)
}

createdPool, err := edgeGateway.CreateLBAppRule(LBRule)
Copy link
Contributor

Choose a reason for hiding this comment

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

CreateLBAppRule(LBRule) - IMHO would be much better readable as CreateLBAppRule(name, script). as it's now it shows that LBRULE ir complex, but it isn't

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could create wrapper, but I would like to keep this consistent and transparent to the struct we have in types.
The reason I dislike when we introduce our own "simplified types" for structs is that we end up translating between structs. Then if a new field appears (or we missed some) in the configuration our APIs become deprecated and a new method must be created.
Again if this is a team decision I can change :)
@lvirbalas, @dataclouder, your thoughts about it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

One more thought. What if I added more explanation to the type fields we have in Go fashion. That way any modern IDE would show more context of what is expected in the field but would still keep the transparency.

These are mockups comments, not exactly the ones I intend to add.
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason I dislike when we introduce our own "simplified types" for structs is that we end up translating between structs. Then if a new field appears (or we missed some) in the configuration our APIs become deprecated and a new method must be created.
Again if this is a team decision I can change :)

I dislike the simplified types as well, as they add another layer of abstraction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, seems we have diff reading and API usage experience. For me as terraform and API reader/user it's easier to pass two string, than Structure with four fields which I have to check which to fill. From Java world there is rule if method with 4-5 parameters when refactor to pass object.

Copy link
Collaborator Author

@Didainius Didainius Jul 10, 2019

Choose a reason for hiding this comment

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

It may be so. But I have already burnt with such methods in this project. I had to change quite a few details on VM networking just because there were "simplified" fields missing important details. The public API gets too many changes this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the light of current discussion - what if I add a wrapper for it now and we have both options available?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you already have this approach for all other previous LB resources. Also, there are many other instances of this approach in EG already. Hence, I suggest leaving this as is in this PR, but @dataclouder could add this to refactoring consideration together with vmware/go-vcloud-director#211

Copy link
Contributor

Choose a reason for hiding this comment

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

I am OK with @Didainius approach.
Simplified structures should be used only when: (I) we have more than 3 fields to pass by position, (II) the original structures are not flat, (III) require internal structure manipulation, (IV) and can't be passed to update methods without changes. A clear example is Edge Gateway, where the structure contains a huge amount of details that we may not intend to deal with in every operation. But this structure is manageable as it is.

vcd/resource_vcd_lb_app_rule.go Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
website/docs/d/lb_app_rule.html.markdown Outdated Show resolved Hide resolved
website/docs/d/lb_app_rule.html.markdown Outdated Show resolved Hide resolved
website/docs/r/lb_app_rule.html.markdown Outdated Show resolved Hide resolved
@ghost ghost added size/XXL and removed size/XL labels Jul 10, 2019
Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

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

LGTM, don't forget to fix build

@ghost ghost added size/XL and removed size/XXL labels Jul 11, 2019
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

Thanks for all the updates!

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

Some minor changes are needed

vcd/datasource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule_test.go Outdated Show resolved Hide resolved
return fmt.Errorf("unable to expand load balancer app rule: %s", err)
}

createdPool, err := edgeGateway.CreateLBAppRule(LBRule)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am OK with @Didainius approach.
Simplified structures should be used only when: (I) we have more than 3 fields to pass by position, (II) the original structures are not flat, (III) require internal structure manipulation, (IV) and can't be passed to update methods without changes. A clear example is Edge Gateway, where the structure contains a huge amount of details that we may not intend to deal with in every operation. But this structure is manageable as it is.

vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule.go Outdated Show resolved Hide resolved
vcd/resource_vcd_lb_app_rule_test.go Outdated Show resolved Hide resolved
website/docs/r/lb_app_rule.html.markdown Outdated Show resolved Hide resolved
website/docs/r/lb_app_rule.html.markdown Outdated Show resolved Hide resolved
@ghost ghost added size/XXL and removed size/XL labels Jul 11, 2019
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

Tests pass. LGTM

@Didainius Didainius merged commit 07b6ea9 into vmware:master Jul 11, 2019
@Didainius Didainius deleted the lb4 branch July 11, 2019 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants