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

Support to Add, Remove and List ACLs (Fixes #6) #26

Conversation

jograca
Copy link
Collaborator

@jograca jograca commented Jan 20, 2022

Description of your changes

This Pull Request adds feature complete ACL support to Add, Remove and List ACLs.
Fixes #6

I have:

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

How has this code been tested

Automated tests are forthcoming

  1. Created an ACL by applying examples/acl/acl.yaml
  2. Verified by running kcl admin acl describe --type any --pattern match --op any --perm any
  3. Updated ACL by changing a Principle in examples/acl/acl.yml
  4. Applied the ACL and noticed the Update threw an error
  5. Deleted ACL by deleting examples/acl/acl.yaml
  6. Verified by same process as bullet 2

jograca and others added 16 commits January 21, 2022 09:14
Signed-off-by: Hasan Turken <[email protected]>
ACL fixes and readme updates
Signed-off-by: Jon Graca <[email protected]>
apis/acl/v1alpha1/acl_types.go Show resolved Hide resolved
internal/clients/kafka/acl/acl.go Outdated Show resolved Hide resolved
internal/clients/kafka/acl/acl.go Outdated Show resolved Hide resolved
apis/acl/v1alpha1/acl_types.go Outdated Show resolved Hide resolved
internal/clients/kafka/acl/acl.go Outdated Show resolved Hide resolved
internal/controller/acl/acl.go Outdated Show resolved Hide resolved
internal/controller/acl/acl.go Outdated Show resolved Hide resolved
internal/controller/acl/acl.go Outdated Show resolved Hide resolved
internal/controller/acl/acl.go Outdated Show resolved Hide resolved
internal/controller/acl/acl.go Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Signed-off-by: Mallory Quaintance <[email protected]>
Copy link
Collaborator

@stevendborrelli stevendborrelli left a comment

Choose a reason for hiding this comment

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

Overall it looks good!

Need to run make reviewable test, as there are some linting errors.

apis/acl/v1alpha1/acl_types.go:31: File is not `gofmt`-ed with `-s` (gofmt)
        ResourceName    string `json:"resourceName"`
internal/clients/kafka/acl/acl.go:19: File is not `gofmt`-ed with `-s` (gofmt)
        ResourceName                      string
internal/controller/acl/acl.go:194: File is not `gofmt`-ed with `-s` (gofmt)
        return managed.ExternalCreation{}, acl.Create(ctx, c.kafkaClient, generated)
internal/clients/kafka/topic/topic_test.go:6: File is not `goimports`-ed with -local github.com/crossplane-contrib/provider-kafka (goimports)
        "github.com/crossplane-contrib/provider-kafka/apis/topic/v1alpha1"
internal/controller/acl/acl.go:146:11: ineffectual assignment to `err` (ineffassign)
        extname, err := acl.ConvertFromJSON(meta.GetExternalName(cr))

apis/acl/v1alpha1/acl_types.go Outdated Show resolved Hide resolved
apis/acl/v1alpha1/acl_types.go Outdated Show resolved Hide resolved
internal/clients/kafka/acl/acl.go Outdated Show resolved Hide resolved
internal/clients/kafka/acl/acl.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@stevendborrelli stevendborrelli left a comment

Choose a reason for hiding this comment

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

I've approved it, but there is one linting error that comes up. (See my comment).

}

// List lists all the ACLs in Kafka
func List(ctx context.Context, cl *kadm.Client, accessControlList *AccessControlList) (*AccessControlList, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Linting is coming up with one more issue cyclomatic complexity 11 of func List is high (> 10)

Cyclomatic complexity is used as a metric for the complexity of tests required and we see it often in controllers. (see https://github.com/fzipp/gocyclo).

Maybe in future releases some of the logic can be factored out into functions.

To fix, add the // nolint:gocyclo comment to the function like so:

func List(ctx context.Context, cl *kadm.Client, accessControlList *AccessControlList) (*AccessControlList, error) { // nolint:gocyclo

@marshmallory marshmallory merged commit a45cfa0 into crossplane-contrib:main Mar 9, 2022
@marshmallory marshmallory deleted the feature/support-to-add-remove-and-list-acls branch March 9, 2022 20:57
@elohmrow
Copy link

elohmrow commented Mar 9, 2022

🎉

@turkenh
Copy link
Collaborator

turkenh commented Mar 9, 2022

🙌

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

Successfully merging this pull request may close these issues.

Support to Add, Remove and List ACLs
7 participants