Move the inspect code away from the image service#43680
Move the inspect code away from the image service#43680thaJeztah merged 1 commit intomoby:masterfrom
Conversation
tianon
left a comment
There was a problem hiding this comment.
FWIW, I found this significantly easier to review in my terminal with diff.colorMoved enabled so I could see that it's something like 99% moved code and a tiny fraction of actually modified bits (hopefully GitHub implements "moved code" detection eventually 😅).
|
The build failure is not related: If someone would be so kind and kick that job again :) |
api/server/router/image/image.go
Outdated
| // NewRouter initializes a new image router | ||
| func NewRouter(backend Backend) router.Router { | ||
| r := &imageRouter{backend: backend} | ||
| func NewRouter(backend Backend, referenceBackend referenceBackend, imageStore imageStore, layerStore layer.Store) router.Router { |
There was a problem hiding this comment.
This signature is a bit "odd"; NewRouter() is exported, but the arguments it takes are non-exported interfaces; should those be exported, or should this take the interfaces that they already implement? (i.e. image.Store, reference.Store? 🤔
There was a problem hiding this comment.
Indeed, I looked at the Backend interface that only references the methods needed by the router and thought I'd do the same, but then put the wrong visibility. I'll put image.Store and reference.Store as dependencies
The LoopkupImage method is only used by the inspect image route and returns an api/type struct. The depenency to api/types of the daemon/images package is wrong, the daemon doesn't need to know about the api types. Signed-off-by: Djordje Lukic <[email protected]>
e98aab2 to
b4ffe3a
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
failure is codecov/patch, which we disabled on master
- What I did
The LoopkupImage method is only used by the inspect image route and
returns an api/type struct. The depenency to api/types of the
daemon/images package is wrong, the daemon doesn't need to know about
the api types.
This is a first step in making the image service smaller, it has too many methods as is:
And all of these either take some
api/typestruct as a parameter or return one:I would like to take a closer look at all of those and either change the types returned or move the methods around. Splitting all of this code will make the image service make more sense, as is, it's too large and does too many things.
- How I did it
Copied the code over to the route handler
- How to verify it
- A picture of a cute animal (not mandatory but encouraged)
