-
Notifications
You must be signed in to change notification settings - Fork 71
Refactor into distinct packages to prep for adding firewall support to Nodes #186
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
Conversation
edc6484 to
d897018
Compare
cloud/linode/client/client.go
Outdated
| var _ Client = (*linodego.Client)(nil) | ||
|
|
||
| func newLinodeClient(token, ua, apiURL string) (*linodego.Client, error) { | ||
| func NewLinodeClient(token, ua, apiURL string) (*linodego.Client, 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.
Since this function is now exported, I would recommend adding some godoc.
This is a bit of a nit, but client.NewLinodeClient kind of stutters. Maybe calling the function New would flow a bit more nicely.
Lastly, please expand the ua argument to userAgent, so that even without godoc, the argument's purpose is clear.
| @@ -1,6 +1,6 @@ | |||
| package linode | |||
| package client | |||
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 a heads up: moving this file into a new package would constitute a major version bump of this module. However, this module's last-tagged version is still < v1, so it should be fine. Just be aware that this may break downstream users of this module.
cloud/linode/firewall/firewalls.go
Outdated
| var newFirewallID int | ||
| var err error | ||
|
|
||
| fwID := service.GetAnnotations()[annotations.AnnLinodeCloudFirewallID] | ||
| newFirewallID, err = strconv.Atoi(fwID) |
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.
nit: There is no need to declare newFirewallID and err this high up.
| var newFirewallID int | |
| var err error | |
| fwID := service.GetAnnotations()[annotations.AnnLinodeCloudFirewallID] | |
| newFirewallID, err = strconv.Atoi(fwID) | |
| fwID := service.GetAnnotations()[annotations.AnnLinodeCloudFirewallID] | |
| newFirewallID, err := strconv.Atoi(fwID) |
cloud/linode/firewall/firewalls.go
Outdated
| err = l.Client.DeleteFirewallDevice(ctx, existingFirewallID, deviceID) | ||
| if err != 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.
nit:
| err = l.Client.DeleteFirewallDevice(ctx, existingFirewallID, deviceID) | |
| if err != nil { | |
| if err := l.Client.DeleteFirewallDevice(ctx, existingFirewallID, deviceID); err != 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.
updated and in a few other spots in this file too
nesv
left a comment
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.
LGTM
General:
Pull Request Guidelines:
This PR moves out the Firewall logic into its own
firewallpackage so it can be used for managing Firewalls for both LoadBalancer Services (NodeBalancers) and Nodes.I also split out the annotations and client since I was getting an import cycle with just the existing
linodeand newfirewallpackages.The change to add support for Firewalls based on Node annotations will be tackled in a separate PR.