Skip to content

Commit

Permalink
add DefaultAzureCredential::create
Browse files Browse the repository at this point in the history
  • Loading branch information
cataggar committed Jan 11, 2024
1 parent 1165ee8 commit 4354362
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions sdk/identity/src/token_credentials/default_credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,9 @@ enum DefaultAzureCredentialType {
AzureCli,
}

/// Alias of DefaultAzureCredentialKind for backwards compatibility.
#[deprecated(
since = "0.19.0",
note = "Please use DefaultAzureCredentialKind instead"
)]
pub type DefaultAzureCredentialEnum = DefaultAzureCredentialKind;

/// Types of `TokenCredential` supported by `DefaultAzureCredential`
#[derive(Debug)]
pub enum DefaultAzureCredentialKind {
pub(crate) enum DefaultAzureCredentialKind {
/// `TokenCredential` from environment variable.
Environment(EnvironmentCredential),
/// `TokenCredential` from managed identity that has been assigned to an App Service.
Expand Down Expand Up @@ -261,10 +254,14 @@ pub struct DefaultAzureCredential {
}

impl DefaultAzureCredential {
pub fn create(options: TokenCredentialOptions) -> azure_core::Result<DefaultAzureCredential> {
DefaultAzureCredentialBuilder::default()
.with_options(options)
.build()
}

/// Creates a `DefaultAzureCredential` with specified sources.
///
/// These sources will be tried in the order provided in the `TokenCredential` authentication flow.
pub fn with_sources(sources: Vec<DefaultAzureCredentialKind>) -> Self {
fn with_sources(sources: Vec<DefaultAzureCredentialKind>) -> Self {
DefaultAzureCredential {
sources,
cache: TokenCache::new(),
Expand Down

0 comments on commit 4354362

Please sign in to comment.