forked from loic-sharma/BaGet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Azure] Support raw connection strings for Azure Blob Storage (loic-s…
…harma#411) Addresses loic-sharma#394
- Loading branch information
1 parent
ce69248
commit c61fdc1
Showing
3 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,62 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace BaGet.Azure.Configuration | ||
{ | ||
public class BlobStorageOptions | ||
/// <summary> | ||
/// BaGet's configurations to use Azure Blob Storage to store packages. | ||
/// See: https://loic-sharma.github.io/BaGet/quickstart/azure/#azure-blob-storage | ||
/// </summary> | ||
public class BlobStorageOptions : IValidatableObject | ||
{ | ||
[Required] | ||
/// <summary> | ||
/// The Azure Blob Storage connection string. | ||
/// If provided, ignores <see cref="AccountName"/> and <see cref="AccessKey"/>. | ||
/// </summary> | ||
public string ConnectionString { get; set; } | ||
|
||
/// <summary> | ||
/// The Azure Blob Storage account name. Ignored if <see cref="ConnectionString"/> is provided. | ||
/// </summary> | ||
public string AccountName { get; set; } | ||
|
||
[Required] | ||
|
||
/// <summary> | ||
/// The Azure Blob Storage access key. Ignored if <see cref="ConnectionString"/> is provided. | ||
/// </summary> | ||
public string AccessKey { get; set; } | ||
|
||
[Required] | ||
/// <summary> | ||
/// The Azure Blob Storage container name. | ||
/// </summary> | ||
public string Container { get; set; } | ||
|
||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | ||
{ | ||
const string helpUrl = "https://loic-sharma.github.io/BaGet/quickstart/azure/#azure-blob-storage"; | ||
|
||
if (string.IsNullOrEmpty(ConnectionString)) | ||
{ | ||
if (string.IsNullOrEmpty(AccountName)) | ||
{ | ||
yield return new ValidationResult( | ||
$"The {nameof(AccountName)} configuration is required. See {helpUrl}", | ||
new[] { nameof(AccountName) }); | ||
} | ||
|
||
if (string.IsNullOrEmpty(AccessKey)) | ||
{ | ||
yield return new ValidationResult( | ||
$"The {nameof(AccessKey)} configuration is required. See {helpUrl}", | ||
new[] { nameof(AccessKey) }); | ||
} | ||
} | ||
|
||
if (string.IsNullOrEmpty(Container)) | ||
{ | ||
yield return new ValidationResult( | ||
$"The {nameof(Container)} configuration is required. See {helpUrl}", | ||
new[] { nameof(Container) }); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters