Skip to content

Commit

Permalink
fix: update code
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Mar 28, 2024
1 parent f70be2c commit 5578763
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void GetCredentials_WithPluginConfig_ReturnsExpectedCredential()
// Arrange
var pluginConfig = new Dictionary<string, string>
{
{ "credential_type", "default" }
{ "authentication_method", "default" }
};

// Act
Expand Down
28 changes: 14 additions & 14 deletions Notation.Plugin.AzureKeyVault/KeyVault/Credentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ namespace Notation.Plugin.AzureKeyVault.Credential
public class Credentials
{
/// <summary>
/// Credential type key name in plugin config.
/// authentication method key name in plugin config.
/// </summary>
public const string CredentialTypeKey = "credential_type";
public const string AuthenticationMethod = "authentication_method";
/// <summary>
/// Default credential name.
/// </summary>
public const string DefaultCredentialName = "default";
public const string DefaultAuthentication = "default";
/// <summary>
/// Environment credential name.
/// </summary>
public const string EnvironmentCredentialName = "environment";
public const string EnvironmentAuthentication = "environment";
/// <summary>
/// Workload identity credential name.
/// </summary>
public const string WorkloadIdentityCredentialName = "workloadidentity";
public const string WorkloadIdentityAuthentication = "workloadidentity";
/// <summary>
/// Managed identity credential name.
/// </summary>
public const string ManagedIdentityCredentialName = "managedidentity";
public const string ManagedIdentityAuthentication = "managedidentity";
/// <summary>
/// Azure CLI credential name.
/// </summary>
public const string AzureCliCredentialName = "azurecli";
public const string AzureCliAuthentication = "azurecli";

/// <summary>
/// Get the credential based on the credential type.
Expand All @@ -39,15 +39,15 @@ public static TokenCredential GetCredentials(string credentialType)
credentialType = credentialType.ToLower();
switch (credentialType)
{
case DefaultCredentialName:
case DefaultAuthentication:
return new DefaultAzureCredential();
case EnvironmentCredentialName:
case EnvironmentAuthentication:
return new EnvironmentCredential();
case WorkloadIdentityCredentialName:
case WorkloadIdentityAuthentication:
return new WorkloadIdentityCredential();
case ManagedIdentityCredentialName:
case ManagedIdentityAuthentication:
return new ManagedIdentityCredential();
case AzureCliCredentialName:
case AzureCliAuthentication:
return new AzureCliCredential();
default:
throw new ValidationException($"Invalid credential key: {credentialType}");
Expand All @@ -59,8 +59,8 @@ public static TokenCredential GetCredentials(string credentialType)
/// </summary>
public static TokenCredential GetCredentials(Dictionary<string, string>? pluginConfig)
{
var credentialName = pluginConfig?.GetValueOrDefault(CredentialTypeKey, DefaultCredentialName) ??
DefaultCredentialName;
var credentialName = pluginConfig?.GetValueOrDefault(AuthenticationMethod, DefaultAuthentication) ??
DefaultAuthentication;
return GetCredentials(credentialName);
}
}
Expand Down

0 comments on commit 5578763

Please sign in to comment.