@@ -18,18 +18,16 @@ public static class MinioBuilderExtensions
18
18
/// </summary>
19
19
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/>.</param>
20
20
/// <param name="name">The name of the resource. This name will be used as the connection string name when referenced in a dependency.</param>
21
- /// <param name="minioConsolePort">The host port for MinioO Admin.</param>
22
- /// <param name="minioPort">The host port for MiniO.</param>
23
- /// <param name="rootUser">The root user for the MiniO server.</param>
24
- /// <param name="rootPassword">The password for the MiniO root user.</param>
21
+ /// <param name="port">The host port for MiniO.</param>
22
+ /// <param name="rootUser">The parameter used to provide the root user name for the MiniO resource. If <see langword="null"/> a default value will be used.</param>
23
+ /// <param name="rootPassword">The parameter used to provide the administrator password for the MiniO resource. If <see langword="null"/> a random password will be generated.</param>
25
24
/// <returns>A reference to the <see cref="IResourceBuilder{MinioContainerResource}"/>.</returns>
26
25
public static IResourceBuilder < MinioContainerResource > AddMinioContainer (
27
26
this IDistributedApplicationBuilder builder ,
28
- string name ,
27
+ [ ResourceName ] string name ,
29
28
IResourceBuilder < ParameterResource > ? rootUser = null ,
30
29
IResourceBuilder < ParameterResource > ? rootPassword = null ,
31
- int minioPort = 9000 ,
32
- int minioConsolePort = 9001 )
30
+ int ? port = null )
33
31
{
34
32
ArgumentNullException . ThrowIfNull ( builder ) ;
35
33
ArgumentException . ThrowIfNullOrEmpty ( name ) ;
@@ -39,18 +37,16 @@ public static IResourceBuilder<MinioContainerResource> AddMinioContainer(
39
37
40
38
var rootUserParameter = rootUser ? . Resource ?? new ParameterResource ( "user" , _ => MinioContainerResource . DefaultUserName ) ;
41
39
42
- var minioContainer = new MinioContainerResource ( name , rootUserParameter , rootPasswordParameter ) ;
40
+ var resource = new MinioContainerResource ( name , rootUserParameter , rootPasswordParameter ) ;
43
41
44
42
var builderWithResource = builder
45
- . AddResource ( minioContainer )
43
+ . AddResource ( resource )
46
44
. WithImage ( MinioContainerImageTags . Image , MinioContainerImageTags . Tag )
47
45
. WithImageRegistry ( MinioContainerImageTags . Registry )
48
- . WithHttpEndpoint ( targetPort : 9000 , port : minioPort , name : MinioContainerResource . PrimaryEndpointName )
49
- . WithHttpEndpoint ( targetPort : 9001 , port : minioConsolePort , name : "console" )
50
- . WithEnvironment ( "MINIO_ADDRESS" , $ ":{ minioPort . ToString ( ) } ")
51
- . WithEnvironment ( "MINIO_CONSOLE_ADDRESS" , $ ":{ minioConsolePort . ToString ( ) } ")
52
- . WithEnvironment ( RootUserEnvVarName , minioContainer . RootUser . Value )
53
- . WithEnvironment ( RootPasswordEnvVarName , minioContainer . RootPassword . Value )
46
+ . WithHttpEndpoint ( targetPort : 9000 , port : port , name : MinioContainerResource . PrimaryEndpointName )
47
+ . WithHttpEndpoint ( targetPort : 9001 , name : MinioContainerResource . ConsoleEndpointName )
48
+ . WithEnvironment ( RootUserEnvVarName , resource . RootUser . Value )
49
+ . WithEnvironment ( RootPasswordEnvVarName , resource . PasswordParameter . Value )
54
50
. WithArgs ( "server" , "/data" ) ;
55
51
56
52
var endpoint = builderWithResource . Resource . GetEndpoint ( MinioContainerResource . PrimaryEndpointName ) ;
@@ -74,6 +70,52 @@ public static IResourceBuilder<MinioContainerResource> AddMinioContainer(
74
70
return builderWithResource ;
75
71
}
76
72
73
+
74
+ /// <summary>
75
+ /// Configures the user name that the Minio resource uses.
76
+ /// </summary>
77
+ /// <param name="builder">The resource builder.</param>
78
+ /// <param name="userName">The parameter used to provide the user name for the PostgreSQL resource.</param>
79
+ /// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
80
+ public static IResourceBuilder < MinioContainerResource > WithUserName ( this IResourceBuilder < MinioContainerResource > builder , IResourceBuilder < ParameterResource > userName )
81
+ {
82
+ ArgumentNullException . ThrowIfNull ( builder ) ;
83
+ ArgumentNullException . ThrowIfNull ( userName ) ;
84
+
85
+ builder . Resource . RootUser = userName . Resource ;
86
+ return builder ;
87
+ }
88
+
89
+ /// <summary>
90
+ /// Configures the password that the MiniO resource is used.
91
+ /// </summary>
92
+ /// <param name="builder">The resource builder.</param>
93
+ /// <param name="password">The parameter used to provide the password for the MiniO resource. If <see langword="null"/>, no password will be configured.</param>
94
+ /// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
95
+ public static IResourceBuilder < MinioContainerResource > WithPassword ( this IResourceBuilder < MinioContainerResource > builder , IResourceBuilder < ParameterResource > password )
96
+ {
97
+ ArgumentNullException . ThrowIfNull ( builder ) ;
98
+
99
+ builder . Resource . SetPassword ( password . Resource ) ;
100
+ return builder ;
101
+ }
102
+
103
+ /// <summary>
104
+ /// Configures the host port that the PGAdmin resource is exposed on instead of using randomly assigned port.
105
+ /// </summary>
106
+ /// <param name="builder">The resource builder for PGAdmin.</param>
107
+ /// <param name="port">The port to bind on the host. If <see langword="null"/> is used, a random port will be assigned.</param>
108
+ /// <returns>The resource builder for PGAdmin.</returns>
109
+ public static IResourceBuilder < MinioContainerResource > WithHostPort ( this IResourceBuilder < MinioContainerResource > builder , int ? port )
110
+ {
111
+ ArgumentNullException . ThrowIfNull ( builder ) ;
112
+
113
+ return builder . WithEndpoint ( "http" , endpoint =>
114
+ {
115
+ endpoint . Port = port ;
116
+ } ) ;
117
+ }
118
+
77
119
/// <summary>
78
120
/// Adds a named volume for the data folder to a Minio container resource.
79
121
/// </summary>
0 commit comments