Skip to content

Commit 08196ec

Browse files
authored
Remove remaining middleware code (#3038)
This PR removes the remaining rust-runtime code to support middleware, deprecates empty crates, and removes the remaining codegen references to any of that code. In the interest of keeping code review easier, a separate PR will finish addressing the remaining `TODO(enableNewSmithyRuntime)` comments. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 26a914e commit 08196ec

95 files changed

Lines changed: 108 additions & 10648 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.next.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ references = ["smithy-rs#3011"]
1717
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
1818
author = "jdisanti"
1919

20+
[[smithy-rs]]
21+
message = "The `enableNewSmithyRuntime: middleware` opt-out flag in smithy-build.json has been removed and no longer opts out of the client orchestrator implementation. Middleware is no longer supported. If you haven't already upgraded to the orchestrator, see [the guide](https://github.com/awslabs/smithy-rs/discussions/2887)."
22+
references = ["smithy-rs#3038"]
23+
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
24+
author = "jdisanti"
25+
2026
[[aws-sdk-rust]]
2127
message = "HTTP connector configuration has changed significantly. See the [upgrade guidance](https://github.com/awslabs/smithy-rs/discussions/3022) for details."
2228
references = ["smithy-rs#3011"]
@@ -279,3 +285,9 @@ message = "STS and SSO-based credential providers will now respect both `use_fip
279285
references = ["aws-sdk-rust#882", "smithy-rs#3007"]
280286
meta = { "breaking" = true, "tada" = true, "bug" = true }
281287
author = "Velfi"
288+
289+
[[smithy-rs]]
290+
message = "`SdkError` is no longer re-exported in generated server crates."
291+
references = ["smithy-rs#3038"]
292+
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "server" }
293+
author = "jdisanti"

aws/rust-runtime/aws-endpoint/Cargo.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
name = "aws-endpoint"
33
version = "0.0.0-smithy-rs-head"
44
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Russell Cohen <rcoh@amazon.com>"]
5-
description = "AWS SDK endpoint support."
5+
description = "This crate is no longer used by the AWS SDK and is deprecated."
66
edition = "2021"
77
license = "Apache-2.0"
88
repository = "https://github.com/awslabs/smithy-rs"
99

10-
[dependencies]
11-
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
12-
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types"}
13-
aws-types = { path = "../aws-types" }
14-
http = "0.2.3"
15-
tracing = "0.1"
16-
1710
[package.metadata.docs.rs]
1811
all-features = true
1912
targets = ["x86_64-unknown-linux-gnu"]

aws/rust-runtime/aws-endpoint/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# aws-endpoint
2-
This crate defines endpoint resolution logic specific to AWS services.
2+
3+
This crate is no longer used by the AWS SDK and is deprecated.
34

45
<!-- anchor_start:footer -->
56
This crate is part of the [AWS SDK for Rust](https://awslabs.github.io/aws-sdk-rust/) and the [smithy-rs](https://github.com/awslabs/smithy-rs) code generator. In most cases, it should not be used directly.
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
allowed_external_types = [
2-
"aws_types::*",
3-
"aws_smithy_http::property_bag::PropertyBag",
4-
"aws_smithy_http::middleware::MapRequest",
5-
]
1+
allowed_external_types = []

aws/rust-runtime/aws-endpoint/src/lib.rs

Lines changed: 1 addition & 237 deletions
Original file line numberDiff line numberDiff line change
@@ -3,240 +3,4 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#![allow(clippy::derive_partial_eq_without_eq)]
7-
8-
use std::error::Error;
9-
use std::fmt;
10-
11-
use aws_smithy_http::middleware::MapRequest;
12-
use aws_smithy_http::operation::Request;
13-
use aws_smithy_types::endpoint::Endpoint as SmithyEndpoint;
14-
use aws_smithy_types::Document;
15-
16-
use aws_types::region::{Region, SigningRegion};
17-
use aws_types::SigningName;
18-
19-
/// Middleware Stage to add authentication information from a Smithy endpoint into the property bag
20-
///
21-
/// AwsAuthStage implements [`MapRequest`](MapRequest). It will:
22-
/// 1. Load an endpoint from the property bag
23-
/// 2. Set the `SigningRegion` and `SigningName` in the property bag to drive downstream
24-
/// signing middleware.
25-
#[derive(Clone, Debug)]
26-
pub struct AwsAuthStage;
27-
28-
#[derive(Debug)]
29-
enum AwsAuthStageErrorKind {
30-
NoEndpointResolver,
31-
EndpointResolutionError(Box<dyn Error + Send + Sync>),
32-
}
33-
34-
#[derive(Debug)]
35-
pub struct AwsAuthStageError {
36-
kind: AwsAuthStageErrorKind,
37-
}
38-
39-
impl fmt::Display for AwsAuthStageError {
40-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41-
use AwsAuthStageErrorKind::*;
42-
match &self.kind {
43-
NoEndpointResolver => write!(f, "endpoint resolution failed: no endpoint present"),
44-
EndpointResolutionError(_) => write!(f, "endpoint resolution failed"),
45-
}
46-
}
47-
}
48-
49-
impl Error for AwsAuthStageError {
50-
fn source(&self) -> Option<&(dyn Error + 'static)> {
51-
use AwsAuthStageErrorKind::*;
52-
match &self.kind {
53-
EndpointResolutionError(source) => Some(source.as_ref() as _),
54-
NoEndpointResolver => None,
55-
}
56-
}
57-
}
58-
59-
impl From<AwsAuthStageErrorKind> for AwsAuthStageError {
60-
fn from(kind: AwsAuthStageErrorKind) -> Self {
61-
Self { kind }
62-
}
63-
}
64-
65-
impl MapRequest for AwsAuthStage {
66-
type Error = AwsAuthStageError;
67-
68-
fn name(&self) -> &'static str {
69-
"resolve_endpoint"
70-
}
71-
72-
fn apply(&self, request: Request) -> Result<Request, Self::Error> {
73-
request.augment(|http_req, props| {
74-
let endpoint = props
75-
.get::<aws_smithy_types::endpoint::Endpoint>()
76-
.ok_or(AwsAuthStageErrorKind::NoEndpointResolver)?;
77-
let (signing_region_override, signing_name_override) = smithy_to_aws(endpoint)
78-
.map_err(|err| AwsAuthStageErrorKind::EndpointResolutionError(err))?;
79-
80-
if let Some(signing_region) = signing_region_override {
81-
props.insert(signing_region);
82-
}
83-
if let Some(signing_name) = signing_name_override {
84-
props.insert(signing_name);
85-
}
86-
Ok(http_req)
87-
})
88-
}
89-
}
90-
91-
type EndpointMetadata = (Option<SigningRegion>, Option<SigningName>);
92-
93-
fn smithy_to_aws(value: &SmithyEndpoint) -> Result<EndpointMetadata, Box<dyn Error + Send + Sync>> {
94-
// look for v4 as an auth scheme
95-
let auth_schemes = match value.properties().get("authSchemes") {
96-
Some(Document::Array(schemes)) => schemes,
97-
// no auth schemes:
98-
None => return Ok((None, None)),
99-
_other => return Err("expected an array for authSchemes".into()),
100-
};
101-
let auth_schemes = auth_schemes
102-
.iter()
103-
.flat_map(|doc| match doc {
104-
Document::Object(map) => Some(map),
105-
_ => None,
106-
})
107-
.map(|it| {
108-
let name = match it.get("name") {
109-
Some(Document::String(s)) => Some(s.as_str()),
110-
_ => None,
111-
};
112-
(name, it)
113-
});
114-
let (_, v4) = auth_schemes
115-
.clone()
116-
.find(|(name, _doc)| name.as_deref() == Some("sigv4"))
117-
.ok_or_else(|| {
118-
format!(
119-
"No auth schemes were supported. The Rust SDK only supports sigv4. \
120-
The authentication schemes supported by this endpoint were: {:?}",
121-
auth_schemes.flat_map(|(name, _)| name).collect::<Vec<_>>()
122-
)
123-
})?;
124-
125-
let signing_scope = match v4.get("signingRegion") {
126-
Some(Document::String(s)) => Some(SigningRegion::from(Region::new(s.clone()))),
127-
None => None,
128-
_ => return Err("unexpected type".into()),
129-
};
130-
let signing_name = match v4.get("signingName") {
131-
Some(Document::String(s)) => Some(SigningName::from(s.to_string())),
132-
None => None,
133-
_ => return Err("unexpected type".into()),
134-
};
135-
Ok((signing_scope, signing_name))
136-
}
137-
138-
#[cfg(test)]
139-
mod test {
140-
use std::collections::HashMap;
141-
142-
use aws_smithy_http::body::SdkBody;
143-
use aws_smithy_http::middleware::MapRequest;
144-
use aws_smithy_http::operation;
145-
use aws_smithy_types::endpoint::Endpoint;
146-
use aws_smithy_types::Document;
147-
use http::header::HOST;
148-
149-
use aws_types::region::{Region, SigningRegion};
150-
use aws_types::SigningName;
151-
152-
use crate::AwsAuthStage;
153-
154-
#[test]
155-
fn default_endpoint_updates_request() {
156-
let endpoint = Endpoint::builder()
157-
.url("kinesis.us-east-1.amazon.com")
158-
.build();
159-
let req = http::Request::new(SdkBody::from(""));
160-
let region = Region::new("us-east-1");
161-
let mut req = operation::Request::new(req);
162-
{
163-
let mut props = req.properties_mut();
164-
props.insert(SigningRegion::from(region.clone()));
165-
props.insert(SigningName::from_static("kinesis"));
166-
props.insert(endpoint);
167-
};
168-
let req = AwsAuthStage.apply(req).expect("should succeed");
169-
assert_eq!(req.properties().get(), Some(&SigningRegion::from(region)));
170-
assert_eq!(
171-
req.properties().get(),
172-
Some(&SigningName::from_static("kinesis"))
173-
);
174-
175-
assert!(req.http().headers().get(HOST).is_none());
176-
assert!(
177-
req.properties().get::<Endpoint>().is_some(),
178-
"Endpoint middleware MUST leave the result in the bag"
179-
);
180-
}
181-
182-
#[test]
183-
fn sets_service_override_when_set() {
184-
let endpoint = Endpoint::builder()
185-
.url("kinesis.us-east-override.amazon.com")
186-
.property(
187-
"authSchemes",
188-
vec![Document::Object({
189-
let mut out = HashMap::new();
190-
out.insert("name".to_string(), "sigv4".to_string().into());
191-
out.insert(
192-
"signingName".to_string(),
193-
"qldb-override".to_string().into(),
194-
);
195-
out.insert(
196-
"signingRegion".to_string(),
197-
"us-east-override".to_string().into(),
198-
);
199-
out
200-
})],
201-
)
202-
.build();
203-
let req = http::Request::new(SdkBody::from(""));
204-
let region = Region::new("us-east-1");
205-
let mut req = operation::Request::new(req);
206-
{
207-
let mut props = req.properties_mut();
208-
props.insert(region);
209-
props.insert(SigningName::from_static("qldb"));
210-
props.insert(endpoint);
211-
};
212-
let req = AwsAuthStage.apply(req).expect("should succeed");
213-
assert_eq!(
214-
req.properties().get(),
215-
Some(&SigningRegion::from_static("us-east-override"))
216-
);
217-
assert_eq!(
218-
req.properties().get(),
219-
Some(&SigningName::from_static("qldb-override"))
220-
);
221-
}
222-
223-
#[test]
224-
fn supports_fallback_when_scope_is_unset() {
225-
let endpoint = Endpoint::builder().url("www.service.com").build();
226-
let req = http::Request::new(SdkBody::from(""));
227-
let region = SigningRegion::from_static("us-east-1");
228-
let mut req = operation::Request::new(req);
229-
{
230-
let mut props = req.properties_mut();
231-
props.insert(region.clone());
232-
props.insert(SigningName::from_static("qldb"));
233-
props.insert(endpoint);
234-
};
235-
let req = AwsAuthStage.apply(req).expect("should succeed");
236-
assert_eq!(req.properties().get(), Some(&region));
237-
assert_eq!(
238-
req.properties().get(),
239-
Some(&SigningName::from_static("qldb"))
240-
);
241-
}
242-
}
6+
//! This crate is no longer used by the AWS SDK and is deprecated.

aws/rust-runtime/aws-http/Cargo.toml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,18 @@ license = "Apache-2.0"
88
repository = "https://github.com/awslabs/smithy-rs"
99

1010
[dependencies]
11-
aws-credential-types = { path = "../aws-credential-types" }
1211
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
1312
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types" }
1413
aws-types = { path = "../aws-types" }
1514
bytes = "1.1"
1615
http = "0.2.3"
1716
http-body = "0.4.5"
1817
tracing = "0.1"
19-
percent-encoding = "2.1.0"
2018
pin-project-lite = "0.2.9"
2119

2220
[dev-dependencies]
23-
async-trait = "0.1.50"
24-
aws-credential-types = { path = "../aws-credential-types", features = ["test-util"] }
25-
aws-smithy-async = { path = "../../../rust-runtime/aws-smithy-async", features = ["rt-tokio"] }
26-
aws-smithy-checksums = { path = "../../../rust-runtime/aws-smithy-checksums" }
27-
aws-smithy-protocol-test = { path = "../../../rust-runtime/aws-smithy-protocol-test" }
2821
bytes-utils = "0.1.2"
29-
env_logger = "0.9"
30-
tokio = { version = "1.23.1", features = ["macros", "rt", "rt-multi-thread", "test-util", "time"] }
31-
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
32-
proptest = "1.2"
33-
serde = { version = "1", features = ["derive"]}
34-
serde_json = "1"
22+
tokio = { version = "1.23.1", features = ["macros", "rt", "time"] }
3523

3624
[package.metadata.docs.rs]
3725
all-features = true
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
allowed_external_types = [
2-
"aws_credential_types::*",
3-
"aws_smithy_http::*",
4-
"aws_smithy_types::*",
5-
"aws_types::*",
2+
"aws_smithy_http::body::Error",
3+
"aws_smithy_types::config_bag::storable::Storable",
4+
"aws_smithy_types::config_bag::storable::StoreReplace",
5+
"aws_types::app_name::AppName",
6+
"aws_types::os_shim_internal::Env",
67
"bytes::bytes::Bytes",
78
"http_body::Body",
89
]

0 commit comments

Comments
 (0)