Skip to content

Remove cmd/docker and other directories in cli/ in accordance with the new Moby project scope#32694

Merged
tiborvass merged 4 commits intomoby:masterfrom
tiborvass:cli_removal
May 5, 2017
Merged

Remove cmd/docker and other directories in cli/ in accordance with the new Moby project scope#32694
tiborvass merged 4 commits intomoby:masterfrom
tiborvass:cli_removal

Conversation

@tiborvass
Copy link
Contributor

@tiborvass tiborvass commented Apr 18, 2017

Moving the client-side binary to the https://github.com/docker/cli repository in accordance with the transition to the Moby project.

See #32691 and #32867 for context.

Starting with this commit, integration tests should no longer rely on
the docker cli, they should be API tests instead. For the existing tests
the scripts will use a frozen version of the docker cli with a
DOCKER_API_VERSION frozen to 1.30, which should ensure that the CI remains
green at all times.

To help contributors develop and test manually with a modified docker
cli, this commit also adds a DOCKER_CLI_PATH environment variable to the
Makefile. This allows to set the path of a custom cli that will be
available inside the development container and used to run the
integration tests.

Example on how to make changes to do iterative dev:

[docker/cli] $ make build # or make -f docker.Makefile build
[docker/cli] $ cd $GOPATH/src/github.com/moby/moby
[moby/moby] $ DOCKER_CLI_PATH=~/go/src/github.com/docker/cli/build/docker make shell
# docker -v     # this is your dev version of the docker cli
# ./hack/make.sh binary test-integration-cli    # to run tests against your custom docker cli

New workflow for PRs impacting the Docker CLI:

  • You can continue doing test & dev cycles in the dev container as shown in the example above.
  • When you are ready to submit the changes, you send a PR to moby/moby (in the monolith-less future, to the component itself), and write API tests to make sure the change makes sense in the backend
  • Once the PR is approved, you submit the CLI changes to the docker/cli repo with unit tests
  • Potentially, add more tests to https://github.com/docker/docker-e2e

Additionally, in order to get a green CI, the PR fixes a CGO_ENABLED envvar leak with our install-binaries.sh script, and modifies a Go build tag in pkg/term to ensure we catch the issue earlier next time.

@AkihiroSuda
Copy link
Member

How to test future moby features without CLI?

@krasi-georgiev
Copy link
Contributor

@AkihiroSuda hack/make/.fetch-test-client it seems that will be installed as binary

@AkihiroSuda
Copy link
Member

Docker product CLI could not be used for testing new features that are not available yet in Docker product.

How about renaming cli to testcli rather than completely removing it?

@dnephin
Copy link
Member

dnephin commented Apr 19, 2017

I think the idea would be to write tests that target the API instead of using the CLI to test everything. Writing tests against the API is actually a better idea because it helps verify the quality of the API design. Writing tests using the CLI hides mistakes in API design (and could even hide accidental breaking API changes).

The existing CLI will be available for running the existing tests, but new tests should either be unit tests or target the API.

@AkihiroSuda
Copy link
Member

Yes, I agree API-oriented testing is better, but I just thought manual ad-hoc testing using CLI is still effective, although it is not ideal.

A concrete example is my PR #26331 (introspection mount).
I guess reviewers would want to do ad-hoc testing manually via CLI rather than just checking CI result, because they would need to set random value to introspection-scope=... for testing security aspect.
(Ideally we should do fuzzing on CI, but fuzzing everything is not realistic)

@aaronlehmann
Copy link

aaronlehmann commented Apr 19, 2017 via email

@Vanuan
Copy link

Vanuan commented Apr 21, 2017

Docker product CLI could not be used for testing new features that are not available yet in Docker product.

Why not? If API stays the same, old client should work? If API changes it would be a different version and warrants a change in the cli repo?

@cpuguy83
Copy link
Member

With the goal of moby to split out everything from this repo other than core bits , I think this makes perfect sense although is going to be a rough transition to start off.
We do need to define in detail what will be split out and how, but this is an easy first step that will likely lead to a more well tested API and CLI.

That said, I think the API client library needs to live next to the API definition.
We can run CLI tests in the CLI repo or possibly more appropriately in an integration repo.

@shykes
Copy link
Contributor

shykes commented Apr 25, 2017

  • As others have said, moby tests can continue to use the Docker CLI, just as an external dependency instead of having it built-in.

  • Moving client libraries to docker/cli is temporary, in the near future I would like us to create docker/sdk with all official client libraries for multiple languages.

  • I hear you @cpuguy83 but we are not going to keep the client library next to the REST api implementation. That's because we are preparing to gradually move the focus away from the rest API, and instead focus on 1) the Docker SDK, and 2) the new component GRPC interfaces, similar to containerd & swarmd, that will gradually appear as we split up the engine.

So the SDK will gradually become the source of truth for Docker APIs, rather than the rest API.

(of course this can be implemented gradually and carefully, and without breaking existing tools)

@shykes
Copy link
Contributor

shykes commented Apr 25, 2017

One last point, on the moby side we want to remove client implementation BUT implement tools which can generate custom clients for your blueprint using the grpc definitions. Both client libraries and cli can be generated in that way.

@mavenugo
Copy link
Contributor

@tiborvass I think most of the comments above are for rapid-iterative-development and hence I think a bit more explanation on

The Makefile has been updated to allow bind-mounting the folder the cli
binary resides in, to allow for rapid iterative development.

and an example usage will help.

Makefile Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry if i'm not following, what's /usr/local/cli ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vieux a place i decided to bind mount the folder where the cli is. I need to bind mount the folder so that rebuilding the binary propagates inside the container.

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

I think docs/yaml needs to be added to docker/cli since it's being removed here, otherwise I think it looks correct

@tiborvass tiborvass force-pushed the cli_removal branch 4 times, most recently from c16ba14 to 9b993b7 Compare May 5, 2017 00:59
@tophj-ibm
Copy link
Contributor

nice teamwork @tiborvass @clnperez 👋

LGTM if green

@tiborvass
Copy link
Contributor Author

The failing powerpc test is a known failure. So CI can be considered green!

@justincormack
Copy link
Contributor

shall we merge then...

@AkihiroSuda
Copy link
Member

needs rebase

Makefile Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

@tiborvass just to clarify, is it the case that setting the environment variable for the CLI path, and then running something like make BIND_DIR=. binary shell will set up a test dind container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nishanttotla yes, it will do the same as usual, but will also have the bind-mounted binary specified by DOCKER_CLI_PATH. It will be added to your PATH so you can use it right away inside the dev container. Note that instead of DOCKER_CLI_PATH, you can also specify a different remote and git sha in hack/dockerfile/binaries-commits if you want to show case the full feature on one branch.

@tiborvass tiborvass force-pushed the cli_removal branch 2 times, most recently from 9f45491 to 1a61a99 Compare May 5, 2017 19:06
Arnaud Porterie (icecrime) and others added 4 commits May 5, 2017 12:14
…e new Moby project scope

Starting with this commit, integration tests should no longer rely on
the docker cli, they should be API tests instead. For the existing tests
the scripts will use a frozen version of the docker cli with a
DOCKER_API_VERSION frozen to 1.30, which should ensure that the CI remains
green at all times.

To help contributors develop and test manually with a modified docker
cli, this commit also adds a DOCKER_CLI_PATH environment variable to the
Makefile. This allows to set the path of a custom cli that will be
available inside the development container and used to run the
integration tests.

Signed-off-by: Arnaud Porterie (icecrime) <arnaud.porterie@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
@tiborvass tiborvass merged commit 34337db into moby:master May 5, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.06.0 milestone May 5, 2017
@vieux
Copy link
Contributor

vieux commented May 5, 2017

LGTM 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.