mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Combine AZ and B2 test together
This commit is contained in:
@@ -18,8 +18,6 @@ public class AzureDownloadOptions : RepositoryOptions, IObjectDownloadOptions
|
||||
public string Container { get; set; }
|
||||
|
||||
public string SasToken { get; set; }
|
||||
|
||||
public double Timeout { get; set; }
|
||||
}
|
||||
|
||||
public class AzureUploadOptions : AzureDownloadOptions, IObjectUploadOptions
|
||||
@@ -51,37 +49,44 @@ public class AzureRepository : ObjectRepository<AzureDownloadOptions, AzureUploa
|
||||
} else {
|
||||
client = new BlobServiceClient(new Uri(serviceUrl), new StorageSharedKeyCredential(options.Account, options.Key), clientOptions);
|
||||
}
|
||||
|
||||
return client.GetBlobContainerClient(options.Container);
|
||||
}
|
||||
|
||||
protected override async Task DeleteObject(BlobContainerClient client, string key)
|
||||
{
|
||||
await RetryAsync(async () => {
|
||||
await client.DeleteBlobIfExistsAsync(key);
|
||||
}, "Deleting " + key);
|
||||
await RetryAsync(
|
||||
async () => {
|
||||
await client.DeleteBlobIfExistsAsync(key);
|
||||
},
|
||||
"Deleting " + key);
|
||||
}
|
||||
|
||||
protected override async Task<byte[]> GetObjectBytes(BlobContainerClient client, string key)
|
||||
{
|
||||
return await RetryAsyncRet(async () => {
|
||||
try {
|
||||
var obj = client.GetBlobClient(key);
|
||||
var ms = new MemoryStream();
|
||||
using var response = await obj.DownloadToAsync(ms, CancellationToken.None);
|
||||
return ms.ToArray();
|
||||
} catch (Azure.RequestFailedException ex) when (ex.Status == 404) {
|
||||
return null;
|
||||
}
|
||||
}, $"Downloading {key}...");
|
||||
return await RetryAsyncRet(
|
||||
async () => {
|
||||
try {
|
||||
var obj = client.GetBlobClient(key);
|
||||
var ms = new MemoryStream();
|
||||
using var response = await obj.DownloadToAsync(ms, CancellationToken.None);
|
||||
return ms.ToArray();
|
||||
} catch (Azure.RequestFailedException ex) when (ex.Status == 404) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
$"Downloading {key}...");
|
||||
}
|
||||
|
||||
protected override async Task SaveEntryToFileAsync(AzureDownloadOptions options, VelopackAsset entry, string filePath)
|
||||
{
|
||||
await RetryAsync(async () => {
|
||||
var client = CreateClient(options);
|
||||
var obj = client.GetBlobClient(entry.FileName);
|
||||
using var response = await obj.DownloadToAsync(filePath, CancellationToken.None);
|
||||
}, $"Downloading {entry.FileName}...");
|
||||
await RetryAsync(
|
||||
async () => {
|
||||
var client = CreateClient(options);
|
||||
var obj = client.GetBlobClient(entry.FileName);
|
||||
using var response = await obj.DownloadToAsync(filePath, CancellationToken.None);
|
||||
},
|
||||
$"Downloading {entry.FileName}...");
|
||||
}
|
||||
|
||||
protected override async Task UploadObject(BlobContainerClient client, string key, FileInfo f, bool overwriteRemote, bool noCache)
|
||||
|
||||
@@ -16,8 +16,6 @@ public class GitHubDownloadOptions : RepositoryOptions
|
||||
public string RepoUrl { get; set; }
|
||||
|
||||
public string Token { get; set; }
|
||||
|
||||
public double Timeout { get; set; }
|
||||
}
|
||||
|
||||
public class GitHubUploadOptions : GitHubDownloadOptions
|
||||
|
||||
@@ -20,8 +20,6 @@ public class GiteaDownloadOptions : RepositoryOptions
|
||||
|
||||
public string Token { get; set; }
|
||||
|
||||
public double Timeout { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// Example https://gitea.com
|
||||
///// </summary>
|
||||
|
||||
@@ -6,8 +6,6 @@ namespace Velopack.Deployment;
|
||||
public class HttpDownloadOptions : RepositoryOptions
|
||||
{
|
||||
public string Url { get; set; }
|
||||
|
||||
public double Timeout { get; set; }
|
||||
}
|
||||
|
||||
public class HttpRepository : SourceRepository<HttpDownloadOptions, SimpleWebSource>
|
||||
|
||||
@@ -13,6 +13,7 @@ public class LocalDownloadOptions : RepositoryOptions, IObjectDownloadOptions
|
||||
public class LocalUploadOptions : LocalDownloadOptions, IObjectUploadOptions
|
||||
{
|
||||
public bool ForceRegenerate { get; set; }
|
||||
|
||||
public int KeepMaxReleases { get; set; }
|
||||
}
|
||||
|
||||
@@ -75,4 +76,4 @@ public class LocalRepository(ILogger logger) : ObjectRepository<LocalDownloadOpt
|
||||
var source = new SimpleFileSource(options.TargetPath);
|
||||
return source.GetReleaseFeed(channel: options.Channel, logger: Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,6 @@ public class S3DownloadOptions : RepositoryOptions, IObjectDownloadOptions
|
||||
public string Bucket { get; set; }
|
||||
|
||||
public string Prefix { get; set; }
|
||||
|
||||
public double Timeout { get; set; }
|
||||
}
|
||||
|
||||
public class S3UploadOptions : S3DownloadOptions, IObjectUploadOptions
|
||||
@@ -101,7 +99,7 @@ public class S3Repository : ObjectRepository<S3DownloadOptions, S3UploadOptions,
|
||||
ForcePathStyle = true, // support for MINIO
|
||||
Timeout = TimeSpan.FromMinutes(options.Timeout)
|
||||
};
|
||||
|
||||
|
||||
if (options.Endpoint != null) {
|
||||
config.ServiceURL = options.Endpoint;
|
||||
// if the endpoint is using https, and is _not_ an AWS endpoint, we can disable signing
|
||||
|
||||
@@ -19,6 +19,8 @@ public class RepositoryOptions : IOutputOptions
|
||||
}
|
||||
|
||||
public DirectoryInfo ReleaseDir { get; set; }
|
||||
|
||||
public double Timeout { get; set; } = 30d;
|
||||
}
|
||||
|
||||
public interface IRepositoryCanUpload<TUp> where TUp : RepositoryOptions
|
||||
@@ -37,7 +39,8 @@ public abstract class SourceRepository<TDown, TSource> : DownRepository<TDown>
|
||||
{
|
||||
public SourceRepository(ILogger logger)
|
||||
: base(logger)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
protected override Task<VelopackAssetFeed> GetReleasesAsync(TDown options)
|
||||
{
|
||||
@@ -104,8 +107,7 @@ public abstract class DownRepository<TDown> : IRepositoryCanDownload<TDown>
|
||||
Log.Error($"Checksum mismatch, expected {latest.SHA256}, got {newHash}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (latest.SHA1 != (newHash = IoUtil.CalculateFileSHA1(incomplete))) {
|
||||
} else if (latest.SHA1 != (newHash = IoUtil.CalculateFileSHA1(incomplete))) {
|
||||
Log.Error($"Checksum mismatch, expected {latest.SHA1}, got {newHash}");
|
||||
return;
|
||||
}
|
||||
@@ -156,4 +158,4 @@ public abstract class DownRepository<TDown> : IRepositoryCanDownload<TDown>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,25 +17,47 @@ public static partial class OptionMapper
|
||||
public static partial TDest Map<TDest>(object source);
|
||||
|
||||
public static partial OsxPackOptions ToOptions(this OsxPackCommand cmd);
|
||||
|
||||
public static partial WindowsPackOptions ToOptions(this WindowsPackCommand cmd);
|
||||
|
||||
public static partial LinuxPackOptions ToOptions(this LinuxPackCommand cmd);
|
||||
|
||||
public static partial OsxBundleOptions ToOptions(this OsxBundleCommand cmd);
|
||||
|
||||
public static partial GitHubDownloadOptions ToOptions(this GitHubDownloadCommand cmd);
|
||||
|
||||
public static partial GitHubUploadOptions ToOptions(this GitHubUploadCommand cmd);
|
||||
|
||||
public static partial GiteaDownloadOptions ToOptions(this GiteaDownloadCommand cmd);
|
||||
|
||||
public static partial GiteaUploadOptions ToOptions(this GiteaUploadCommand cmd);
|
||||
|
||||
public static partial HttpDownloadOptions ToOptions(this HttpDownloadCommand cmd);
|
||||
|
||||
[MapperIgnoreTarget(nameof(LocalDownloadOptions.Timeout))]
|
||||
public static partial LocalDownloadOptions ToOptions(this LocalDownloadCommand cmd);
|
||||
|
||||
[MapperIgnoreTarget(nameof(LocalDownloadOptions.Timeout))]
|
||||
public static partial LocalUploadOptions ToOptions(this LocalUploadCommand cmd);
|
||||
|
||||
public static partial S3DownloadOptions ToOptions(this S3DownloadCommand cmd);
|
||||
|
||||
public static partial S3UploadOptions ToOptions(this S3UploadCommand cmd);
|
||||
|
||||
public static partial AzureDownloadOptions ToOptions(this AzureDownloadCommand cmd);
|
||||
|
||||
public static partial AzureUploadOptions ToOptions(this AzureUploadCommand cmd);
|
||||
|
||||
public static partial DeltaGenOptions ToOptions(this DeltaGenCommand cmd);
|
||||
|
||||
public static partial DeltaPatchOptions ToOptions(this DeltaPatchCommand cmd);
|
||||
|
||||
public static partial LoginOptions ToOptions(this LoginCommand cmd);
|
||||
|
||||
public static partial LogoutOptions ToOptions(this LogoutCommand cmd);
|
||||
|
||||
public static partial PublishOptions ToOptions(this PublishCommand cmd);
|
||||
|
||||
public static partial ApiOptions ToOptions(this ApiCommand cmd);
|
||||
|
||||
private static DirectoryInfo StringToDirectoryInfo(string t)
|
||||
@@ -51,4 +73,4 @@ public static partial class OptionMapper
|
||||
if (t == null) return null;
|
||||
return RID.Parse(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user