Skip to content

Commit

Permalink
aws-config: Fix compilation error with rustls and native-tls di…
Browse files Browse the repository at this point in the history
…sabled (#1533)

* `aws-config`: Fix compilation error with `rustls` and `native-tls` disabled

The `ProviderConfig::with_tcp_connector` method uses
`aws_smithy_client::hyper_ext`, which only exists with the
`client-hyper` feature enabled. Add a feature enabling that, and enable
it by default.

Introducing this feature does not cause breakage, because aws-config
did not previously compile with `default-features = false` and neither
`rustls` nor `native-tls` enabled.

* CHANGELOG.next.toml: Update for aws-config compilation fix

* Fix doctest by adding feature gate

Co-authored-by: Russell Cohen <[email protected]>
  • Loading branch information
joshtriplett and rcoh authored Jul 13, 2022
1 parent c220b03 commit c6193bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false }
# author = "rcoh"

[[aws-sdk-rust]]
message = """
Fix compilation of `aws-config` with `rustls` and `native-tls` disabled. The
`ProviderConfig::with_tcp_connector` method uses
`aws_smithy_client::hyper_ext`, which only exists with the `client-hyper`
feature enabled. Add a feature enabling that, and enable it by default.
"""
references = ["smithy-rs#1541"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "joshtriplett"

[[aws-sdk-rust]]
message = """
Add support for aws-chunked content encoding. Only single-chunk encoding is supported. Multiple chunks and
Expand Down
7 changes: 4 additions & 3 deletions aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ license = "Apache-2.0"
repository = "https://github.com/awslabs/smithy-rs"

[features]
client-hyper = ["aws-smithy-client/client-hyper"]
rustls = ["aws-smithy-client/rustls"]
native-tls = ["aws-smithy-client/native-tls"]
rt-tokio = ["aws-smithy-async/rt-tokio"]
rt-tokio = ["aws-smithy-async/rt-tokio", "tokio/rt"]

default = ["rustls", "rt-tokio"]
default = ["client-hyper", "rustls", "rt-tokio"]

[dependencies]
aws-sdk-sts = { path = "../../sdk/build/aws-sdk/sdk/sts", default-features = false }
aws-sdk-sso = { path = "../../sdk/build/aws-sdk/sdk/sso", default-features = false }
aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async" }
aws-smithy-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-client" }
aws-smithy-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-client", default-features = false }
aws-smithy-types = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-types" }
aws-types = { path = "../../sdk/build/aws-sdk/sdk/aws-types" }
tokio = { version = "1", features = ["sync"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ mod test {

#[tokio::test]
#[traced_test]
#[cfg(feature = "client-hyper")]
async fn no_providers_configured_err() {
use aws_smithy_async::rt::sleep::TokioSleep;
use aws_smithy_client::erase::boxclone::BoxCloneService;
Expand Down
1 change: 1 addition & 0 deletions aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ mod loader {
///
/// # Examples
/// ```no_run
/// # #[cfg(feature = "hyper-client")]
/// # async fn docs() {
/// use aws_config::provider_config::ProviderConfig;
/// let custom_https_connector = hyper_rustls::HttpsConnectorBuilder::new().
Expand Down
16 changes: 9 additions & 7 deletions aws/rust-runtime/aws-config/src/provider_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ use aws_types::{
region::Region,
};

use std::error::Error;
use std::fmt::{Debug, Formatter};
use std::sync::Arc;

use crate::connector::default_connector;
use http::Uri;
use hyper::client::connect::Connection;
use tokio::io::{AsyncRead, AsyncWrite};

/// Configuration options for Credential Providers
///
Expand Down Expand Up @@ -239,13 +235,19 @@ impl ProviderConfig {
///
/// # Stability
/// This method may change to support HTTP configuration.
#[cfg(feature = "client-hyper")]
pub fn with_tcp_connector<C>(self, connector: C) -> Self
where
C: Clone + Send + Sync + 'static,
C: tower::Service<Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C: tower::Service<http::Uri>,
C::Response: hyper::client::connect::Connection
+ tokio::io::AsyncRead
+ tokio::io::AsyncWrite
+ Send
+ Unpin
+ 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<Box<dyn Error + Send + Sync + 'static>>,
C::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
{
let connector_fn = move |settings: &HttpSettings, sleep: Option<Arc<dyn AsyncSleep>>| {
let mut builder = aws_smithy_client::hyper_ext::Adapter::builder()
Expand Down

0 comments on commit c6193bd

Please sign in to comment.