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 optional notes to firewall rules #65

Merged
merged 2 commits into from
Mar 21, 2019

Conversation

nstapelbroek
Copy link
Contributor

Heya 👋

Thank you for creating and sharing this repository!
Recently, Vultr added the option to leave a small note on a firewall rule. Extra convenient when you are trying to remember who a certain entry belongs to.

This PR should allow users to use this new notes functionality by adding an optional --notes flag to the firewall rule creation command. Let me know what you think.
The functional result:
Screenshot 2019-03-19 at 21 53 01
Screenshot 2019-03-19 at 21 55 45

Notes / questions:

I'm still a bit new to the language, so if you have any comments or suggestions: let me know! I've written down some thoughts below. Maybe you can help me out with these?

  • Is there a way to handle the API change of CreateFirewallRule more gracefully? I don't think that optional arguments is a thing in golang 🤔
  • What about validation rules? The API docs state that there is a limit of 255 characters. Should we validate the data before we send it?
  • Any way I can test this better?

@@ -198,7 +200,7 @@ func (c *Client) GetFirewallRules(groupID string) ([]FirewallRule, error) {
// protocol must be one of: "icmp", "tcp", "udp", "gre"
// port can be a port number or colon separated port range (TCP/UDP only)
func (c *Client) CreateFirewallRule(groupID, protocol, port string,
network *net.IPNet) (int, error) {
network *net.IPNet, notes string) (int, error) {
Copy link
Contributor Author

@nstapelbroek nstapelbroek Mar 19, 2019

Choose a reason for hiding this comment

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

After reading #40 I think we should maybe create a CreateFirewallRuleWithNote and leave this method signature untouched. What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

No, I think it's fine this way. We'll just bump the major version number since its a breaking aPI change, but not really a big deal. Anyone using external golang code as a library should vendor his dependencies imho, and thus not have any problem with such changes. 😄

@JamesClonk
Copy link
Owner

@nstapelbroek Thanks a lot, looks good.
Regarding testing, you could also add one example using notes to the Test_Firewall_GetRules_Ok. But otherwise it's fine and LGTM 😃 👍

@JamesClonk JamesClonk merged commit ab236da into JamesClonk:master Mar 21, 2019
@JamesClonk
Copy link
Owner

Actually merged it already.
Again, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants