-
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.
- Loading branch information
Showing
6 changed files
with
879 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pulumi/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using Pulumi.Azure.Extensions.Utils; | ||
using Pulumi.Azure.Storage; | ||
|
||
namespace Pulumi.Azure.Extensions.Storage | ||
{ | ||
public sealed class BlobCollectionArgs : ResourceArgs | ||
{ | ||
/// <summary> | ||
/// The access tier of the storage blob. Possible values are `Archive`, `Cool` and `Hot`. | ||
/// </summary> | ||
[Input("accessTier", false, false)] | ||
public Input<string> AccessTier { get; set; } | ||
|
||
/// <summary> | ||
/// The number of workers per CPU core to run for concurrent uploads. Defaults to `8`. | ||
/// </summary> | ||
[Input("parallelism", false, false)] | ||
public Input<int> Parallelism { get; set; } | ||
|
||
/// <summary> | ||
/// Specifies the storage account in which to create the storage container. | ||
/// Changing this forces a new resource to be created. | ||
/// </summary> | ||
[Input("storageAccountName", true, false)] | ||
public Input<string> StorageAccountName { get; set; } | ||
|
||
/// <summary> | ||
/// The name of the storage container in which this blob should be created. | ||
/// </summary> | ||
[Input("storageContainerName", true, false)] | ||
public Input<string> StorageContainerName { get; set; } | ||
|
||
/// <summary> | ||
/// The type of the storage blobs to be created. Possible values are `Append`, `Block` or `Page`. Changing this forces a new resource to be created. | ||
/// </summary> | ||
[Input("type", true, false)] | ||
public Input<string> Type { get; set; } | ||
} | ||
|
||
public sealed class BlobCollection | ||
{ | ||
private const string SearchPattern = "*.*"; | ||
|
||
/// <summary> | ||
/// Upload all files and folders from a sourceFolder to a Blob Storage Account in Azure. | ||
/// </summary> | ||
/// <param name="sourceFolder">An absolute path to a folder on the local file system.</param> | ||
/// <param name="args">The arguments used to populate the <see cref="Blob"/> resources.</param> | ||
public BlobCollection(string sourceFolder, BlobCollectionArgs args) | ||
{ | ||
if (string.IsNullOrEmpty(sourceFolder)) | ||
{ | ||
throw new ArgumentNullException(nameof(sourceFolder)); | ||
} | ||
|
||
if (args == null) | ||
{ | ||
throw new ArgumentNullException(nameof(args)); | ||
} | ||
|
||
int sourceFolderLength = sourceFolder.Length + 1; | ||
|
||
var files = Directory.EnumerateFiles(sourceFolder, SearchPattern, SearchOption.AllDirectories) | ||
.Select(path => new | ||
{ | ||
info = new FileInfo(path), | ||
name = path.Remove(0, sourceFolderLength).Replace(Path.PathSeparator, '/'), // Make the name Azure Storage compatible | ||
}) | ||
.Where(file => file.info.Length > 0) // https://github.com/pulumi/pulumi-azure/issues/544 | ||
; | ||
|
||
foreach (var file in files) | ||
{ | ||
_ = new Blob(file.name, new BlobArgs | ||
{ | ||
AccessTier = args.AccessTier, | ||
Name = file.name, | ||
StorageAccountName = args.StorageAccountName, | ||
StorageContainerName = args.StorageContainerName, | ||
Type = args.Type, | ||
Source = new FileAsset(file.info.FullName), | ||
ContentType = MimeTypeMap.GetMimeType(file.info.Extension) | ||
}); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.