Merge branch 'main' into source-partitions-json

This commit is contained in:
Russell Cohen 2023-12-20 14:36:06 -05:00 committed by GitHub
commit fc3ba64f64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 920 additions and 418 deletions

View File

@ -40,3 +40,9 @@ message = """`requireEndpointResolver: false` is no longer required to remove th
references = ["smithy-rs#3292"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "rcoh"
[[aws-sdk-rust]]
message = "Fix bug in `CredentialsProcess` provider where `expiry` was incorrectly treated as a required field."
references = ["smithy-rs#3335", "aws-sdk-rust#1021"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "rcoh"

View File

@ -77,6 +77,7 @@ aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async", feat
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -7,7 +7,7 @@
//! Credentials Provider for external process
use crate::json_credentials::{json_parse_loop, InvalidJsonCredentials, RefreshableCredentials};
use crate::json_credentials::{json_parse_loop, InvalidJsonCredentials};
use crate::sensitive_command::CommandWithSensitiveArgs;
use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials};
use aws_credential_types::Credentials;
@ -120,25 +120,12 @@ impl CredentialProcessProvider {
))
})?;
match parse_credential_process_json_credentials(output) {
Ok(RefreshableCredentials {
access_key_id,
secret_access_key,
session_token,
expiration,
..
}) => Ok(Credentials::new(
access_key_id,
secret_access_key,
Some(session_token.to_string()),
expiration.into(),
"CredentialProcess",
)),
Err(invalid) => Err(CredentialsError::provider_error(format!(
parse_credential_process_json_credentials(output).map_err(|invalid| {
CredentialsError::provider_error(format!(
"Error retrieving credentials from external process, could not parse response: {}",
invalid
))),
}
))
})
}
}
@ -149,7 +136,7 @@ impl CredentialProcessProvider {
/// Keys are case insensitive.
pub(crate) fn parse_credential_process_json_credentials(
credentials_response: &str,
) -> Result<RefreshableCredentials<'_>, InvalidJsonCredentials> {
) -> Result<Credentials, InvalidJsonCredentials> {
let mut version = None;
let mut access_key_id = None;
let mut secret_access_key = None;
@ -206,25 +193,32 @@ pub(crate) fn parse_credential_process_json_credentials(
let access_key_id = access_key_id.ok_or(InvalidJsonCredentials::MissingField("AccessKeyId"))?;
let secret_access_key =
secret_access_key.ok_or(InvalidJsonCredentials::MissingField("SecretAccessKey"))?;
let session_token = session_token.ok_or(InvalidJsonCredentials::MissingField("Token"))?;
let expiration = expiration.ok_or(InvalidJsonCredentials::MissingField("Expiration"))?;
let expiration =
SystemTime::try_from(OffsetDateTime::parse(&expiration, &Rfc3339).map_err(|err| {
let expiration = expiration.map(parse_expiration).transpose()?;
if expiration.is_none() {
tracing::debug!("no expiration provided for credentials provider credentials. these credentials will never be refreshed.")
}
Ok(Credentials::new(
access_key_id,
secret_access_key,
session_token.map(|tok| tok.to_string()),
expiration,
"CredentialProcess",
))
}
fn parse_expiration(expiration: impl AsRef<str>) -> Result<SystemTime, InvalidJsonCredentials> {
SystemTime::try_from(
OffsetDateTime::parse(expiration.as_ref(), &Rfc3339).map_err(|err| {
InvalidJsonCredentials::InvalidField {
field: "Expiration",
err: err.into(),
}
})?)
.map_err(|_| {
InvalidJsonCredentials::Other(
"credential expiration time cannot be represented by a DateTime".into(),
)
})?;
Ok(RefreshableCredentials {
access_key_id,
secret_access_key,
session_token,
expiration,
})?,
)
.map_err(|_| {
InvalidJsonCredentials::Other(
"credential expiration time cannot be represented by a DateTime".into(),
)
})
}
@ -258,6 +252,18 @@ mod test {
);
}
#[tokio::test]
async fn test_credential_process_no_expiry() {
let provider = CredentialProcessProvider::new(String::from(
r#"echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY" }'"#,
));
let creds = provider.provide_credentials().await.expect("valid creds");
assert_eq!(creds.access_key_id(), "ASIARTESTID");
assert_eq!(creds.secret_access_key(), "TESTSECRETKEY");
assert_eq!(creds.session_token(), None);
assert_eq!(creds.expiry(), None);
}
#[tokio::test]
async fn credentials_process_timeouts() {
let provider = CredentialProcessProvider::new(String::from("sleep 1000"));

View File

@ -24,6 +24,7 @@ tokio = { version = "1.23.1", features = ["full", "test-util", "rt"] }
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -10,5 +10,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -24,5 +24,6 @@ tokio = { version = "1.23.1", features = ["macros", "rt", "time"] }
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -10,5 +10,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -40,5 +40,6 @@ tokio = { version = "1.23.1", features = ["macros", "rt", "io-util"] }
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -12,6 +12,7 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -43,6 +43,7 @@ tracing-test = "0.2.4"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -10,5 +10,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -68,6 +68,7 @@ required-features = [ "sigv4a" ]
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -36,6 +36,7 @@ rustc_version = "0.4.0"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -19,7 +19,7 @@ aws-sdk-dynamodb = { path = "../../build/aws-sdk/sdk/dynamodb", features = ["beh
aws-smithy-async = { path = "../../build/aws-sdk/sdk/aws-smithy-async", features = ["test-util"] }
aws-smithy-http = { path = "../../build/aws-sdk/sdk/aws-smithy-http" }
aws-smithy-protocol-test = { path = "../../build/aws-sdk/sdk/aws-smithy-protocol-test" }
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["test-util"]}
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["test-util", "wire-mock"]}
aws-smithy-runtime-api = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"]}
aws-smithy-types = { path = "../../build/aws-sdk/sdk/aws-smithy-types", features = ["test-util"]}
aws-types = { path = "../../build/aws-sdk/sdk/aws-types" }

View File

@ -0,0 +1,70 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use std::time::Duration;
use aws_credential_types::Credentials;
use aws_sdk_dynamodb::types::AttributeValue;
use aws_sdk_dynamodb::Client;
use aws_smithy_async::rt::sleep::{SharedAsyncSleep, TokioSleep};
use aws_smithy_runtime::client::http::test_util::wire::{ReplayedEvent, WireMockServer};
use aws_smithy_runtime::{ev, match_events};
use aws_smithy_types::retry::RetryConfig;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_types::region::Region;
use bytes::Bytes;
const DYNAMO_THROTTLING_RESPONSE: &str = r#"{"__type":"com.amazonaws.dynamodb.v20120810#ThrottlingException",
"message":"enhance your calm"}"#;
const DYNAMODB_DB_SUCCESS_RESPONSE: &str = r#"{"Count":0,"Items":[],"ScannedCount":2}"#;
#[tokio::test]
async fn test_no_reconnect_500_throttling() {
assert_error_not_transient(ReplayedEvent::HttpResponse {
status: 500,
body: Bytes::from(DYNAMO_THROTTLING_RESPONSE),
})
.await
}
#[tokio::test]
async fn test_no_reconnect_429_throttling() {
assert_error_not_transient(ReplayedEvent::HttpResponse {
status: 429,
body: Bytes::from(DYNAMO_THROTTLING_RESPONSE),
})
.await
}
async fn assert_error_not_transient(error: ReplayedEvent) {
let mock = WireMockServer::start(vec![
error,
ReplayedEvent::with_body(DYNAMODB_DB_SUCCESS_RESPONSE),
])
.await;
let config = aws_sdk_dynamodb::Config::builder()
.region(Region::from_static("us-east-2"))
.credentials_provider(Credentials::for_tests())
.sleep_impl(SharedAsyncSleep::new(TokioSleep::new()))
.endpoint_url(mock.endpoint_url())
.http_client(mock.http_client())
.timeout_config(
TimeoutConfig::builder()
.operation_attempt_timeout(Duration::from_millis(100))
.build(),
)
.retry_config(RetryConfig::standard())
.build();
let client = Client::from_conf(config);
let _item = client
.get_item()
.key("foo", AttributeValue::Bool(true))
.send()
.await
.expect("should succeed");
match_events!(ev!(dns), ev!(connect), _, ev!(http(200)))(&mock.events());
}

View File

@ -29,6 +29,7 @@ normal = ["futures-util"]
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -36,5 +36,6 @@ tracing-test = "0.2.1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -10,5 +10,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -23,5 +23,6 @@ bytes-utils = "0.1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -15,5 +15,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -66,5 +66,6 @@ harness = false
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -19,5 +19,6 @@ publish = false
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -50,5 +50,6 @@ pretty_assertions = "1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -10,5 +10,6 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -45,5 +45,6 @@ tokio = { version = "1.23.1", features = [
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -17,5 +17,6 @@ serde_json = "1.0"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -22,5 +22,6 @@ aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["clie
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -14,5 +14,6 @@ urlencoding = "2.1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -33,6 +33,7 @@ tokio = { version = "1.25", features = ["macros", "rt", "rt-multi-thread"] }
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -58,6 +58,7 @@ hyper_0_14 = { package = "hyper", version = "0.14.27",features = ["client", "ser
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -19,5 +19,6 @@ time = { version = "0.3.4", optional = true }
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -21,5 +21,5 @@ _Note:_ Conversions to and from [`SystemTime`](https://doc.rust-lang.org/std/tim
into [`aws-smithy-types`](https://docs.rs/aws-smithy-types/0.30.0-alpha/aws_smithy_types/date_time/struct.DateTime.html#impl-From%3CSystemTime%3E).
<!-- anchor_start:footer -->
This crate is part of the [AWS SDK for Rust](https://awslabs.github.io/aws-sdk-rust/) and the [smithy-rs](https://github.com/smithy-lang/smithy-rs) code generator. In most cases, it should not be used directly.
This crate is part of the [AWS SDK for Rust](https://awslabs.github.io/aws-sdk-rust/) and the [smithy-rs](https://github.com/smithy-lang/smithy-rs) code generator.
<!-- anchor_end:footer -->

View File

@ -72,6 +72,7 @@ tempfile = "3.2.0"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -34,7 +34,6 @@ impl AsRef<[u8]> for Blob {
#[cfg(all(aws_sdk_unstable, feature = "serde-serialize"))]
mod serde_serialize {
use super::*;
use crate::base64;
use serde::Serialize;
impl Serialize for Blob {
@ -54,7 +53,6 @@ mod serde_serialize {
#[cfg(all(aws_sdk_unstable, feature = "serde-deserialize"))]
mod serde_deserialize {
use super::*;
use crate::base64;
use serde::{de::Visitor, Deserialize};
struct HumanReadableBlobVisitor;
@ -68,7 +66,7 @@ mod serde_deserialize {
where
E: serde::de::Error,
{
match base64::decode(v) {
match crate::base64::decode(v) {
Ok(inner) => Ok(Blob { inner }),
Err(e) => Err(E::custom(e)),
}

View File

@ -18,5 +18,6 @@ proptest = "1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -43,5 +43,6 @@ proptest = "1"
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata

View File

@ -0,0 +1,353 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anyhow"
version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"once_cell",
"strsim",
"termcolor",
]
[[package]]
name = "clap_derive"
version = "4.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92289ffc6fb4a85d85c246ddb874c05a87a2e540fb6ad52f7ca07c8c1e1840b1"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "console"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"unicode-width",
"windows-sys",
]
[[package]]
name = "encode_unicode"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "indicatif"
version = "0.17.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25"
dependencies = [
"console",
"instant",
"number_prefix",
"portable-atomic",
"unicode-width",
]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]]
name = "number_prefix"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "os_str_bytes"
version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
[[package]]
name = "portable-atomic"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro2"
version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "runtime-release-dryrun"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"indicatif",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
dependencies = [
"winapi-util",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"

View File

@ -0,0 +1,11 @@
[package]
name = "runtime-release-dryrun"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4", features = ["derive"] }
anyhow = "1.0.75"
indicatif = "0.17.7"

View File

@ -0,0 +1,182 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// this tool is simple and works at what it does
// potential improvements:
// - support the release of rust-runtime crates
// - support patching the users system-wide ~/.cargo/config.toml
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::Duration;
use anyhow::{bail, Context, Result};
use clap::Parser;
use indicatif::{ProgressBar, ProgressStyle};
#[derive(Parser, Debug)]
struct DryRunSdk {
/// Path to the aws-sdk-rust repo
#[clap(long)]
pub sdk_path: PathBuf,
/// Tag of the aws-sdk-rust repo to dry-run against
#[clap(long)]
pub rust_sdk_tag: String,
/// Path to the artifact produced by the release-dry run
#[clap(long)]
pub smithy_rs_release: PathBuf,
}
#[derive(Parser, Debug)]
#[clap(
name = "runtime-release-dryrun",
about = "CLI tool to prepare the aws-sdk-rust to test the result of releasing a new set of runtime crates.",
version
)]
#[allow(clippy::enum_variant_names)] // Want the "use" prefix in the CLI subcommand names for clarity
enum Args {
/// Dry run a smithy-rs release against a rust SDK release
///
/// You will need:
/// 1. An `aws-sdk-rust` repo with a clean working tree
/// 2. A directory containing the artifacts from a smithy-rs release dry run. This is an artifact
/// named `artifacts-generate-smithy-rs-release` from the GH action (e.g. https://github.com/smithy-lang/smithy-rs/actions/runs/7200898068)
/// 3. An `aws-sdk-rust` release tag you want to test against
///
/// After running the tool, you might want to do something like `cargo test` in `s3`. Make sure
/// to run `cargo update` to pull in the new dependencies. Use `cargo tree` to confirm you're
/// actually consuming the new versions.
#[clap(verbatim_doc_comment)]
DryRunSdk(DryRunSdk),
}
fn main() -> Result<()> {
let args = Args::parse();
match args {
Args::DryRunSdk(args) => dry_run_sdk(args).map_err(|err| {
// workaround an indicatif (bug?) where one character is stripped from output on the error message
eprintln!(" ");
err
})?,
}
Ok(())
}
fn step<T>(message: &'static str, step: impl FnOnce() -> Result<T>) -> Result<T> {
let spinner = ProgressBar::new_spinner()
.with_message(message)
.with_style(ProgressStyle::with_template("{spinner} {msg} {elapsed}").unwrap());
spinner.enable_steady_tick(Duration::from_millis(100));
let result = step();
let check = match &result {
Ok(_) => "",
Err(_) => "",
};
spinner.set_style(ProgressStyle::with_template("{msg} {elapsed}").unwrap());
spinner.finish_with_message(format!("{check} {message}"));
result
}
fn run(command: &mut Command) -> anyhow::Result<()> {
let status = command.output()?;
if !status.status.success() {
bail!(
"command `{:?}` failed:\n{}{}",
command,
String::from_utf8_lossy(&status.stdout),
String::from_utf8_lossy(&status.stderr)
);
}
Ok(())
}
fn dry_run_sdk(args: DryRunSdk) -> Result<()> {
step("Checking out SDK tag", || {
run(Command::new("git")
.arg("checkout")
.arg(&args.rust_sdk_tag)
.current_dir(&args.sdk_path))
.context("failed to checkout aws-sdk-rust revision")?;
Ok(())
})?;
// By default the SDK dependencies also include a path component. This prevents
// patching from working
step("Applying version-only dependencies", || {
run(Command::new("sdk-versioner")
.args([
"use-version-dependencies",
"--versions-toml",
"versions.toml",
"sdk",
])
.current_dir(&args.sdk_path))?;
run(Command::new("git")
.args(["checkout", "-B", "smithy-release-dryrun"])
.current_dir(&args.sdk_path))?;
run(Command::new("git")
.args([
"commit",
"-am",
"removing path dependencies to allow patching",
])
.current_dir(&args.sdk_path))?;
Ok(())
})?;
let patches = step("computing patches", || {
let path = Path::new(&args.smithy_rs_release).join("crates-to-publish");
let crates_to_patch = std::fs::read_dir(&path)
.context(format!("could list crates in directory {:?}", path))?
.map(|dir| dir.unwrap().file_name())
.map(|osstr| osstr.into_string().expect("invalid utf-8 directory"))
.collect::<Vec<_>>();
let patch_sections = crates_to_patch
.iter()
.map(|crte| {
let path = Path::new(&args.smithy_rs_release)
.join("crates-to-publish")
.join(crte);
assert!(
path.exists(),
"tried to reference a crate that did not exist!"
);
format!(
"{crte} = {{ path = '{}' }}",
path.canonicalize().unwrap().to_str().unwrap()
)
})
.collect::<Vec<_>>()
.join("\n");
Ok(format!("[patch.crates-io]\n{patch_sections}"))
})?;
// Note: in the future we could also automatically apply this to the system wide ~/.cargo/config.toml
step("apply patches to workspace Cargo.toml", || {
let workspace_cargo_toml = Path::new(&args.sdk_path).join("Cargo.toml");
if !workspace_cargo_toml.exists() {
bail!(
"Could not find the workspace Cargo.toml to patch {:?}",
workspace_cargo_toml
);
}
let current_contents = std::fs::read_to_string(&workspace_cargo_toml)
.context("could not read workspace cargo.toml")?;
std::fs::write(
workspace_cargo_toml,
format!("{current_contents}\n{patches}"),
)?;
run(Command::new("git")
.args(["commit", "-am", "patching workspace Cargo.toml"])
.current_dir(&args.sdk_path))?;
Ok(())
})?;
println!("{:?} has been updated to build against patches. Use `cargo update` to recompute the dependencies.", &args.sdk_path);
Ok(())
}

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ opt-level = 0
[dependencies]
anyhow = "1"
cargo_toml = "0.17.1"
cargo_toml = "0.10.1"
clap = { version = "~3.1.18", features = ["derive"]}
lazy_static = "1.4.0"
serde = { version = "1", features = ["derive"]}

View File

@ -7,6 +7,7 @@ use anyhow::Context;
use std::borrow::Cow;
use std::fmt::{Display, Formatter};
use std::fs::read_to_string;
use std::path::{Path, PathBuf};
#[derive(Debug)]
@ -136,6 +137,13 @@ where
T: Fix,
{
fn check(&self, path: impl AsRef<Path>) -> anyhow::Result<Vec<LintError>> {
self.fix(path).map(|(errs, _)| errs)
let old_contents = read_to_string(path.as_ref())?;
let (mut errs, new_contents) = self.fix(path)?;
if new_contents != old_contents {
errs.push(LintError::new(
"fix would have made changes. Run `sdk-lints fix`",
));
}
Ok(errs)
}
}

View File

@ -88,7 +88,7 @@ impl Check for CrateLicense {
fn check_crate_license(package: Package, path: impl AsRef<Path>) -> Result<Vec<LintError>> {
let mut errors = vec![];
match package.license() {
match package.license {
Some(license) if license == "Apache-2.0" => {}
incorrect_license => errors.push(LintError::new(format!(
"invalid license: {:?}",
@ -145,11 +145,10 @@ fn check_crate_author(package: Package) -> Result<Vec<LintError>> {
} else {
RUST_SDK_TEAM
};
if !package.authors().iter().any(|s| s == expected_author) {
if !package.authors.iter().any(|s| s == expected_author) {
errors.push(LintError::new(format!(
"missing `{}` in package author list ({:?})",
expected_author,
package.authors()
expected_author, package.authors
)));
}
Ok(errors)
@ -212,6 +211,7 @@ fn check_docs_rs(package: &Package<DocsRsMetadata>) -> Vec<LintError> {
const DEFAULT_DOCS_RS_SECTION: &str = r#"
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
"#;

View File

@ -8,7 +8,7 @@ use anyhow::{Context, Result};
use std::fs;
use std::path::{Path, PathBuf};
const CRATES_TO_BE_USED_DIRECTLY: &[&str] = ["aws-config"].as_slice();
const CRATES_TO_BE_USED_DIRECTLY: &[&str] = ["aws-config", "aws-smithy-types-convert"].as_slice();
pub(crate) struct ReadmesExist;
impl Lint for ReadmesExist {