8000 Move container ops to `command.Command` by michaeldwan · Pull Request #2307 · replicate/cog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Move container ops to command.Command #2307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 13, 2025
Merged

Move container ops to command.Command #2307

merged 10 commits into from
May 13, 2025

Conversation

michaeldwan
Copy link
Member
@michaeldwan michaeldwan commented May 8, 2025

This change is part of the ongoing work to abstract all docker cli calls behind the command.Command interface. Once complete (almost there!) we can replace the cli client with one that connects directly to the daemon and exposes a swath of low level api calls we need.

This PR:

  • moves run (execute and wait for completion) and start (execute and detach) to the interface
  • uses the client's ContainerInspect function to get a container port rather than the docker port command
  • adds mockery to codegen interface mocks for testing (just giving it a try, works okay so far, will rip out if it's a pita)
  • adds tests for handling ports in container inspect responses

The only intentional change to behavior is that the entire host environment is no longer passed to containers by default. The motivation for this change is to reduce hard-to-debug foot guns caused by host env invisibly altering the container. Going forward the env passed to containers will be explicit.

@michaeldwan michaeldwan marked this pull request as ready for review May 12, 2025 20:49
@michaeldwan michaeldwan requested a review from a team May 12, 2025 21:18
Copy link
Contributor
@8W9aG 8W9aG left a comment

Choose a reason for hiding this comment

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

🙌 nice job!

@michaeldwan michaeldwan merged commit 1ba7667 into main May 13, 2025
38 of 39 checks passed
@michaeldwan michaeldwan deleted the md/docker-client branch May 13, 2025 00:13
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
danfairs pushed a commit to condensereality/cog that referenced this pull request May 14, 2025
* update GetPort to use inspect, codegen mocks for tests

* move `run.{Run, RunWithIO, RunDaemon}` to `command.Command`

* pass streams to run

* debug message when generating schema

* split run/start operations, fix io streams

* remove print statement that's breaking tests

* remove commended out code

* remove internalRunOptions

* Force linux/amd64, remove RunOptions.Platform

* add TODO for passing host env to container by default
Signed-off-by: Dan Fairs <dan@condensereality.com>
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
0