feat: Make S3 bucket names configurable via environment variables

This commit is contained in:
Alexa
2026-06-25 14:04:36 +03:00
parent 98fa7b89cf
commit 44fc9047e0
2 changed files with 11 additions and 2 deletions
@@ -62,8 +62,8 @@ public interface IObjectStorage
public static class Buckets
{
public const string Content = "dorknet-content";
public const string Saves = "dorknet-saves";
public static string Content { get; set; } = "dorknet-content";
public static string Saves { get; set; } = "dorknet-saves";
}
/// <summary>
@@ -157,6 +157,13 @@ public class ObjectStorageService : IObjectStorage, IDisposable
{
_log = log;
_diskFallbackRoot = Path.Combine(AppContext.BaseDirectory, "data", "object-fallback");
// Bucket names are env-overridable so a new game generation can point at
// fresh buckets (e.g. dorknet2023-*) without a code change. Applied here
// (before the disk/S3 branch) so the disk fallback paths use them too.
if (config["S3:ContentBucket"] is { Length: > 0 } contentBucket) Buckets.Content = contentBucket;
if (config["S3:SavesBucket"] is { Length: > 0 } savesBucket) Buckets.Saves = savesBucket;
_log.LogInformation(
"[storage] buckets content={Content} saves={Saves}", Buckets.Content, Buckets.Saves);
// Provider switch: env-driven. The Garage one-click service in
// Coolify exposes its endpoint on http://garage:3900 and supplies