Skip to content

Commit

Permalink
Use custom octorust client (cncf#615)
Browse files Browse the repository at this point in the history
The main reason is to follow redirects (disabled by the default client).

Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz authored May 7, 2024
1 parent 2e23e04 commit a12487b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pretty_assertions = "1.4.0"
qrcode = "0.14.0"
regex = "1.10.4"
reqwest = { version = "0.12.4", features = ["json", "native-tls-vendored"] }
reqwest_octorust = { package = "reqwest", version = "0.11.14", default-features = false, features = ["json", "multipart"] }
reqwest-middleware = "0.2.2"
rust-embed = "8.3.0"
serde = { version = "1.0.199", features = ["derive"] }
serde_json = "1.0.116"
Expand Down
2 changes: 2 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ parse_link_header = { workspace = true }
qrcode = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true }
reqwest_octorust = { workspace = true }
reqwest-middleware = { workspace = true }
rust-embed = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion crates/cli/src/build/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ impl GHApi {
fn new(token: &str) -> Result<Self> {
// Setup octorust GitHub API client
let user_agent = format!("{}/{}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
let gh_client = octorust::Client::new(user_agent.clone(), Credentials::Token(token.to_string()))?;
let gh_client = octorust::Client::custom(
user_agent.clone(),
Credentials::Token(token.to_string()),
reqwest_middleware::ClientBuilder::new(reqwest_octorust::Client::builder().build()?).build(),
);

// Setup HTTP client ready to make requests to the GitHub API
// (for some operations that cannot be done with the octorust client)
Expand Down

0 comments on commit a12487b

Please sign in to comment.