Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This partially addresses 1409.
This is taking the majority of the
pkg/package fromanchore/grype-dband migrating it to here. This is mainly a lift-and-shift of thebuildandpackageaspects of grype-db (pullwill remain in grype-db).What's being added to grype
A similar question, what is NOT being added to grype:
pullprocess in grype-dbWhy do this?
The grype-db lib has a lot of code that is responsible for taking data and writing it to the DB. Today the DB schema and surrounding code lives in the grype repo. This can lead to odd situations where you've made a change to the DB code in grype and released it but it doesn't function practically in the grype-db repo, what is responsible for making production DBs. This is the first step in moving all of the logic needed to write to a DB in one spot, so that we can catch these kinds of issues as early as possible.
Unit/Integration tests could benefit from being able to build realistic DBs from test fixture data in the same manner that we build DBs in production. Today we utilize a mocking layer, which is very cumbersome and not providing a lot of value. By cumbersome, I mean that it takes many lines of code to express a test + test-fixture (which needs to be manually written). By "not providing a lot of value" I mean that it is easy to write a test that will pass but does not reflect what will happen in production (thus is not a good safety net to continue to develop against).
Simplifies development workflow. Instead of needing to implement logic across two repos, it's implemented in one (grype). Grype-db still needs to pull in the changes, but only via a go-module bump, not with additional code/test review.
Questions
Will we migrate the remaining grype-db functionality (commands) into grype?... Maybe. There are good reasons for and against this. The most minimal/impactful action is to get the underlying DB writing functionality migrated to grype in order to improve our test posture.
Does this refactor tests with a new DB build infrastructure? Not yet, that will be a follow up PR(s).
Does this internalize the new API? Not yet, only a few areas have been put into
internalpackages. This will be a focus of the grype 1.0 work as a whole (more things will be put intointernalover time).Will this new code be removed from grype-db? Yes.