Skip to content

refactor(storage): move storage init from controller to storagefactory#1345

Closed
eusebiu-constantin-petu-dbk wants to merge 1 commit into
project-zot:mainfrom
eusebiu-constantin-petu-dbk:storage_factory
Closed

refactor(storage): move storage init from controller to storagefactory#1345
eusebiu-constantin-petu-dbk wants to merge 1 commit into
project-zot:mainfrom
eusebiu-constantin-petu-dbk:storage_factory

Conversation

@eusebiu-constantin-petu-dbk

Copy link
Copy Markdown
Collaborator

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Comment thread pkg/api/controller.go
func compareImageStore(root1, root2 string) bool {
isSameFile, err := config.SameFile(root1, root2)
// This error is path error that means either of root directory doesn't exist, in that case do string match
storeController, err := storagefactory.New(c.Config, linter, c.Metrics, c.Log)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really want this to be a storage.New() ... no factory pls.

"zotregistry.io/zot/pkg/storage/s3"
)

func New(config *config.Config, linter common.Lint, metrics monitoring.MetricServer,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not promote this up to pkg/storage/?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

because it needs to import local/s3 for constructors, but at the same time local/s3 needs common code (which needs storage interface).

@eusebiu-constantin-petu-dbk
eusebiu-constantin-petu-dbk force-pushed the storage_factory branch 3 times, most recently from 5992869 to 823792f Compare April 10, 2023 15:00
@codecov

codecov Bot commented Apr 10, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1345 (212c28b) into main (3510ef0) will increase coverage by 0.00%.
The diff coverage is 93.60%.

@@           Coverage Diff           @@
##             main    #1345   +/-   ##
=======================================
  Coverage   90.50%   90.51%           
=======================================
  Files          97       98    +1     
  Lines       21503    21509    +6     
=======================================
+ Hits        19462    19468    +6     
  Misses       1526     1526           
  Partials      515      515           
Impacted Files Coverage Δ
pkg/storage/storagefactory/storage_factory.go 88.80% <88.80%> (ø)
pkg/storage/storage_controller.go 94.11% <93.10%> (-5.89%) ⬇️
pkg/api/config/config.go 89.18% <100.00%> (ø)
pkg/api/controller.go 94.07% <100.00%> (+1.30%) ⬆️
pkg/api/routes.go 94.48% <100.00%> (ø)
pkg/cli/root.go 96.42% <100.00%> (ø)
pkg/extensions/sync/utils.go 90.17% <100.00%> (ø)
pkg/storage/cache.go 92.00% <100.00%> (+20.57%) ⬆️
pkg/storage/common/common.go 96.07% <100.00%> (ø)
pkg/storage/local/local.go 82.56% <100.00%> (-0.02%) ⬇️
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
@rchincha

rchincha commented Apr 26, 2023

Copy link
Copy Markdown
Contributor

pkg/storage/types <- all interfaces
pkg/storage/common <- common underlying impl
pkg/storage/[local,s3,dynamodb, ...] <- individual components impl the storage "type"
pkg/storage/storage.go <- New()

Remove keyword "factory"

pkg/api/controller only calls storage.New(config)

@andaaron

Copy link
Copy Markdown
Contributor

Superseded by #1459

@andaaron andaaron closed this May 24, 2023
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.

3 participants