Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- BREAKING: Removed commons::s3::S3ConnectionImplementation.
commons::s3::InlinedBucketSpec::endpoint() doesn't take arguments since the protocol
decision is now based on the existance of TLS configuration ([#390]).

[#390]: https://github.com/stackabletech/operator-rs/issues/390

## [0.18.0] - 2022-05-04

### Added
Expand Down
29 changes: 7 additions & 22 deletions src/commons/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ pub struct InlinedS3BucketSpec {

impl InlinedS3BucketSpec {
/// Build the endpoint URL from [S3ConnectionSpec::host] and [S3ConnectionSpec::port] and the S3 implementation to use
pub fn endpoint(&self, implementation: &S3ConnectionImplementation) -> Option<String> {
let implementation = implementation.to_string();
pub fn endpoint(&self) -> Option<String> {
let protocol = match self.connection.as_ref().and_then(|c| c.tls.as_ref()) {
Some(_tls) => "https",
_ => "http",
};
self.connection.as_ref().and_then(|connection| {
connection.host.as_ref().map(|h| match connection.port {
Some(p) => format!("{implementation}://{h}:{p}"),
None => format!("{implementation}://{h}"),
Some(p) => format!("{protocol}://{h}:{p}"),
None => format!("{protocol}://{h}"),
})
})
}
Expand All @@ -96,24 +99,6 @@ impl InlinedS3BucketSpec {
}
}

/// The implementation the product should use when interacting with S3
/// It is sometimes called protocol as it is prepended to the connection endpoint, e.g. `s3a://<host>`
/// but it often specifies which s3 client implemtation to use, the used protocol on the wire is always S3.
/// Spark e.g. supports `s3a` and `cos` as S3 connectors/implementations, which are different implementations but talk to the same S3 endpoint.
pub enum S3ConnectionImplementation {
S3,
S3a,
}

impl ToString for S3ConnectionImplementation {
fn to_string(&self) -> String {
match self {
S3ConnectionImplementation::S3 => "s3".to_string(),
S3ConnectionImplementation::S3a => "s3a".to_string(),
}
}
}

/// Operators are expected to define fields for this type in order to work with S3 buckets.
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down