forked from CommunityToolkit/Aspire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinioContainerResource.cs
More file actions
52 lines (42 loc) · 1.84 KB
/
MinioContainerResource.cs
File metadata and controls
52 lines (42 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace Aspire.Hosting.ApplicationModel;
/// <summary>
/// A resource that represents a MiniO storage
/// </summary>
/// <param name="name">The name of the resource</param>
/// <param name="rootUser"> A parameter that contains the MiniO server admin user name, or null to</param>
/// <param name="rootPassword"> A parameter that contains the Minio server admin password</param>
public sealed class MinioContainerResource(
string name,
ParameterResource rootUser,
ParameterResource rootPassword) : ContainerResource(name),
IResourceWithConnectionString
{
internal const string PrimaryEndpointName = "http";
internal const string DefaultUserName = "minioadmin";
/// <summary>
/// The MiniO root user.
/// </summary>
public ParameterResource RootUser { get; set; } = rootUser;
/// <summary>
/// The MiniO root password.
/// </summary>
public ParameterResource RootPassword { get; } = rootPassword;
private EndpointReference? _primaryEndpoint;
/// <summary>
/// Gets the primary endpoint for the Minio. This endpoint is used for all API calls over HTTP.
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);
/// <summary>
/// Gets the connection string expression for the Minio
/// </summary>
public ReferenceExpression ConnectionStringExpression => GetConnectionString();
private ReferenceExpression GetConnectionString()
{
var builder = new ReferenceExpressionBuilder();
builder.Append(
$"Endpoint=http://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
builder.Append($";AccessKey={RootUser.Value}");
builder.Append($";SecretKey={RootPassword.Value}");
return builder.Build();
}
}