Skip to content
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

docker-buildx: symlink plugin to brew owned cli-plugins #162200

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

narqo
Copy link
Contributor

@narqo narqo commented Feb 9, 2024

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

The PR updates the existing formula with docker-buildx Docker plugin, adding a post install step, that links the plugin into #{HOMEBREW_PREFIX}/lib/docker/cli-plugins directory. Users are expected to add the directory to the list of cliPluginsExtraDirs in their docker-cli's config.

E.g. this is how it looks in my config.json

% cat ~/.config/docker/config.json
{
    "auths": {},
    "currentContext": "colima",
    "cliPluginsExtraDirs": [
        "/opt/homebrew/lib/docker/cli-plugins"
    ]
}

I find this behaviour much more in-line with how managed packages should work. That is, as a user I find it more natural to update my local config, to point to a managed directory with plugins, than symlinking the managed plugin into my home directory (i.e. the previous suggestion from "caveats").


Note on Docker's cliPluginsExtraDirs, this parameter was added to docker-cli more than 4 years ago, but the fields of the config aren't very well documented it seems.

@github-actions github-actions bot added the go Go use is a significant feature of the PR or issue label Feb 9, 2024
Copy link
Contributor

github-actions bot commented Feb 9, 2024

Thanks for contributing to Homebrew! 🎉 It looks like you're having trouble with a CI failure. See our contribution guide for help. You may be most interested in the section on dealing with CI failures. You can find the CI logs in the Checks tab of your pull request.

@@ -32,11 +33,18 @@ def install
generate_completions_from_executable(bin/"docker-buildx", "completion")
end

def post_install
cli_plugins = HOMEBREW_PREFIX/"lib/docker/cli-plugins"
Copy link
Member

Choose a reason for hiding this comment

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

Could you motivate this choice of path? Is lib/docker/cli-plugins a "well-known" path (in some sense)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, following the original design docker/cli#1534 docker-cli scans these paths, when it searches for plugins:

Unix-like OSes:

  • $HOME/.docker/cli-plugins
  • /usr/local/lib/docker/cli-plugins & /usr/local/libexec/docker/cli-plugins
  • /usr/lib/docker/cli-plugins & /usr/libexec/docker/cli-plugins

I think it's reasonable to keep Docker CLI's plugins, that brew manages, in the similar structure.

Note, Docker Desktop seems to amend the default list of the paths and bundles several cli-plugins into the distribution itself (e.g. buildx and compose live inside the docker desktop's bundle).

@@ -32,11 +33,18 @@ def install
generate_completions_from_executable(bin/"docker-buildx", "completion")
end

def post_install
Copy link
Member

Choose a reason for hiding this comment

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

We could probably replace this post_install entirely by doing something like

(lib/"docker/cli-plugins").install_symlink bin/"docker-buildx"

Any reason why we're not doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's indeed simpler; I updated the changes. PHAL

Signed-off-by: Vladimir Varankin <vladimir@varank.in>
@chenrui333
Copy link
Member

@narqo thanks for your first contribution to homebrew-core! 🎉

Copy link
Contributor

github-actions bot commented Mar 6, 2024

🤖 An automated task has requested bottles to be published to this PR.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Mar 6, 2024
@BrewTestBot BrewTestBot added this pull request to the merge queue Mar 6, 2024
Merged via the queue into Homebrew:master with commit 5c611bc Mar 6, 2024
13 checks passed
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. go Go use is a significant feature of the PR or issue outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants