-
Notifications
You must be signed in to change notification settings - Fork 227
Create/use a runtime interface instead of direct calls to Docker #211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good direction! some small comments
lmk when it's ready to review (for real)
pkg/operations/start.go
Outdated
@@ -20,8 +21,14 @@ import ( | |||
) | |||
|
|||
func StartVM(vm *vmmd.VM, debug bool) error { | |||
// Get the Docker client | |||
dc, err := docker.GetDockerClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make all these calls use the global provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
pkg/runtime/docker/client.go
Outdated
StdinOnce: false, | ||
Env: nil, | ||
Cmd: nil, | ||
Healthcheck: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the unset options here to make sure the default values are used, and make it explicit what we set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they were just temporarily there while I figured out which ones to set.
pkg/source/docker.go
Outdated
reader, err := ds.exportCmd.StdoutPipe() | ||
func (ds *DockerSource) Reader() (rc io.ReadCloser, err error) { | ||
// Get the Docker client | ||
dc, err := docker.GetDockerClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global provider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Docker client's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks really good 👍
Rebase, fix the nits and we're ready to go!
var NetworkPlugin cni.NetworkPlugin | ||
|
||
func SetCNINetworkPlugin() (err error) { | ||
NetworkPlugin, err = cni.GetCNINetworkPlugin(Runtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok, but a bit misleading, as by default we don't use this provider in the codepath at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's currently only used on one place when using CNI networking, but at least it has its own provider now. Might rename it later if it causes extra confusion.
pkg/runtime/types.go
Outdated
type Interface interface { | ||
InspectImage(image string) (*ImageInspectResult, error) | ||
PullImage(image string) (io.ReadCloser, error) | ||
ExportImage(image string) (io.ReadCloser, string, error) | ||
GetNetNS(containerID string) (string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to GetContainerNetns()
and move to the container section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6e60eba.
pkg/runtime/types.go
Outdated
type Interface interface { | ||
InspectImage(image string) (*ImageInspectResult, error) | ||
PullImage(image string) (io.ReadCloser, error) | ||
ExportImage(image string) (io.ReadCloser, string, error) | ||
GetNetNS(containerID string) (string, error) | ||
RawClient() interface{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we do grouping here, move this last in its own section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6e60eba.
GetNetNS(containerID string) (string, error) | ||
RawClient() interface{} | ||
|
||
RunContainer(image string, config *ContainerConfig, name string) (string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add // TODO: AttachContainer()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6e60eba.
# Conflicts: # cmd/ignite/run/create.go # cmd/ignite/run/images.go # cmd/ignite/run/inspect.go # cmd/ignite/run/kernels.go # cmd/ignite/run/ps.go # pkg/metadata/imgmd/imgmd.go # pkg/metadata/kernmd/kernmd.go # pkg/metadata/metadata.go # pkg/operations/start.go # pkg/source/docker.go
FYI: made this regex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well!
pkg/runtime
instead of direct calls to Docker
This removes all direct calls to the
docker
binary in favor of thepkg/runtime
interface.pkg
refactoredcmd
refactored (excludingattach
)