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

Refactor and add tests, implement a feature #7

Merged
merged 1 commit into from
Jun 8, 2022

Conversation

zregvart
Copy link
Member

@zregvart zregvart commented Jun 3, 2022

What we didn't have in the bash or the ec-cli was the ability to
have multiple sources of policy (Rego) files, e.g. from multiple git
repositories or branches. Now this is available in the ec-cli.

This does however refactor the implementation into smaller more
manageable files, hopefully makes it easier to maintain.

Tests were added.

Ref. https://issues.redhat.com/browse/HACBS-372

@robnester-rh
Copy link
Contributor

I've typically seen the internal directory at the top level. This golang-standards project layout repo is always really useful.

@simonbaird
Copy link
Member

Lgtm fwiw.

return clnt, err
}

func (p *policyEvaluator) fetchEnterpriseContractPolicy(ctx context.Context) (*ecp.EnterpriseContractPolicy, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is a function defined for a struct in another file. I understand the relation between this function and the kubernets_client.go file, but does it hurt readability by having functions separated like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Missed the refactoring there, I wanted a separate struct for k8s, that should not belong on policyEvaluator

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh okay gotcha

Copy link
Contributor

@robnester-rh robnester-rh 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 left a few notes.

A few code style issues that should be addressed:

  • go uses camel case. no snake casing.
  • all functions should have appropriate doc strings
  • ensure a blank line between license boilerplate and package declaration to avoid tools such as golint from complaining.

@zregvart
Copy link
Member Author

zregvart commented Jun 7, 2022

I've typically seen the internal directory at the top level. This golang-standards project layout repo is always really useful.

https://github.com/golang-standards/project-layout#internal

Note that you are not limited to the top level internal directory. You can have more than one internal directory at any level of your project tree.

What we didn't have in the `bash` or the `ec-cli` was the ability to
have multiple sources of policy (Rego) files, e.g. from multiple git
repositories or branches. Now this is available in the `ec-cli`.

This does however refactor the implementation into smaller more
manageable files, hopefully makes it easier to maintain.

Tests were added.

Ref. https://issues.redhat.com/browse/HACBS-372
@robnester-rh robnester-rh self-requested a review June 8, 2022 14:59
@robnester-rh robnester-rh merged commit 8280cad into enterprise-contract:main Jun 8, 2022
@zregvart zregvart deleted the issue/HACBS-372 branch June 8, 2022 15:37
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