44//! Operator CRDs are expected to use the [S3BucketDef] as an entry point to this module
55//! and obtain an [InlinedS3BucketSpec] by calling [`S3BucketDef::resolve`].
66//!
7- use crate :: commons:: tls:: Tls ;
7+ use crate :: commons:: { secret_class :: SecretClassVolume , tls:: Tls } ;
88use crate :: error;
99use crate :: { client:: Client , error:: OperatorResult } ;
1010use kube:: CustomResource ;
@@ -82,14 +82,6 @@ impl InlinedS3BucketSpec {
8282 . as_ref ( )
8383 . and_then ( |connection| connection. endpoint ( ) )
8484 }
85-
86- /// Shortcut to [S3ConnectionSpec::secret_class]
87- pub fn secret_class ( & self ) -> Option < String > {
88- match self . connection . as_ref ( ) {
89- Some ( conn_spec) => conn_spec. secret_class . clone ( ) ,
90- _ => None ,
91- }
92- }
9385}
9486
9587/// Operators are expected to define fields for this type in order to work with S3 buckets.
@@ -159,14 +151,23 @@ impl S3ConnectionDef {
159151) ]
160152#[ serde( rename_all = "camelCase" ) ]
161153pub struct S3ConnectionSpec {
154+ /// Hostname of the S3 server without any protocol or port
162155 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
163156 pub host : Option < String > ,
157+ /// Port the S3 server listens on.
158+ /// If not specified the products will determine the port to use.
164159 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
165160 pub port : Option < u16 > ,
161+ /// Which access style to use.
162+ /// Defaults to virtual hosted-style as most of the data products out there.
163+ /// Have a look at the official documentation on <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html>
166164 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
167165 pub access_style : Option < S3AccessStyle > ,
166+ /// If the S3 uses authentication you have to specify you S3 credentials.
167+ /// In the most cases a SecretClass providing `accessKey` and `secretKey` is sufficient.
168168 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
169- pub secret_class : Option < String > ,
169+ pub credentials : Option < SecretClassVolume > ,
170+ /// If you want to use TLS when talking to S3 you can enable TLS encrypted communication with this setting.
170171 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
171172 pub tls : Option < Tls > ,
172173}
@@ -203,7 +204,9 @@ impl S3ConnectionSpec {
203204#[ derive( strum:: Display , Clone , Debug , Deserialize , JsonSchema , PartialEq , Serialize ) ]
204205#[ strum( serialize_all = "PascalCase" ) ]
205206pub enum S3AccessStyle {
207+ /// Use path-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access>
206208 Path ,
209+ /// Use as virtual hosted-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access>
207210 VirtualHosted ,
208211}
209212
@@ -225,7 +228,7 @@ mod test {
225228 connection : Some ( S3ConnectionDef :: Inline ( S3ConnectionSpec {
226229 host : Some ( "host" . to_owned ( ) ) ,
227230 port : Some ( 8080 ) ,
228- secret_class : None ,
231+ credentials : None ,
229232 access_style : Some ( S3AccessStyle :: VirtualHosted ) ,
230233 tls : None ,
231234 } ) ) ,
0 commit comments