Commit 04ede192 authored by John DiSanti's avatar John DiSanti Committed by AWS SDK Rust Bot
Browse files

Remove deprecations from rust-runtime (#3222)



This PR removes deprecations throughout smithy-rs client and the SDK.
Some of these deprecations were ignored by the compiler (in the case
where `#[deprecated]` was used with `pub use`), so these will need to be
explicitly called out in the changelog.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent a055471e
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -72,3 +72,23 @@ message = "Make some types for various services optional. Previously, they defau
references = ["smithy-rs#3228"]
meta = { "breaking" = true, "tada" = false, "bug" = true }
author = "milesziemer"

[[smithy-rs]]
message = """
Types/functions that were deprecated in previous releases were removed. Unfortunately, some of these deprecations
were ignored by the Rust compiler (we found out later that `#[deprecated]` on `pub use` doesn't work). See
the [deprecations removal list](https://github.com/smithy-lang/smithy-rs/discussions/3223) for more details.
"""
references = ["smithy-rs#3222"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "jdisanti"

[[aws-sdk-rust]]
message = """
Types/functions that were deprecated in previous releases were removed. Unfortunately, some of these deprecations
were ignored by the Rust compiler (we found out later that `#[deprecated]` on `pub use` doesn't work). See
the [deprecations removal list](https://github.com/smithy-lang/smithy-rs/discussions/3223) for more details.
"""
references = ["smithy-rs#3222"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"
+0 −46
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::app_name::AppName;
use aws_types::os_shim_internal::Env;

/// Load an app name from the `AWS_SDK_UA_APP_ID` environment variable.
#[derive(Debug, Default)]
#[deprecated(note = "This is unused and will be removed in a future release.")]
pub struct EnvironmentVariableAppNameProvider {
    env: Env,
}

#[allow(deprecated)]
impl EnvironmentVariableAppNameProvider {
    /// Create a new `EnvironmentVariableAppNameProvider`
    pub fn new() -> Self {
        Self { env: Env::real() }
    }

    #[doc(hidden)]
    /// Create an region provider from a given `Env`
    ///
    /// This method is used for tests that need to override environment variables.
    pub fn new_with_env(env: Env) -> Self {
        Self { env }
    }

    /// Attempts to create an `AppName` from the `AWS_SDK_UA_APP_ID` environment variable.
    pub fn app_name(&self) -> Option<AppName> {
        if let Ok(name) = self.env.get("AWS_SDK_UA_APP_ID") {
            match AppName::new(name) {
                Ok(name) => Some(name),
                Err(err) => {
                    tracing::warn!(err = %DisplayErrorContext(&err), "`AWS_SDK_UA_APP_ID` environment variable value was invalid");
                    None
                }
            }
        } else {
            None
        }
    }
}
+0 −3
Original line number Diff line number Diff line
@@ -5,9 +5,6 @@

//! Providers that load configuration from environment variables

/// Load app name from the environment
pub mod app_name;

use std::error::Error;
use std::fmt::{Display, Formatter};

+0 −43
Original line number Diff line number Diff line
@@ -355,14 +355,6 @@ mod loader {
            self
        }

        /// Deprecated. Don't use.
        #[deprecated(
            note = "HTTP connector configuration changed. See https://github.com/smithy-lang/smithy-rs/discussions/3022 for upgrade guidance."
        )]
        pub fn http_connector(self, http_client: impl HttpClient + 'static) -> Self {
            self.http_client(http_client)
        }

        /// Override the [`HttpClient`](aws_smithy_runtime_api::client::http::HttpClient) for this [`ConfigLoader`].
        ///
        /// The HTTP client will be used for both AWS services and credentials providers.
@@ -399,14 +391,6 @@ mod loader {
            self
        }

        /// The credentials cache has been replaced. Use the identity_cache() method instead. See its rustdoc for an example.
        #[deprecated(
            note = "The credentials cache has been replaced. Use the identity_cache() method instead for equivalent functionality. See its rustdoc for an example."
        )]
        pub fn credentials_cache(self) -> Self {
            self
        }

        /// Override the identity cache used to build [`SdkConfig`](aws_types::SdkConfig).
        ///
        /// The identity cache caches AWS credentials and SSO tokens. By default, a lazy cache is used
@@ -647,33 +631,6 @@ mod loader {
            self
        }

        /// Set configuration for all sub-loaders (credentials, region etc.)
        ///
        /// Update the `ProviderConfig` used for all nested loaders. This can be used to override
        /// the HTTPs connector used by providers or to stub in an in memory `Env` or `Fs` for testing.
        ///
        /// # Examples
        /// ```no_run
        /// # #[cfg(feature = "hyper-client")]
        /// # async fn create_config() {
        /// use aws_config::provider_config::ProviderConfig;
        /// let custom_https_connector = hyper_rustls::HttpsConnectorBuilder::new()
        ///     .with_webpki_roots()
        ///     .https_only()
        ///     .enable_http1()
        ///     .build();
        /// let provider_config = ProviderConfig::default().with_tcp_connector(custom_https_connector);
        /// let shared_config = aws_config::defaults(BehaviorVersion::latest()).configure(provider_config).load().await;
        /// # }
        /// ```
        #[deprecated(
            note = "Use setters on this builder instead. configure is very hard to use correctly."
        )]
        pub fn configure(mut self, provider_config: ProviderConfig) -> Self {
            self.provider_config = Some(provider_config);
            self
        }

        /// Load the default configuration chain
        ///
        /// If fields have been overridden during builder construction, the override values will be used.
+0 −106
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

//! Load an app name from an AWS profile

use super::profile_file::ProfileFiles;
use crate::provider_config::ProviderConfig;
use aws_types::app_name::AppName;

/// Loads an app name from a profile file
///
/// This provider will attempt to shared AWS shared configuration and then read the
/// `sdk-ua-app-id` property from the active profile.
///
#[doc = include_str!("location_of_profile_files.md")]
///
/// # Examples
///
/// **Loads "my-app" as the app name**
/// ```ini
/// [default]
/// sdk-ua-app-id = my-app
/// ```
///
/// **Loads "my-app" as the app name _if and only if_ the `AWS_PROFILE` environment variable
/// is set to `other`.**
/// ```ini
/// [profile other]
/// sdk-ua-app-id = my-app
/// ```
///
/// This provider is part of the [default app name provider chain](crate::default_provider::app_name).
#[derive(Debug, Default)]
#[deprecated(
    note = "This is unused and is deprecated for backwards compatibility. It will be removed in a future release."
)]
pub struct ProfileFileAppNameProvider {
    provider_config: ProviderConfig,
}

#[allow(deprecated)]
impl ProfileFileAppNameProvider {
    /// Create a new [ProfileFileAppNameProvider}
    ///
    /// To override the selected profile, set the `AWS_PROFILE` environment variable or use the [`Builder`].
    pub fn new() -> Self {
        Self {
            provider_config: ProviderConfig::default(),
        }
    }

    /// [`Builder`] to construct a [`ProfileFileAppNameProvider`]
    pub fn builder() -> Builder {
        Builder::default()
    }

    /// Parses the profile config and attempts to find an app name.
    pub async fn app_name(&self) -> Option<AppName> {
        let app_id = self.provider_config.profile().await?.get("sdk-ua-app-id")?;
        match AppName::new(app_id.to_owned()) {
            Ok(app_name) => Some(app_name),
            Err(err) => {
                tracing::warn!(err = %err, "`sdk-ua-app-id` property `{}` was invalid", app_id);
                None
            }
        }
    }
}

/// Builder for [ProfileFileAppNameProvider]
#[derive(Debug, Default)]
#[allow(deprecated)]
pub struct Builder {
    config: Option<ProviderConfig>,
    profile_override: Option<String>,
    profile_files: Option<ProfileFiles>,
}

#[allow(deprecated)]
impl Builder {
    /// Override the configuration for this provider
    pub fn configure(mut self, config: &ProviderConfig) -> Self {
        self.config = Some(config.clone());
        self
    }

    /// Override the profile name used by the [ProfileFileAppNameProvider]
    pub fn profile_name(mut self, profile_name: impl Into<String>) -> Self {
        self.profile_override = Some(profile_name.into());
        self
    }

    /// Build a [ProfileFileAppNameProvider] from this builder
    #[allow(deprecated)]
    pub fn build(self) -> ProfileFileAppNameProvider {
        let conf = self
            .config
            .unwrap_or_default()
            .with_profile_config(self.profile_files, self.profile_override);
        ProfileFileAppNameProvider {
            provider_config: conf,
        }
    }
}
Loading