grater: add basic interface to interact with docker. #1758
Codecov Report
:x: Patch coverage is
71.56863% with 29 lines in your changes missing coverage. Please review.:white_check_mark: Project coverage is 62.85%. Comparing base (
b15d339) to head (4723c2e).:warning: Report is 1 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| grater/internal/dockercontainer/dockercontainer.go | 69.41% | 17 Missing and 9 partials :warning: |
| ...ater/internal/mockcontainer/mockdockercontainer.go | 82.35% | 3 Missing :warning: |
<details><summary>Additional details and impacted files</summary>
@@ Coverage Diff @@
## main #1758 +/- ##
==========================================
+ Coverage 62.65% 62.85% +0.20%
==========================================
Files 71 73 +2
Lines 4378 4480 +102
==========================================
+ Hits 2743 2816 +73
- Misses 1388 1408 +20
- Partials 247 256 +9
</details>
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
This implementation sounds good. But this doesn't include an interface, only the docker struct.
We mentioned having (and using) a Container interface that would allow having multiple implementation structs (including a mock one), and only use actual docker when we really need it.
IMHO, Controller is too generic. It could be many things. I would name this Container, even though it may not actually be a "container" in the docker sense.
Renamed the struct to Container, however the package controller cannot be renamed to container as it was causing a import conflict with docker/container.
Troublesome import pattern:
"github.com/docker/docker/api/types/container"
"go.opentelemetry.io/build-tools/grater/internal/container"
Now:
"github.com/docker/docker/api/types/container"
"go.opentelemetry.io/build-tools/grater/internal/controller"
You could import the docker container package with a specific name.
dockerContainer "github.com/docker/docker/api/types/container"
"go.opentelemetry.io/build-tools/grater/internal/container"
Only tests should have the integration build. Otherwise. We can't use them at runtime.
This is a mock container, not specific to docker. How about having it in grater/internal/mockcontainer?
package dockercontainer
// Package mockcontainer provides a mock implementation of the Container interface.
// MockDockerContainer is a mock implementation of the Container interface.
This interface shouldn't have a dependency on moby, it should be generic (only one implementation will use moby).
Also, we can improve that later, but I'd return structs rather than func or string, to make things more generic as well.
We're getting there 😸
Instead of client.ExecInspectResult I have updated to return int of exitcode as the usecase of this was to eventually know the exitcode of commands only, as we already return out separately as string.
Yes, its better to make a generic struct response like, ExecuteCommandResponse, which we can extend and modify as we want in future, how about we make a follow up PR for this?
Approved these changes.
Approved these changes.
dmathieu
amishhhaaaa
Part of #1528.