-
-
Notifications
You must be signed in to change notification settings - Fork 16
refactor!: Simplify common S3 structs and add helper functions #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use kube::CustomResource; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::commons::{secret_class::SecretClassVolume, tls::TlsClientDetails}; | ||
|
||
use super::S3ConnectionInlineOrReference; | ||
|
||
// Contains all the needed details to access an S3 object store. | ||
#[derive(CustomResource, Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)] | ||
#[kube( | ||
group = "s3.stackable.tech", | ||
version = "v1alpha1", | ||
kind = "S3Connection", | ||
plural = "s3connections", | ||
crates( | ||
kube_core = "kube::core", | ||
k8s_openapi = "k8s_openapi", | ||
schemars = "schemars" | ||
), | ||
namespaced | ||
)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct S3ConnectionSpec { | ||
/// Hostname of the S3 server without any protocol or port. | ||
// TODO: Rename to `hostname` to be more consistent with other structs. | ||
#[serde(rename = "host")] | ||
pub hostname: String, | ||
|
||
/// Port the S3 server listens on. | ||
/// Port of the S3 server. If TLS is used defaults to 443 otherwise to 80. | ||
pub(crate) port: Option<u16>, | ||
|
||
/// Which access style to use. | ||
/// Defaults to virtual hosted-style as most of the data products out there. | ||
/// Have a look at the official documentation on <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html> | ||
#[serde(default)] | ||
pub access_style: S3AccessStyle, | ||
|
||
/// If the S3 uses authentication you have to specify you S3 credentials. | ||
/// In the most cases a SecretClass providing `accessKey` and `secretKey` is sufficient. | ||
pub credentials: Option<SecretClassVolume>, | ||
|
||
/// If you want to use TLS when talking to S3 you can enable TLS encrypted communication with this setting. | ||
#[serde(flatten)] | ||
pub tls: TlsClientDetails, | ||
} | ||
|
||
/// Contains the name of the bucket as well as the needed connection details. | ||
#[derive(Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)] | ||
#[kube( | ||
group = "s3.stackable.tech", | ||
version = "v1alpha1", | ||
kind = "S3Bucket", | ||
plural = "s3buckets", | ||
crates( | ||
kube_core = "kube::core", | ||
k8s_openapi = "k8s_openapi", | ||
schemars = "schemars" | ||
), | ||
namespaced | ||
)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct S3BucketSpec { | ||
/// Name of the bucket | ||
pub(crate) bucket_name: String, | ||
/// Either a inlined s3 connection or a reference to a S3Connection object | ||
pub(crate) connection: S3ConnectionInlineOrReference, | ||
} | ||
|
||
#[derive( | ||
strum::Display, Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize, | ||
)] | ||
#[strum(serialize_all = "PascalCase")] | ||
pub enum S3AccessStyle { | ||
/// Use path-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access> | ||
Path, | ||
/// Use as virtual hosted-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access> | ||
#[default] | ||
VirtualHosted, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.