-
Notifications
You must be signed in to change notification settings - Fork 2.8k
refactor: move internal packages to internal/ directory #9606
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
base: main
Are you sure you want to change the base?
refactor: move internal packages to internal/ directory #9606
Conversation
00f0f8f to
55e85bb
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
55e85bb to
0330e3b
Compare
Move compliance, iac/providers, and iac/state to pkg/ as they are part of the public API. Keep clock, cloud, and policy in internal/ as they are internal implementation.
Export BuildComplianceReport and BuildSummary functions along with required types (Report, SummaryReport, ControlCheckResult, ControlCheckSummary) in pkg/compliance for external use.
- Replace mapfs.New() with fstest.MapFS in createDataFS() - Replace CycloneDXWriter with k8s.Write in cluster controller - Update compliance imports to use public types package - Update go.mod to use Trivy fork with public API changes TODO: Update go.mod to use main branch after aquasecurity/trivy#9606 merges
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.
This file appears as newly created on the GitHub UI because the proportion of import statements is high compared to the total number of lines, resulting in a low similarity to the original file, but it is correctly recognized as a rename in git.
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.
same
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.
ditto
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.
ditto
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.
ditto
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.
ditto
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.
same
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.
same
internal/iac/state/state.go
Outdated
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.
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.
I left comment about aws config.
Also it looks like we can move dependency and vulnerability packages.
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.
trivy-aws uses this package - https://github.com/aquasecurity/trivy-aws/blob/6e28982904fb3a988cfdfcd41a63ac0caac6e8d4/pkg/commands/run.go#L32
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.
The default settings and trivial logic are used to load the AWS config, so I think it can be reimplemented in trivy-aws.
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.
We use Digest in Package.
Can we move this package into internal?
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.
As we discussed earlier, let's leave pkg/iac/terraform public for now.
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.
Ditto, let's leave pkg/iac/scanners/terraform public for now.

Description
pkg/tointernal/Background
Trivy is primarily distributed as a CLI tool, and using Trivy as a library is not recommended for community users. However, Aqua Security internally imports and uses Trivy as a library in our products. This refactoring helps us:
pkg/) that we maintain for backward compatibilityinternal/where we can refactor freely without worrying about breaking changesWhy now?
This refactoring was previously attempted in PRs #291 and #887 six years ago but was abandoned because:
internal/boundaryNow, Trivy has matured:
API Change Detection
We use go-apidiff to automatically detect API changes in PRs. With this refactoring:
go-apidiffautomatically excludesinternal/packages from analysispkg/Changes
pkg/tointernal/.golangci.yamland magefiles to reference correct pathsChecklist