diff --git a/src/ImageSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs b/src/ImageSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs index cd96e0ba..74a74a65 100644 --- a/src/ImageSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs +++ b/src/ImageSharp.Web.Providers.AWS/AmazonS3ClientFactory.cs @@ -4,7 +4,6 @@ using System; using Amazon; using Amazon.S3; -using SixLabors.ImageSharp.Web.Providers.AWS; namespace SixLabors.ImageSharp.Web { @@ -18,7 +17,7 @@ internal static class AmazonS3ClientFactory /// /// A new . /// - public static AmazonS3Client CreateClient(AWSS3BucketClientOptions options) + public static AmazonS3Client CreateClient(IAWSS3BucketClientOptions options) { if (!string.IsNullOrWhiteSpace(options.Endpoint)) { diff --git a/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs index b02b649f..42d47de0 100644 --- a/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs +++ b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs @@ -7,7 +7,6 @@ using Amazon.S3; using Amazon.S3.Model; using Microsoft.Extensions.Options; -using SixLabors.ImageSharp.Web.Providers.AWS; using SixLabors.ImageSharp.Web.Resolvers; using SixLabors.ImageSharp.Web.Resolvers.AWS; @@ -25,10 +24,10 @@ public class AWSS3StorageCache : IImageCache /// Initializes a new instance of the class. /// /// The cache options. - public AWSS3StorageCache(IOptions cacheOptions) + public AWSS3StorageCache(IOptions cacheOptions) { Guard.NotNull(cacheOptions, nameof(cacheOptions)); - AWSS3BucketClientOptions options = cacheOptions.Value; + AWSS3StorageCacheOptions options = cacheOptions.Value; this.bucket = options.BucketName; this.amazonS3Client = AmazonS3ClientFactory.CreateClient(options); } @@ -85,12 +84,12 @@ public Task SetAsync(string key, Stream stream, ImageCacheMetadata metadata) /// created bucket. If the container already exists, . /// public static PutBucketResponse CreateIfNotExists( - AWSS3BucketClientOptions options, + AWSS3StorageCacheOptions options, S3CannedACL acl) => AsyncHelper.RunSync(() => CreateIfNotExistsAsync(options, acl)); private static async Task CreateIfNotExistsAsync( - AWSS3BucketClientOptions options, + AWSS3StorageCacheOptions options, S3CannedACL acl) { AmazonS3Client client = AmazonS3ClientFactory.CreateClient(options); diff --git a/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCacheOptions.cs b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCacheOptions.cs new file mode 100644 index 00000000..b2f096aa --- /dev/null +++ b/src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCacheOptions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Web.Caching.AWS +{ + /// + /// Configuration options for the provider. + /// + public class AWSS3StorageCacheOptions : IAWSS3BucketClientOptions + { + /// + public string Region { get; set; } + + /// + public string BucketName { get; set; } + + /// + public string AccessKey { get; set; } + + /// + public string AccessSecret { get; set; } + + /// + public string Endpoint { get; set; } + } +} diff --git a/src/ImageSharp.Web.Providers.AWS/IAWSS3BucketClientOptions.cs b/src/ImageSharp.Web.Providers.AWS/IAWSS3BucketClientOptions.cs new file mode 100644 index 00000000..ecfd2a5d --- /dev/null +++ b/src/ImageSharp.Web.Providers.AWS/IAWSS3BucketClientOptions.cs @@ -0,0 +1,41 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Web +{ + /// + /// Provides a common interface for AWS S3 Bucket Client Options. + /// + internal interface IAWSS3BucketClientOptions + { + /// + /// Gets or sets the AWS region endpoint (us-east-1/us-west-1/ap-southeast-2). + /// + string Region { get; set; } + + /// + /// Gets or sets the AWS bucket name. + /// + string BucketName { get; set; } + + /// + /// Gets or sets the AWS key - Can be used to override keys provided by the environment. + /// If deploying inside an EC2 instance AWS keys will already be available via environment + /// variables and don't need to be specified. Follow AWS best security practices on . + /// + string AccessKey { get; set; } + + /// + /// Gets or sets the AWS secret - Can be used to override keys provided by the environment. + /// If deploying inside an EC2 instance AWS keys will already be available via environment + /// variables and don't need to be specified. Follow AWS best security practices on . + /// + string AccessSecret { get; set; } + + /// + /// Gets or sets the AWS endpoint - used for testing to over region endpoint allowing it + /// to be set to localhost. + /// + string Endpoint { get; set; } + } +} diff --git a/src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProviderOptions.cs b/src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProviderOptions.cs index 23eecc84..ceaa18b6 100644 --- a/src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProviderOptions.cs +++ b/src/ImageSharp.Web.Providers.AWS/Providers/AWSS3StorageImageProviderOptions.cs @@ -19,36 +19,21 @@ public class AWSS3StorageImageProviderOptions /// /// Configuration options for the provider. /// - public class AWSS3BucketClientOptions + public class AWSS3BucketClientOptions : IAWSS3BucketClientOptions { - /// - /// Gets or sets the AWS region endpoint (us-east-1/us-west-1/ap-southeast-2). - /// + /// public string Region { get; set; } - /// - /// Gets or sets the AWS bucket name. - /// + /// public string BucketName { get; set; } - /// - /// Gets or sets the AWS key - Can be used to override keys provided by the environment. - /// If deploying inside an EC2 instance AWS keys will already be available via environment - /// variables and don't need to be specified. Follow AWS best security practices on . - /// + /// public string AccessKey { get; set; } - /// - /// Gets or sets the AWS secret - Can be used to override keys provided by the environment. - /// If deploying inside an EC2 instance AWS keys will already be available via environment - /// variables and don't need to be specified. Follow AWS best security practices on . - /// + /// public string AccessSecret { get; set; } - /// - /// Gets or sets the AWS endpoint - used for testing to over region endpoint allowing it - /// to be set to localhost. - /// + /// public string Endpoint { get; set; } } } diff --git a/src/ImageSharp.Web.Providers.Azure/Caching/AzureBlobStorageCacheOptions.cs b/src/ImageSharp.Web.Providers.Azure/Caching/AzureBlobStorageCacheOptions.cs index 9d253d5d..adddb58e 100644 --- a/src/ImageSharp.Web.Providers.Azure/Caching/AzureBlobStorageCacheOptions.cs +++ b/src/ImageSharp.Web.Providers.Azure/Caching/AzureBlobStorageCacheOptions.cs @@ -6,19 +6,12 @@ namespace SixLabors.ImageSharp.Web.Caching.Azure /// /// Configuration options for the . /// - public class AzureBlobStorageCacheOptions + public class AzureBlobStorageCacheOptions : IAzureBlobContainerClientOptions { - /// - /// Gets or sets the Azure Blob Storage connection string. - /// - /// + /// public string ConnectionString { get; set; } - /// - /// Gets or sets the Azure Blob Storage container name. - /// Must conform to Azure Blob Storage containiner naming guidlines. - /// - /// + /// public string ContainerName { get; set; } } } diff --git a/src/ImageSharp.Web.Providers.Azure/IAzureBlobContainerClientOptions.cs b/src/ImageSharp.Web.Providers.Azure/IAzureBlobContainerClientOptions.cs new file mode 100644 index 00000000..6048b5e6 --- /dev/null +++ b/src/ImageSharp.Web.Providers.Azure/IAzureBlobContainerClientOptions.cs @@ -0,0 +1,24 @@ +// Copyright (c) Six Labors. +// Licensed under the Apache License, Version 2.0. + +namespace SixLabors.ImageSharp.Web +{ + /// + /// Provides a common interface for Azure Blob Container Options. + /// + internal interface IAzureBlobContainerClientOptions + { + /// + /// Gets or sets the Azure Blob Storage connection string. + /// + /// + public string ConnectionString { get; set; } + + /// + /// Gets or sets the Azure Blob Storage container name. + /// Must conform to Azure Blob Storage container naming guidlines. + /// + /// + public string ContainerName { get; set; } + } +} diff --git a/src/ImageSharp.Web.Providers.Azure/Providers/AzureBlobStorageImageProviderOptions.cs b/src/ImageSharp.Web.Providers.Azure/Providers/AzureBlobStorageImageProviderOptions.cs index 7d4eef59..6afd6538 100644 --- a/src/ImageSharp.Web.Providers.Azure/Providers/AzureBlobStorageImageProviderOptions.cs +++ b/src/ImageSharp.Web.Providers.Azure/Providers/AzureBlobStorageImageProviderOptions.cs @@ -19,19 +19,12 @@ public class AzureBlobStorageImageProviderOptions /// /// Represents a single Azure Blob Storage connection and container. /// - public class AzureBlobContainerClientOptions + public class AzureBlobContainerClientOptions : IAzureBlobContainerClientOptions { - /// - /// Gets or sets the Azure Blob Storage connection string. - /// - /// + /// public string ConnectionString { get; set; } - /// - /// Gets or sets the Azure Blob Storage container name. - /// Must conform to Azure Blob Storage containiner naming guidlines. - /// - /// + /// public string ContainerName { get; set; } } } diff --git a/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageCacheTestServerFixture.cs b/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageCacheTestServerFixture.cs index 1cdfa4c4..c1e94de5 100644 --- a/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageCacheTestServerFixture.cs +++ b/tests/ImageSharp.Web.Tests/TestUtilities/AWSS3StorageCacheTestServerFixture.cs @@ -88,7 +88,7 @@ protected override void ConfigureServices(IServiceCollection services) => .AddProvider(AWSS3StorageImageProviderFactory.Create) .AddProvider() .AddProcessor() - .Configure(options => + .Configure(options => { options.Endpoint = TestConstants.AWSEndpoint; options.BucketName = TestConstants.AWSCacheBucketName;