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

Restructure database folder #721

Merged
merged 16 commits into from
Mar 13, 2019
Merged

Restructure database folder #721

merged 16 commits into from
Mar 13, 2019

Conversation

KeyboardNerd
Copy link
Contributor

@KeyboardNerd KeyboardNerd commented Feb 27, 2019

  • one pgsql data model per folder, and one table per file
  • one data model per file

@KeyboardNerd KeyboardNerd changed the title (WIP) database: Restructure database folder Restructure database folder Mar 6, 2019
@KeyboardNerd KeyboardNerd added lifecycle/preserve kind/cleanup no functional changes, only reorganization labels Mar 7, 2019
Copy link
Contributor

@jzelinskie jzelinskie left a comment

Choose a reason for hiding this comment

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

I tried not to nitpick existing code.

database/pgsql/pgsession.go Outdated Show resolved Hide resolved
database/pgsql/pgsession.go Show resolved Hide resolved
// features and processors used to scan the ancestry.
func (tx *pgSession) UpsertAncestry(a database.Ancestry) error {
return ancestry.UpsertAncestry(tx.Tx, a)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these are all basically doing the same thing, I'll often keep the entire thing on one line and stack them all up.

func (tx *pgSession) UpsertAncestry(a database.Ancestry) error { return ancestry.UpsertAncestry(tx.Tx, a) }
func (tx *pgSession) FindAncestry(name string) (database.Ancestry, bool, error) { return ancestry.FindAncestry(tx.Tx, name) }
func (tx *pgSession) PersistDetectors(detectors []database.Detector) error { return detector.PersistDetectors(tx.Tx, detectors) }
func (tx *pgSession) PersistFeatures(features []database.Feature) error { return feature.PersistFeatures(tx.Tx, features) }
func (tx *pgSession) PersistNamespacedFeatures(features []database.NamespacedFeature) error { return feature.PersistNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) CacheAffectedNamespacedFeatures(features []database.NamespacedFeature) error { return vulnerability.CacheAffectedNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) FindAffectedNamespacedFeatures(features []database.NamespacedFeature) ([]database.NullableAffectedNamespacedFeature, error) { return vulnerability.FindAffectedNamespacedFeatures(tx.Tx, features) }
func (tx *pgSession) PersistNamespaces(namespaces []database.Namespace) error { return namespace.PersistNamespaces(tx.Tx, namespaces) }
...

It makes it clear that there isn't really logic going on here, and that everything is boilerplate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gofmt doesn't like that idea

Copy link
Contributor

Choose a reason for hiding this comment

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

database/pgsql/pgsession.go Outdated Show resolved Hide resolved
@KeyboardNerd
Copy link
Contributor Author

KeyboardNerd commented Mar 13, 2019

rebased to master, hope no issues because of merge conflict
update commit addressed the comments, it will be rebased.

- assertion.go assertions used in pgsql tests
- data.go contains go representation of data.sql
- testdb.go contains test db/tx creation logic
- testutil.go contains misc other things
- pgsql/util/error.go contains error handling logic
- pgsql/page/page.go contains the page struct
- pgsql/monitoring contains the prometheus logic
- pgsql/pgsession contains the pgsession struct
- Tests in complex_test.go are now in corresponding test files.
- Pgsql_test is partially moved to testutil/testdb.go
@KeyboardNerd KeyboardNerd merged commit 2c7838e into quay:master Mar 13, 2019
@KeyboardNerd KeyboardNerd deleted the cache branch March 13, 2019 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup no functional changes, only reorganization
Development

Successfully merging this pull request may close these issues.

None yet

2 participants