-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathdummy.rs
More file actions
197 lines (182 loc) · 7.14 KB
/
Copy pathdummy.rs
File metadata and controls
197 lines (182 loc) · 7.14 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use stackable_operator::{
commons::resources::{JvmHeapLimits, Resources},
config::fragment::Fragment,
config_overrides::{KeyValueConfigOverrides, KeyValueOverridesProvider},
crd::{
authentication::{self, oidc},
git_sync::v1alpha2::GitSync,
},
database_connections::{
databases::{
derby::DerbyConnection, mysql::MysqlConnection, postgresql::PostgresqlConnection,
redis::RedisConnection,
},
drivers::{
celery::GenericCeleryDatabaseConnection, jdbc::GenericJdbcDatabaseConnection,
sqlalchemy::GenericSqlAlchemyDatabaseConnection,
},
},
deep_merger::ObjectOverrides,
kube::CustomResource,
role_utils::Role,
schemars::JsonSchema,
status::condition::ClusterCondition,
v2::config_overrides::JsonConfigOverrides,
versioned::versioned,
};
use strum::EnumIter;
/// Typed config override strategies for Dummy config files.
///
/// Demonstrates both JSON-formatted (`config.json`) and key-value-formatted
/// (`dummy.properties`) config file overrides.
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
#[schemars(crate = "stackable_operator::schemars")]
#[serde(rename_all = "camelCase")]
pub struct DummyConfigOverrides {
/// Overrides for the `config.json` file.
#[serde(
default,
rename = "config.json",
skip_serializing_if = "Option::is_none"
)]
pub config_json: Option<JsonConfigOverrides>,
/// Overrides for the `dummy.properties` file.
#[serde(
default,
rename = "dummy.properties",
skip_serializing_if = "Option::is_none"
)]
pub dummy_properties: Option<KeyValueConfigOverrides>,
}
impl KeyValueOverridesProvider for DummyConfigOverrides {
fn get_key_value_overrides(&self, file: &str) -> BTreeMap<String, Option<String>> {
match file {
"dummy.properties" => self
.dummy_properties
.as_ref()
.map(KeyValueConfigOverrides::as_product_config_overrides)
.unwrap_or_default(),
_ => BTreeMap::new(),
}
}
}
#[versioned(
version(name = "v1alpha1"),
crates(
kube_core = "stackable_operator::kube::core",
kube_client = "stackable_operator::kube::client",
k8s_openapi = "stackable_operator::k8s_openapi",
schemars = "stackable_operator::schemars",
versioned = "stackable_operator::versioned"
)
)]
pub mod versioned {
#[versioned(crd(
group = "dummy.stackable.tech",
kind = "DummyCluster",
status = "v1alpha1::DummyClusterStatus",
doc = "A DummyCluster is a test-only resource used by operator-rs to exercise CRD generation. It is not backed by a real operator.",
namespaced,
))]
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
#[schemars(crate = "stackable_operator::schemars")]
#[serde(rename_all = "camelCase")]
pub struct DummyClusterSpec {
nodes: Option<Role<ProductConfigFragment, DummyConfigOverrides>>,
// Not versioned yet
stackable_affinity: stackable_operator::commons::affinity::StackableAffinity,
stackable_node_selector: stackable_operator::commons::affinity::StackableNodeSelector,
user_information_cache: stackable_operator::commons::cache::UserInformationCache,
cluster_operation: stackable_operator::commons::cluster_operation::ClusterOperation,
domain_name: stackable_operator::commons::networking::DomainName,
host_name: stackable_operator::commons::networking::HostName,
kerberos_realm_name: stackable_operator::commons::networking::KerberosRealmName,
opa_config: stackable_operator::commons::opa::OpaConfig,
pdb_config: stackable_operator::commons::pdb::PdbConfig,
product_image: stackable_operator::commons::product_image_selection::ProductImage,
secret_class_volume: stackable_operator::commons::secret_class::SecretClassVolume,
secret_reference: stackable_operator::shared::secret::SecretReference,
tls_client_details: stackable_operator::commons::tls_verification::TlsClientDetails,
git_sync: GitSync,
database_connection: DummyDatabaseConnection,
#[serde(default)]
pub object_overrides: ObjectOverrides,
// Already versioned
client_authentication_details: authentication::core::v1alpha1::ClientAuthenticationDetails<
oidc::v1alpha1::ClientAuthenticationMethodOption,
>,
}
#[derive(Debug, Default, PartialEq, Fragment, JsonSchema)]
#[fragment_attrs(
derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema),
schemars(crate = "stackable_operator::schemars"),
serde(rename_all = "camelCase")
)]
#[schemars(crate = "stackable_operator::schemars")]
pub struct ProductConfig {
#[fragment_attrs(serde(default))]
resources: Resources<ProductStorageConfig, JvmHeapLimits>,
#[fragment_attrs(serde(default))]
pub logging: stackable_operator::product_logging::spec::Logging<Container>,
}
#[derive(Debug, Default, PartialEq, Fragment, JsonSchema)]
#[fragment_attrs(
derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema),
schemars(crate = "stackable_operator::schemars"),
serde(rename_all = "camelCase")
)]
#[schemars(crate = "stackable_operator::schemars")]
pub struct ProductStorageConfig {
data_storage: stackable_operator::commons::resources::PvcConfig,
}
#[derive(
Clone,
Debug,
Deserialize,
Eq,
EnumIter,
JsonSchema,
Ord,
PartialEq,
PartialOrd,
Serialize,
strum::Display,
)]
#[serde(rename_all = "kebab-case")]
#[strum(serialize_all = "kebab-case")]
#[schemars(crate = "stackable_operator::schemars")]
pub enum Container {
Prepare,
Vector,
BundleBuilder,
Opa,
UserInfoFetcher,
}
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
#[schemars(crate = "stackable_operator::schemars")]
pub enum DummyDatabaseConnection {
Postgresql(PostgresqlConnection),
Mysql(MysqlConnection),
Derby(DerbyConnection),
Redis(RedisConnection),
GenericJdbc(GenericJdbcDatabaseConnection),
GenericSqlAlchemy(GenericSqlAlchemyDatabaseConnection),
GenericCelery(GenericCeleryDatabaseConnection),
}
#[derive(Clone, Default, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
#[schemars(crate = "stackable_operator::schemars")]
#[serde(rename_all = "camelCase")]
pub struct DummyClusterStatus {
pub conditions: Vec<ClusterCondition>,
}
}
#[cfg(test)]
impl stackable_operator::versioned::test_utils::RoundtripTestData for v1alpha1::DummyClusterSpec {
fn roundtrip_test_data() -> Vec<Self> {
// In the DummyCluster we only have v1alpha1, so there is no point in testing roundtrips.
vec![]
}
}