-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmod.rs
More file actions
84 lines (76 loc) · 2.59 KB
/
mod.rs
File metadata and controls
84 lines (76 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use kube::CustomResource;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::{crd::s3::connection::v1alpha1 as conn_v1alpha1, versioned::versioned};
mod v1alpha1_impl;
#[versioned(
version(name = "v1alpha1"),
crates(
kube_core = "kube::core",
k8s_openapi = "k8s_openapi",
schemars = "schemars",
)
)]
pub mod versioned {
pub mod v1alpha1 {
pub use v1alpha1_impl::BucketError;
}
/// S3 bucket specification containing the bucket name and an inlined or referenced connection specification.
/// Learn more on the [S3 concept documentation](DOCS_BASE_URL_PLACEHOLDER/concepts/s3).
#[versioned(crd(
group = "s3.stackable.tech",
kind = "S3Bucket",
plural = "s3buckets",
namespaced
))]
#[derive(Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BucketSpec {
/// The name of the S3 bucket.
pub bucket_name: String,
/// The definition of an S3 connection, either inline or as a reference.
pub connection: conn_v1alpha1::InlineConnectionOrReference,
}
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
// TODO: This probably should be serde(untagged), but this would be a breaking change
pub enum InlineBucketOrReference {
Inline(BucketSpec),
Reference(String),
}
/// Use this struct in your operator.
pub struct ResolvedBucket {
pub bucket_name: String,
pub connection: conn_v1alpha1::ConnectionSpec,
}
}
#[cfg(test)]
impl stackable_versioned::test_utils::RoundtripTestData for v1alpha1::BucketSpec {
fn roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- bucketName: my-example-bucket
connection:
reference: my-connection-resource
- bucketName: foo
connection:
inline:
host: s3.example.com
- bucketName: foo
connection:
inline:
host: s3.example.com
port: 1234
accessStyle: VirtualHosted
credentials:
secretClass: s3-credentials
region:
name: eu-west-1
tls:
verification:
server:
caCert:
secretClass: s3-cert
"})
.expect("Failed to parse BucketSpec YAML")
}
}