Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add additional secret descriptor constructor for required without key…
… map

Signed-off-by: James Croft <jamz_c@hotmail.co.uk>
  • Loading branch information
jamesmcroft committed Feb 16, 2024
commit 2b4b44d5f1a6de08e8fcf20387a632cc4f38ee9e
21 changes: 14 additions & 7 deletions src/Dapr.Extensions.Configuration/DaprSecretDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Copyright 2021 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@ public class DaprSecretDescriptor
/// A collection of metadata key-value pairs that will be provided to the secret store. The valid metadata keys and values are determined by the type of secret store used.
/// </summary>
public IReadOnlyDictionary<string, string> Metadata { get; }

/// <summary>
/// This flag indicates if this field's existence should trigger an exception. Setting it to "false"
/// will suppress the exception whereas setting it to "true" will not suppress it.
Expand All @@ -53,17 +53,24 @@ public class DaprSecretDescriptor
/// <summary>
/// Secret Descriptor Constructor
/// </summary>
public DaprSecretDescriptor(string secretName, IReadOnlyDictionary<string, string> metadata) :
public DaprSecretDescriptor(string secretName, IReadOnlyDictionary<string, string> metadata) :
this(secretName, metadata, true, secretName)
{


}

/// <summary>
/// Secret Descriptor Constructor
/// </summary>
public DaprSecretDescriptor(string secretName, IReadOnlyDictionary<string, string> metadata, bool isRequired) :
this(secretName, metadata, isRequired, secretName)
{
}

/// <summary>
/// Secret Descriptor Constructor
/// </summary>
public DaprSecretDescriptor(string secretName, IReadOnlyDictionary<string, string> metadata,
bool isRequired, string secretKey)
public DaprSecretDescriptor(string secretName, IReadOnlyDictionary<string, string> metadata, bool isRequired, string secretKey)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making isRequired and secretKey both optional arguments, to help reduce the explosion of constructor overloads as well as, say, allow users to only specify the secretKey but not have to then care about the isRequired argument. We might also consider doing the same for metadata.

Ideally these would all (save for secretName) bet init properties on the class, but that's a larger breaking change (depending on how many people actually specify metdata with each secret).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the constructor overload bloat and consolidated this change into the existing 2 constructors using optional arguments.

{
SecretName = secretName;
Metadata = metadata;
Expand Down