Skip to content

feat: improve storage services#128

Merged
nikoksr merged 58 commits intomasterfrom
improve-storage-services
Jul 7, 2020
Merged

feat: improve storage services#128
nikoksr merged 58 commits intomasterfrom
improve-storage-services

Conversation

@nikoksr
Copy link
Copy Markdown
Collaborator

@nikoksr nikoksr commented Jul 7, 2020

Summary

Improve the storage services. Simpler structure, easier to use and support for more databases.

Proposed Changes

  • add editorconfig file
  • replace bare sql with gorm
  • add a makefile
  • add golangci-lint config
  • apply golangci-lint critics and recommendations
  • simplify project structure
  • add custom error types
  • many small changes and fixes

nikoksr added 30 commits July 1, 2020 23:43
Proji now uses gorm to power its main storage. Gorm simplifies proji's
code base vastly and allows usage of mysql, mssql, postgres and sqlite
databases as backend storage. Updates to the main config will follow
soon. Notice that the models which represent tables in the database also
changed and are not backwards compatible and definitly breaking.
Removed most of the tests after refactoring the storage package and will
do pretty much all tests of the repo in the very near future.
The makefile was adapted from
https://github.com/goreleaser/goreleaser/blob/master/Makefile and allows
you to setup the environment, build, format, lint and test the project
and list todo items from the code.
UnsupportedDatabaseDialectError decribes an error in the case that a
driver to a unsupported database dialect got passed.

See
https://gorm.io/docs/connecting_to_the_database.html#Supported-Databases
for a list of supported drivers.
In case of an unsupported database driver, the function will now return
a UnsupportedDatabaseDialectError. Previously the default case just set
the dialector to nil and returned an empty error.
The const TokenKeys in the code don't actually hold the token but the
config key under which the token may be found and included.
The main config now allows the specification of a custom database. You
can set the database.driver and database.dsn fields. Check the docs for
more informations. Defaults to 'sqlite3' as a driver and 'db/proji.sqlite3' as a dsn.
Renamed the env field 'Svc' to 'StorageService'.
nikoksr added 27 commits July 6, 2020 13:53
Changing back to the old working directory was executed by defer and its
error was thus ignored. defer is now wrapped in an anonymous function
where a potential error will be handled.
Cobra and Viper make you use global variables and init functions. So we
have to ignore the two linters in the cmd package.
Remove pkg directory and move its content to the root of the project.
Add an optional description with a maximum length of 255 characters.
Even though its not really useful; the name is used to create a project
so it should probably be stored too.
Replace the functions LoadAllClasses and LoadAllProjects with
LoadClasses and LoadProjects. The new functions take a spread string
array as parameter. If one or multiple inputs are given, the function
returns one or multiple classes/projects. If no input is given all
classes/projects will be returned.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #128 into master will decrease coverage by 38.94%.
The diff coverage is 7.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #128       +/-   ##
===========================================
- Coverage   55.99%   17.05%   -38.95%     
===========================================
  Files           8       35       +27     
  Lines         959     1466      +507     
===========================================
- Hits          537      250      -287     
- Misses        333     1200      +867     
+ Partials       89       16       -73     
Impacted Files Coverage Δ
cmd/class.go 100.00% <ø> (ø)
cmd/classAdd.go 1.66% <0.00%> (ø)
cmd/classExport.go 9.67% <0.00%> (ø)
cmd/classLs.go 11.76% <0.00%> (ø)
cmd/classRm.go 12.12% <0.00%> (ø)
cmd/classShow.go 5.88% <0.00%> (ø)
cmd/completion.go 100.00% <ø> (ø)
cmd/completionBash.go 40.00% <ø> (ø)
cmd/completionZsh.go 40.00% <ø> (ø)
cmd/init.go 3.57% <0.00%> (ø)
... and 55 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f3dd0c...a5fae4f. Read the comment docs.

@nikoksr nikoksr merged commit 310046a into master Jul 7, 2020
@nikoksr nikoksr deleted the improve-storage-services branch July 7, 2020 01:07
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.

2 participants