Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
17ff823
feat(stackable-versioned): Add flux-converter
sbernauer May 27, 2025
eb141e0
test: Add roundtrip generation via macro
sbernauer May 28, 2025
5a1a62f
fix some tests
sbernauer May 28, 2025
6a88cf4
Fix remaining tests
sbernauer May 28, 2025
3de96a7
fix rest of tests
sbernauer May 30, 2025
91e440d
Merge branch 'main' into feat/flux-converter-2
sbernauer Jun 2, 2025
27b89b4
chore: Merge branch 'main' into feat/flux-converter-2
Techassi Jun 3, 2025
95d2c83
chore: Merge branch 'main' into feat/flux-converter-2
Techassi Jun 3, 2025
3a10e4d
refactor(k8s-version): Move darling code into module
Techassi Jun 10, 2025
86a1c66
refactor(stackable-versioned): Split utils into separate files
Techassi Jun 10, 2025
bc7da2b
chore(stackable-versioned): Cleanup, move and improve conversion code
Techassi Jun 10, 2025
de8db62
chore(stackable-versioned): Move K8s related error enums
Techassi Jun 10, 2025
57011ab
chore(stackable-versioned): Move code, add error handling
Techassi Jun 11, 2025
51162b9
chore(stackable-versioned): Remove roundtrip tests
Techassi Jun 11, 2025
a6e1273
chore(crd-preview): Fix macro, add re-exports
Techassi Jun 11, 2025
297f75b
chore!(stackable-versioned): Remove unused merged_crd skip flag
Techassi Jun 11, 2025
15bb2a4
fix(stackable-versioned): Emit status field during conversion
Techassi Jun 11, 2025
cfa83ca
chore: Fix clippy lints
Techassi Jun 11, 2025
510a32e
test(stackable-versioned): Adjust snapshots
Techassi Jun 11, 2025
ae2954a
chore: Add rust-analyzer setting
Techassi Jun 11, 2025
83fec7e
chore: Allow RUSTSEC-2024-0436 advisory
Techassi Jun 11, 2025
70c5367
chore(stackable-versioned): Remove unused fixtures
Techassi Jun 11, 2025
37f476d
chore(stackable-versioned): Remove unused feature
Techassi Jun 11, 2025
0e544dc
chore(stackable-versioned): Fix rustdoc
Techassi Jun 11, 2025
b004805
chore: Remove unused dependencies
Techassi Jun 12, 2025
ffd4db8
chore(stackable-versioned): Move Otel attributes into constants
Techassi Jun 12, 2025
914b466
docs(stackable-versioned): Adjust K8s doc comments
Techassi Jun 12, 2025
619a26c
test(stackable-versioned): Improve conversion_paths unit test
Techassi Jun 12, 2025
a432a18
chore(stackable-versioned): Update changelog
Techassi Jun 12, 2025
54f4185
chore: Apply suggestions
Techassi Jun 13, 2025
195b7b7
docs(stackable-versioned): Add doc comments
Techassi Jun 13, 2025
e1bf934
chore: Apply suggestion
Techassi Jun 13, 2025
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
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ educe = { version = "0.6.0", default-features = false, features = ["Clone", "De
either = "1.13.0"
futures = "0.3.30"
futures-util = "0.3.30"
indexmap = "2.5"
indexmap = "2.5.0"
indoc = "2.0.6"
insta = { version= "1.40", features = ["glob"] }
hyper = { version = "1.4.1", features = ["full"] }
hyper-util = "0.1.8"
Expand Down
3 changes: 2 additions & 1 deletion crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ versioned = []

[dependencies]
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] }
stackable-versioned = { path = "../stackable-versioned", features = ["k8s"] }
stackable-versioned = { path = "../stackable-versioned", features = ["k8s", "flux-converter"] }
stackable-operator-derive = { path = "../stackable-operator-derive" }
stackable-shared = { path = "../stackable-shared" }

Expand All @@ -28,6 +28,7 @@ dockerfile-parser.workspace = true
either.workspace = true
educe.workspace = true
futures.workspace = true
indoc.workspace = true
indexmap.workspace = true
json-patch.workspace = true
k8s-openapi.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/commons/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! crates(
//! kube_core = "stackable_operator::kube::core",
//! k8s_openapi = "stackable_operator::k8s_openapi",
//! schemars = "stackable_operator::schemars"
//! schemars = "stackable_operator::schemars",
//! )
//! )]
//! #[serde(rename_all = "camelCase")]
Expand Down
60 changes: 59 additions & 1 deletion crates/stackable-operator/src/crd/authentication/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub mod versioned {
crates(
kube_core = "kube::core",
k8s_openapi = "k8s_openapi",
schemars = "schemars"
schemars = "schemars",
)
))]
#[derive(
Expand Down Expand Up @@ -153,3 +153,61 @@ pub mod versioned {
oidc: Option<oidc::v1alpha1::ClientAuthenticationOptions<O>>,
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData
for v1alpha1::AuthenticationClassSpec
{
fn get_roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- provider:
static:
userCredentialsSecret:
name: simple-users-credentials
- provider:
ldap:
hostname: my.ldap.server
port: 389
searchBase: ou=users,dc=example,dc=org
searchFilter: foo
bindCredentials:
secretClass: openldap-bind-credentials
ldapFieldNames:
email: email
givenName: givenName
group: group
surname: surname
uid: uid
tls:
verification:
server:
caCert:
secretClass: s3-cert
- provider:
oidc:
hostname: my.keycloak.server
port: 8080
rootPath: /realms/master
scopes:
- email
- openid
- profile
principalClaim: preferred_username
providerHint: Keycloak
tls:
verification:
server:
caCert:
secretClass: s3-cert
- provider:
tls: {}
- provider:
tls:
clientCertSecretClass: client-auth-tls
- provider:
kerberos:
kerberosSecretClass: kerberos-auth
"})
.expect("Failed to parse AuthenticationClassSpec YAML")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Default for FieldNames {
#[cfg(test)]
mod tests {
use super::*;
use crate::commons::secret_class::SecretClassVolume;
use crate::{commons::secret_class::SecretClassVolume, utils::yaml_from_str_singleton_map};

#[test]
fn minimal() {
Expand Down Expand Up @@ -213,9 +213,7 @@ mod tests {
caCert:
secretClass: ldap-ca-cert
"#;
let deserializer = serde_yaml::Deserializer::from_str(input);
let ldap: AuthenticationProvider =
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
let ldap: AuthenticationProvider = yaml_from_str_singleton_map(input).unwrap();

assert_eq!(ldap.port(), 42);
assert!(ldap.tls.uses_tls());
Expand Down
6 changes: 2 additions & 4 deletions crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod tests {
use super::*;
use crate::{
config::fragment::validate, product_config_utils::env_vars_from,
product_logging::spec::default_container_log_config,
product_logging::spec::default_container_log_config, utils::yaml_from_str_singleton_map,
};

#[test]
Expand Down Expand Up @@ -435,9 +435,7 @@ mod tests {
--git-config: key:value,safe.directory:/safe-dir
"#;

let deserializer = serde_yaml::Deserializer::from_str(git_sync_spec);
let git_syncs: Vec<GitSync> =
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
let git_syncs: Vec<GitSync> = yaml_from_str_singleton_map(git_sync_spec).unwrap();

let resolved_product_image = ResolvedProductImage {
image: "oci.stackable.tech/sdp/product:latest".to_string(),
Expand Down
21 changes: 21 additions & 0 deletions crates/stackable-operator/src/crd/listener/class/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ pub mod versioned {
pub preferred_address_type: core_v1alpha1::PreferredAddressType,
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData
for v1alpha1::ListenerClassSpec
{
fn get_roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- serviceType: ClusterIP
- serviceType: NodePort
- serviceType: LoadBalancer
- serviceType: ClusterIP
loadBalancerAllocateNodePorts: false
loadBalancerClass: foo
serviceAnnotations:
foo: bar
serviceExternalTrafficPolicy: Local
preferredAddressType: HostnameConservative
"})
.expect("Failed to parse ListenerClassSpec YAML")
}
}
53 changes: 53 additions & 0 deletions crates/stackable-operator/src/crd/listener/listeners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,56 @@ pub mod versioned {
Cluster,
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData for v1alpha1::ListenerSpec {
fn get_roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- {}
- className: cluster-internal
extraPodLabelSelectorLabels: {}
ports: []
publishNotReadyAddresses: true
- className: external-unstable
extraPodLabelSelectorLabels:
foo: bar
ports:
- name: http
port: 8080
protocol: TCP
publishNotReadyAddresses: true
"})
.expect("Failed to parse ListenerSpec YAML")
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData
for v1alpha1::PodListenersSpec
{
fn get_roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- listeners: {}
- listeners:
foo:
scope: Node
- listeners:
foo:
scope: Cluster
ingressAddresses:
- address: 1.2.3.4
addressType: IP
ports: {}
- listeners:
foo:
scope: Cluster
ingressAddresses:
- address: foo.bar
addressType: Hostname
ports:
http: 8080
https: 8443
"})
.expect("Failed to parse PodListenersSpec YAML")
}
}
33 changes: 32 additions & 1 deletion crates/stackable-operator/src/crd/s3/bucket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod versioned {
crates(
kube_core = "kube::core",
k8s_openapi = "k8s_openapi",
schemars = "schemars"
schemars = "schemars",
),
namespaced
))]
Expand Down Expand Up @@ -49,3 +49,34 @@ pub mod versioned {
pub connection: conn_v1alpha1::ConnectionSpec,
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData for v1alpha1::BucketSpec {
fn get_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")
}
}
34 changes: 33 additions & 1 deletion crates/stackable-operator/src/crd/s3/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod versioned {
crates(
kube_core = "kube::core",
k8s_openapi = "k8s_openapi",
schemars = "schemars"
schemars = "schemars",
),
namespaced
))]
Expand Down Expand Up @@ -101,6 +101,38 @@ pub mod versioned {
}
}

#[cfg(test)]
impl stackable_versioned::flux_converter::test_utils::RoundtripTestData
for v1alpha1::ConnectionSpec
{
fn get_roundtrip_test_data() -> Vec<Self> {
crate::utils::yaml_from_str_singleton_map(indoc::indoc! {"
- host: s3.example.com
- host: s3.example.com
port: 1234
accessStyle: VirtualHosted
credentials:
secretClass: s3-credentials
region:
name: eu-west-1
tls: null
- host: s3.example.com
region:
name: us-east-1
tls:
verification:
none: {}
- host: s3.example.com
tls:
verification:
server:
caCert:
secretClass: s3-cert
"})
.expect("Failed to parse ConnectionSpec YAML")
}
}

#[cfg(test)]
mod tests {
use std::collections::BTreeMap;
Expand Down
8 changes: 8 additions & 0 deletions crates/stackable-operator/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ pub use self::{option::OptionExt, url::UrlExt};
pub(crate) fn format_full_controller_name(operator: &str, controller: &str) -> String {
format!("{operator}_{controller}")
}

pub fn yaml_from_str_singleton_map<'a, D>(input: &'a str) -> Result<D, serde_yaml::Error>
where
D: serde::Deserialize<'a>,
{
let deserializer = serde_yaml::Deserializer::from_str(input);
serde_yaml::with::singleton_map_recursive::deserialize(deserializer)
}
3 changes: 2 additions & 1 deletion crates/stackable-versioned-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ quote.workspace = true

[dev-dependencies]
# Only needed for doc tests / examples
stackable-versioned = { path = "../stackable-versioned", features = ["k8s"] }
stackable-versioned = { path = "../stackable-versioned", features = ["k8s", "flux-converter"] }

insta.workspace = true
prettyplease.workspace = true
Expand All @@ -53,4 +53,5 @@ serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
snafu.workspace = true
tracing.workspace = true
trybuild.workspace = true
Loading
Loading