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

Versions updates #11

Merged
merged 2 commits into from
May 8, 2024
Merged

Versions updates #11

merged 2 commits into from
May 8, 2024

Conversation

JustinKuli
Copy link
Owner

Versions updates, and various other housekeeping items.

JustinKuli added 2 commits May 8, 2024 02:01
Much cleaner YAML from kustomize, and some cleanup in configuration for
golang-ci. Kubernetes 1.30 wasn't fully working in things here yet, it
seemed like some wrinkles inside of dependencies. But Kubernetes 1.29
comes with an extra configmap to consider during test setup.

Makefile organization was slightly to help with tracking the versions of
utilities.

Signed-off-by: Justin Kulikauskas <[email protected]>
More formatting and scanning. The github actions files for these checks
has been combined, and will run only on push, removing the duplicated
checks that appeared in Pull Requests.

Also cleans up some oddities found with GOPATH, which resolved other
oddities with coverage commands.

Signed-off-by: Justin Kulikauskas <[email protected]>
Copy link

github-actions bot commented May 8, 2024

Code Coverage Report for this branch (might be slow to update): Go Coverage

Copy link

github-actions bot commented May 8, 2024

PR Review 🔍

⏱️ Estimated effort to review [1-5]

2, because the PR primarily involves updates to dependencies, minor refactoring, and configuration changes. The changes are straightforward and mostly involve version bumps and minor syntax adjustments.

🏅 Score

85

🧪 Relevant tests

No

⚡ Possible issues

Possible Bug: The removal of the "+build !ignore_autogenerated" line in the generated files could potentially affect the build process if the build tooling relies on these tags.

Dependency Management: The PR updates several dependencies to newer versions. While this is generally good practice, it should be verified that these updates do not introduce any breaking changes or compatibility issues with the existing codebase.

🔒 Security concerns

No


on: [push, pull_request]
on: [push]
Copy link

Choose a reason for hiding this comment

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

Suggestion: Consider adding the pull_request event to the on trigger for the GitHub Actions workflow to ensure that checks are also run on pull requests, not just on pushes to the repository. This is important for catching issues before they are merged into the main branch. [enhancement]

Suggested change
on: [push]
on: [push, pull_request]

Comment on lines 9 to 13
disable:
- bodyclose
- copyloopvar # prefer old style for now, more reliable across various scanners
- cyclop
- deadcode #deprecated
Copy link

Choose a reason for hiding this comment

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

Suggestion: Re-enable the err113 linter to enforce consistent error handling practices across the codebase. This linter checks for errors that are not created or wrapped with %w in fmt.Errorf, which is a common best practice in Go for error handling. [best practice]

Suggested change
disable:
- bodyclose
- copyloopvar # prefer old style for now, more reliable across various scanners
- cyclop
- deadcode #deprecated
disable:
- bodyclose
- cyclop
- deadcode #deprecated
- depguard

Comment on lines 75 to 76
.PHONY: manifests
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
Copy link

Choose a reason for hiding this comment

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

Suggestion: Add a clean-up target in the Makefile to remove the generated binaries and other build artifacts. This helps in maintaining a clean workspace and can be useful before rebuilds to ensure that no stale artifacts are used. [maintainability]

Suggested change
.PHONY: manifests
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
.PHONY: clean
clean:
rm -rf $(LOCAL_BIN)/*
echo "Cleaned up build artifacts."
.PHONY: manifests
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.

Copy link
Owner Author

Choose a reason for hiding this comment

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

If it was any more complicated than one directory to rm, I would consider this.

Comment on lines +39 to +43
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
Copy link

Choose a reason for hiding this comment

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

Suggestion: Add a step to cache dependencies in the GitHub Actions workflow to speed up builds. This can significantly reduce build times by avoiding redundant downloads of dependencies that haven't changed. [performance]

Suggested change
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'

Copy link
Owner Author

Choose a reason for hiding this comment

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

The setup-go action does this automatically based on the go.sum. I considered doing this for the other binaries that are separately installed, but when the go.sum cache is hit (as in, all dependencies to build the program are already cached), the actions take less than 2 minutes each. And that's good enough for me to not worry about the additional cache setup.

Comment on lines +89 to +92
fmt: $(GOFUMPT) $(GCI)
go mod tidy
find . -not \( -path "./.go" -prune \) -name "*.go" | xargs $(GOFUMPT) -l -w
find . -not \( -path "./.go" -prune \) -name "*.go" | xargs $(GCI) write --skip-generated -s standard -s default -s localmodule
Copy link

Choose a reason for hiding this comment

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

Suggestion: Use more specific patterns for find commands in the fmt target to avoid unnecessary processing of non-Go files and directories, improving the efficiency of the formatting process. [performance]

Suggested change
fmt: $(GOFUMPT) $(GCI)
go mod tidy
find . -not \( -path "./.go" -prune \) -name "*.go" | xargs $(GOFUMPT) -l -w
find . -not \( -path "./.go" -prune \) -name "*.go" | xargs $(GCI) write --skip-generated -s standard -s default -s localmodule
fmt: $(GOFUMPT) $(GCI)
go mod tidy
find . -type f -name '*.go' ! -path './.go/*' | xargs $(GOFUMPT) -l -w
find . -type f -name '*.go' ! -path './.go/*' | xargs $(GCI) write --skip-generated -s standard -s default -s localmodule

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not touching these unless I have to.

Comment on lines +20 to 23
resources:
- ../crd
- ../rbac
- ../manager
Copy link

Choose a reason for hiding this comment

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

Suggestion: Replace 'resources' with 'bases' to maintain consistency with kustomize terminology and ensure correct processing of base resources. [maintainability]

Suggested change
resources:
- ../crd
- ../rbac
- ../manager
bases:
- ../crd
- ../rbac
- ../manager

Comment on lines 131 to 133
enum:
- low
- Low
Copy link

Choose a reason for hiding this comment

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

Suggestion: Consider using consistent capitalization for enum values to avoid potential issues with case-sensitive comparisons. The severity field has mixed capitalization for the same values. [best practice]

Suggested change
enum:
- low
- Low
severity:
enum:
- Low

Comment on lines 119 to 123
enum:
- Inform
- inform
- Enforce
- enforce
Copy link

Choose a reason for hiding this comment

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

Suggestion: The remediationAction enum values are duplicated with different cases (e.g., 'Inform' and 'inform'). It's recommended to keep enum values consistent to prevent confusion and potential bugs in case-sensitive environments. [bug]

Suggested change
enum:
- Inform
- inform
- Enforce
- enforce
remediationAction:
enum:
- Inform
- Enforce

Comment on lines +52 to +54
description: |-
NamespaceSelector indicates which namespaces on the cluster this policy
should apply to, when the policy applies to namespaced objects.
Copy link

Choose a reason for hiding this comment

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

Suggestion: To improve the clarity and maintainability of the YAML, consider removing the redundant description fields that have been added to properties where the description merely repeats the property name or is overly verbose without adding clarity. [maintainability]

Suggested change
description: |-
NamespaceSelector indicates which namespaces on the cluster this policy
should apply to, when the policy applies to namespaced objects.
description: |-
Indicates applicable namespaces for the policy.

Comment on lines +172 to +174
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
Copy link

Choose a reason for hiding this comment

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

Suggestion: The description for operator and values in matchExpressions is verbose and could be simplified to enhance readability and maintainability. [enhancement]

Suggested change
description: |-
operator represents a key's relationship to a set of values.
Valid operators are In, NotIn, Exists and DoesNotExist.
description: |-
Defines the relationship between a key and values. Valid operators: In, NotIn, Exists, DoesNotExist.

github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Copy link

Choose a reason for hiding this comment

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

Suggestion: Consider using consistent versioning for direct and indirect dependencies to avoid potential incompatibilities. For example, github.com/golang/protobuf and google.golang.org/protobuf are both updated, but they should be kept at compatible versions to prevent issues in serialization or compatibility with other libraries. [maintainability]

@JustinKuli
Copy link
Owner Author

AI Suggestions Score

Some suggestions were very similar, so I did not count them multiple times.

Category Count Comment
Great 0
Good 6 Surprisingly useful stylistic comments. If I could change the API docs and enums, I would.
Bad 3 Inaccuracies with changing kustomization options
Terrible 2 Somewhat bizarre comments

@JustinKuli JustinKuli merged commit 166473c into main May 8, 2024
5 checks passed
@JustinKuli JustinKuli deleted the versions-updates branch May 8, 2024 03:38
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.

1 participant