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

Allow HOMEBREW_CURLRC to specify a path for curl --config #15853

Merged

Conversation

clint-stripe
Copy link
Contributor

@clint-stripe clint-stripe commented Aug 10, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

We're using a custom HOMEBREW_ARTIFACT_DOMAIN that requires some additional flags in .curlrc. We would like to set HOMEBREW_CURLRC and the value for CURL_HOME in /etc/homebrew/brew.env to support this without relying on the user's .curlrc.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Some comments.

Library/Homebrew/env_config.rb Outdated Show resolved Hide resolved
bin/brew Outdated Show resolved Hide resolved
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great work here @clint-stripe! Excuse all the back-and-forth: just the first time we've had a config change like this so want to make sure we get it right first time 😎

Comment on lines 135 to 138
description: "If set to a path, pass it with `--config` when invoking `curl`(1). " \
"If set but _not_ a valid path, do not pass `--disable`, which disables the " \
"use of `.curlrc`.",
Copy link
Member

Choose a reason for hiding this comment

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

This is great. Wondering if this is the best approach or if we want to do something like "if set to 1 or true"? @Homebrew/brew thoughts?

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 a very fair question! The current handling of boolean: true is #present?, but it might be nice to enforce something stricter in this particular case.

Copy link
Member

@Bo98 Bo98 Aug 14, 2023

Choose a reason for hiding this comment

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

This is great. Wondering if this is the best approach or if we want to do something like "if set to 1 or true"? @Homebrew/brew thoughts?

Starting with / is probably sufficient to invoke the path-based logic, given it is unlikely someone does that in order to use it as a boolean and we won't ever support relative paths.

There's potentially also an argument that we could just let CURL_HOME passthrough if HOMEBREW_CURLRC is set rather than the double-purpose, but it maybe doesn't matter much and which is safer is largely situational.

Copy link
Member

Choose a reason for hiding this comment

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

Starting with / is probably sufficient to invoke the path-based logic, given it is unlikely someone does that in order to use it as a boolean and we won't ever support relative paths.

Agreed, that works for me!

Comment on lines 321 to 335
it "doesn't return `--config` when HOMEBREW_CURLRC is unset" do
expect(curl_args(*args)).not_to include(a_string_starting_with("--config="))
end

it "returns `--config` when HOMEBREW_CURLRC is a valid path" do
Tempfile.create do |tmpfile|
path = tmpfile.path
ENV["HOMEBREW_CURLRC"] = path
# We still expect --disable
expect(curl_args(*args).first).to eq("--disable")
expect(curl_args(*args).join(" ")).to include("--config #{path}")
end
ensure
ENV["HOMEBREW_CURLRC"] = nil
end
Copy link
Member

Choose a reason for hiding this comment

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

😍

Comment on lines 135 to 138
description: "If set to a path, pass it with `--config` when invoking `curl`(1). " \
"If set but _not_ a valid path, do not pass `--disable`, which disables the " \
"use of `.curlrc`.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
description: "If set to a path, pass it with `--config` when invoking `curl`(1). " \
"If set but _not_ a valid path, do not pass `--disable`, which disables the " \
"use of `.curlrc`.",
description: "If set to a full path (i.e. beginning with `/`, pass it with `--config` when invoking `curl`(1). " \
"If set but _not_ a valid path, do not pass `--disable`, which disables the " \
"use of `.curlrc`.",

note this will fail brew style: you'll need to fix up the strings locally. Once that's done, you've run brew generate-man-completions and (ideally if your git-fu is sufficient) squashed it down to a single commit and CI is 🟢: this is ready to merge! Sorry for all the back and forth.

@clint-stripe clint-stripe changed the title Allow CURL_HOME env var when HOMEBREW_CURLRC is set Allow HOMEBREW_CURLRC to specify a path for curl --config Aug 14, 2023
@clint-stripe
Copy link
Contributor Author

clint-stripe commented Aug 14, 2023

Awesome, thank you so much for the quick reviews! (Also really appreciate brew tests, brew style, etc 🙂)

I made that last change you suggested, fixed up the line lengths, and squashed. CI looks green!

Library/Homebrew/env_config.rb Outdated Show resolved Hide resolved
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks so much for your first contribution (hopefully of many)! Without people like you submitting PRs we couldn't run this project. You rock, @clint-stripe!

@MikeMcQuaid MikeMcQuaid merged commit 72d25a2 into Homebrew:master Aug 15, 2023
25 checks passed
@github-actions github-actions bot added the outdated PR was locked due to age label Sep 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants