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 Firewall resource #333

Merged
merged 17 commits into from
Sep 2, 2021

Conversation

psinghal20
Copy link
Contributor

@psinghal20 psinghal20 commented Jun 8, 2021

Description of your changes

Fixes a part of #329

Some of the things I have assumed while defining types and controller that can be incorrect and would require a look:

  • The fields marked as OUTPUT_ONLY are to be treated as observations.
  • The fields ForceSendFields, NullFields and ServerResponse in google API types can be ignored for our use case.
  • All the comments in Type fields are directly used from google API and were a little verbose.

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

This code has primarily been tested locally using the example file attached with this change. I have also added unit tests similar to what we have for other compute resources.

@psinghal20 psinghal20 force-pushed the firewall-resource branch 2 times, most recently from e10a836 to c6ce334 Compare June 8, 2021 22:03
@psinghal20 psinghal20 changed the title Firewall resource Add Firewall resource Jun 8, 2021
Copy link
Member

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

This is looking really great @psinghal20! A few comments below and it would be great to also add some unit tests for the firewall client :)

container.SetupCluster,
container.SetupGKECluster,
Copy link
Member

Choose a reason for hiding this comment

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

I believe this may have been inadvertently added during rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I think I messed up while rebasing the master to fix the conflicts, I will fix this up, and I think ideally it should just be container.SetupCluster. My bad, I will fix this up.

type FirewallLogConfig struct {
// Enable: This field denotes whether to enable logging for a particular
// firewall rule.
Enable bool `json:"enable,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

If this is optional it should be *bool and marked with + optional. However, sometimes when there is a single field in an embedded struct I will opt for making it required since the embedded struct really shouldn't be provided if the only field it supports is not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I agree with that. I have made FirewallLogConfig an optional object but made Enable as required and removed omitempty for it.

apis/compute/v1beta1/firewall_types.go Outdated Show resolved Hide resolved
apis/compute/v1beta1/firewall_types.go Outdated Show resolved Hide resolved
@psinghal20
Copy link
Contributor Author

Hi @hasheddan, I have resolved all the above comments and added some small unit tests for firewall client code which helped uncover an issue in the generateFirewall method. 😬

Copy link
Member

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

@psinghal20 was revisiting this PR and I noticed this resource is being introduced at v1beta1, but we typically introduced new resources at v1alpha1, would you mind updating?

Copy link
Contributor

@turkenh turkenh left a comment

Choose a reason for hiding this comment

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

@psinghal20, first of all, sorry for the long review process but I hope there will be some improvement in the near future.
Your PR looking very good and thanks a lot for your contribution 💪

While testing on my side, I observed some missing pieces which I added as comments.

@psinghal20 was revisiting this PR and I noticed this resource is being introduced at v1beta1, but we typically introduced new resources at v1alpha1, would you mind updating?

I also noticed you already moved to v1alpha1 but didn't register to schema which causes controller to fail at startup. Basically, we just need the following patch:

diff --git a/apis/gcp.go b/apis/gcp.go
index 14c59b3..269efbe 100644
--- a/apis/gcp.go
+++ b/apis/gcp.go
@@ -21,6 +21,7 @@ import (
        "k8s.io/apimachinery/pkg/runtime"

        cachev1beta1 "github.com/crossplane/provider-gcp/apis/cache/v1beta1"
+       computev1alpha1 "github.com/crossplane/provider-gcp/apis/compute/v1alpha1"
        computev1beta1 "github.com/crossplane/provider-gcp/apis/compute/v1beta1"
        containerv1beta1 "github.com/crossplane/provider-gcp/apis/container/v1beta1"
        containerv1beta2 "github.com/crossplane/provider-gcp/apis/container/v1beta2"
@@ -41,6 +42,7 @@ func init() {
                gcpv1alpha3.SchemeBuilder.AddToScheme,
                gcpv1beta1.SchemeBuilder.AddToScheme,
                cachev1beta1.SchemeBuilder.AddToScheme,
+               computev1alpha1.SchemeBuilder.AddToScheme,
                computev1beta1.SchemeBuilder.AddToScheme,
                containerv1beta2.SchemeBuilder.AddToScheme,
                containerv1beta1.SchemeBuilder.AddToScheme,

pkg/controller/compute/firewall.go Outdated Show resolved Hide resolved
pkg/controller/compute/firewall.go Outdated Show resolved Hide resolved
pkg/clients/firewall/firewall.go Outdated Show resolved Hide resolved
@psinghal20
Copy link
Contributor Author

Hi @turkenh, I have resolved the above-mentioned comments. Please take a look, thanks!

@turkenh
Copy link
Contributor

turkenh commented Aug 31, 2021

@psinghal20 thanks, looking good but there seem to be some linter errors.
Could you check them?

@fahedouch
Copy link
Contributor

Hi teams,

thank you for your work @psinghal20 . @hasheddan @turkenh we really need this feature, any idea in which release it will land?

This commit adds the types and generated files for the Firewall managed
resource.

Signed-off-by: Pratyush Singhal <[email protected]>
refactor for firewall resource

Signed-off-by: Pratyush Singhal <[email protected]>
@psinghal20
Copy link
Contributor Author

Hi @turkenh, I have updated the PR, the change required a rebase with the master. I have updated some of the tests accordingly, and removed the test case checking the Kubernetes resource update which we removed here. Let me know if anything else is required, thanks! 😄

Copy link
Contributor

@turkenh turkenh left a comment

Choose a reason for hiding this comment

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

Great work @psinghal20, thanks!

@turkenh turkenh merged commit 95d1725 into crossplane-contrib:master Sep 2, 2021
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.

4 participants