@@ -21,6 +21,9 @@ public static class NatsBuilderExtensions
21
21
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
22
22
public static IResourceBuilder < NatsServerResource > AddNats ( this IDistributedApplicationBuilder builder , string name , int ? port = null )
23
23
{
24
+ ArgumentNullException . ThrowIfNull ( builder ) ;
25
+ ArgumentNullException . ThrowIfNull ( name ) ;
26
+
24
27
var nats = new NatsServerResource ( name ) ;
25
28
return builder . AddResource ( nats )
26
29
. WithEndpoint ( targetPort : 4222 , port : port , name : NatsServerResource . PrimaryEndpointName )
@@ -54,7 +57,11 @@ public static IResourceBuilder<NatsServerResource> WithJetStream(this IResourceB
54
57
/// <param name="builder">The resource builder.</param>
55
58
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
56
59
public static IResourceBuilder < NatsServerResource > WithJetStream ( this IResourceBuilder < NatsServerResource > builder )
57
- => builder . WithArgs ( "-js" ) ;
60
+ {
61
+ ArgumentNullException . ThrowIfNull ( builder ) ;
62
+
63
+ return builder . WithArgs ( "-js" ) ;
64
+ }
58
65
59
66
/// <summary>
60
67
/// Adds a named volume for the data folder to a NATS container resource.
@@ -64,8 +71,13 @@ public static IResourceBuilder<NatsServerResource> WithJetStream(this IResourceB
64
71
/// <param name="isReadOnly">A flag that indicates if this is a read-only volume.</param>
65
72
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
66
73
public static IResourceBuilder < NatsServerResource > WithDataVolume ( this IResourceBuilder < NatsServerResource > builder , string ? name = null , bool isReadOnly = false )
67
- => builder . WithVolume ( name ?? VolumeNameGenerator . CreateVolumeName ( builder , "data" ) , "/var/lib/nats" , isReadOnly )
68
- . WithArgs ( "-sd" , "/var/lib/nats" ) ;
74
+ {
75
+ ArgumentNullException . ThrowIfNull ( builder ) ;
76
+
77
+ return builder . WithVolume ( name ?? VolumeNameGenerator . CreateVolumeName ( builder , "data" ) , "/var/lib/nats" ,
78
+ isReadOnly )
79
+ . WithArgs ( "-sd" , "/var/lib/nats" ) ;
80
+ }
69
81
70
82
/// <summary>
71
83
/// Adds a bind mount for the data folder to a NATS container resource.
@@ -75,7 +87,11 @@ public static IResourceBuilder<NatsServerResource> WithDataVolume(this IResource
75
87
/// <param name="isReadOnly">A flag that indicates if this is a read-only mount.</param>
76
88
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
77
89
public static IResourceBuilder < NatsServerResource > WithDataBindMount ( this IResourceBuilder < NatsServerResource > builder , string source , bool isReadOnly = false )
78
- => builder . WithBindMount ( source , "/var/lib/nats" , isReadOnly )
79
- . WithArgs ( "-sd" , "/var/lib/nats" ) ;
90
+ {
91
+ ArgumentNullException . ThrowIfNull ( builder ) ;
92
+ ArgumentNullException . ThrowIfNull ( source ) ;
80
93
94
+ return builder . WithBindMount ( source , "/var/lib/nats" , isReadOnly )
95
+ . WithArgs ( "-sd" , "/var/lib/nats" ) ;
96
+ }
81
97
}
0 commit comments