Skip to content

Commit

Permalink
Merge branch 'main' into refactor/add-host-struct
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer authored Sep 19, 2024
2 parents 152ee94 + 8a8235e commit 064cc13
Show file tree
Hide file tree
Showing 15 changed files with 263 additions and 187 deletions.
324 changes: 166 additions & 158 deletions Cargo.lock

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ product-config = { git = "https://github.com/stackabletech/product-config.git",

axum = "0.7.5"
chrono = { version = "0.4.38", default-features = false }
clap = { version = "4.5.13", features = ["derive", "cargo", "env"] }
const_format = "0.2.32"
clap = { version = "4.5.17", features = ["derive", "cargo", "env"] }
const_format = "0.2.33"
const-oid = "0.9.6"
convert_case = "0.6.0"
darling = "0.20.10"
delegate = "0.12.0"
delegate = "0.13.0"
derivative = "2.2.0"
dockerfile-parser = "0.8.0"
ecdsa = { version = "0.16.9", features = ["digest", "pem"] }
either = "1.13.0"
futures = "0.3.30"
futures-util = "0.3.30"
hyper = { version = "1.4.1", features = ["full"] }
hyper-util = "0.1.6"
hyper-util = "0.1.8"
itertools = "0.13.0"
json-patch = "2.0.0"
k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_30"] }
# We use rustls instead of openssl for easier portablitly, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
kube = { version = "0.93.1", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "rustls-tls"] }
k8s-openapi = { version = "0.23.0", default-features = false, features = ["schemars", "v1_31"] }
# We use rustls instead of openssl for easier portability, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
kube = { version = "0.95.0", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "rustls-tls"] }
opentelemetry = "0.23.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] }
opentelemetry-appender-tracing = "0.4.0"
Expand All @@ -41,7 +41,7 @@ opentelemetry-semantic-conventions = "0.15.0"
p256 = { version = "0.13.2", features = ["ecdsa"] }
pin-project = "1.1.5"
proc-macro2 = "1.0.86"
quote = "1.0.36"
quote = "1.0.37"
rand = "0.8.5"
rand_core = "0.6.4"
regex = "1.10.6"
Expand All @@ -50,21 +50,21 @@ rstest = "0.22.0"
rstest_reuse = "0.7.0"
schemars = { version = "0.8.21", features = ["url"] }
semver = "1.0.23"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.122"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
serde_yaml = "0.9.34" # This is the last available version, see https://github.com/dtolnay/serde-yaml/releases/tag/0.9.34 for details
sha2 = { version = "0.10.8", features = ["oid"] }
signature = "2.2.0"
snafu = "0.8.4"
stackable-operator-derive = { path = "stackable-operator-derive" }
strum = { version = "0.26.3", features = ["derive"] }
syn = "2.0.77"
tempfile = "3.11.0"
tempfile = "3.12.0"
time = { version = "0.3.36" }
tokio = { version = "1.39.2", features = ["macros", "rt-multi-thread", "fs"] }
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread", "fs"] }
tokio-rustls = "0.26.0"
tokio-test = "0.4.4"
tower = "0.4.13"
tower = { version = "0.5.1", features = ["util"] }
tower-http = { version = "0.5.2", features = ["trace"] }
tracing = "0.1.40"
tracing-appender = "0.2.3"
Expand Down
4 changes: 4 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [0.75.0] - 2024-09-19

### Added

- BREAKING: Add `HostName` type and use it within LDAP and OIDC AuthenticationClass as well as S3Connection ([#863]).
Expand All @@ -30,6 +32,7 @@ All notable changes to this project will be documented in this file.

- BREAKING: `validation` module now uses typed errors ([#851]).
- Set `checkIncrement` to 5 seconds in Logback config ([#853]).
- Bump Rust dependencies and enable Kubernetes 1.31 (via `kube` 0.95.0) ([#867]).

### Fixed

Expand All @@ -43,6 +46,7 @@ All notable changes to this project will be documented in this file.
[#855]: https://github.com/stackabletech/operator-rs/pull/855
[#858]: https://github.com/stackabletech/operator-rs/pull/858
[#862]: https://github.com/stackabletech/operator-rs/pull/862
[#867]: https://github.com/stackabletech/operator-rs/pull/867

## [0.74.0] - 2024-08-22

Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "stackable-operator"
description = "Stackable Operator Framework"
version = "0.74.0"
version = "0.75.0"
authors.workspace = true
license.workspace = true
edition.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions crates/stackable-operator/src/builder/pod/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl ContainerBuilder {
name,
EnvVarSource {
secret_key_ref: Some(SecretKeySelector {
name: Some(secret_name.into()),
name: secret_name.into(),
key: secret_key.into(),
..Default::default()
}),
Expand All @@ -145,7 +145,7 @@ impl ContainerBuilder {
name,
EnvVarSource {
config_map_key_ref: Some(ConfigMapKeySelector {
name: Some(config_map_name.into()),
name: config_map_name.into(),
key: config_map_key.into(),
..Default::default()
}),
Expand Down Expand Up @@ -400,10 +400,10 @@ mod tests {
matches!(container.env.as_ref().unwrap().first(), Some(EnvVar {name, value: Some(value), ..}) if name == "foo" && value == "bar")
);
assert!(
matches!(container.env.as_ref().unwrap().get(1), Some(EnvVar {name, value_from: Some(EnvVarSource {config_map_key_ref: Some(ConfigMapKeySelector {name: Some(config_map_name), key: config_map_key, ..}), ..}), ..}) if name == "envFromConfigMap" && config_map_name == "my-configmap" && config_map_key == "my-key")
matches!(container.env.as_ref().unwrap().get(1), Some(EnvVar {name, value_from: Some(EnvVarSource {config_map_key_ref: Some(ConfigMapKeySelector {name: config_map_name, key: config_map_key, ..}), ..}), ..}) if name == "envFromConfigMap" && config_map_name == "my-configmap" && config_map_key == "my-key")
);
assert!(
matches!(container.env.as_ref().unwrap().get(2), Some(EnvVar {name, value_from: Some(EnvVarSource {secret_key_ref: Some(SecretKeySelector {name: Some(secret_name), key: secret_key, ..}), ..}), ..}) if name == "envFromSecret" && secret_name == "my-secret" && secret_key == "my-key")
matches!(container.env.as_ref().unwrap().get(2), Some(EnvVar {name, value_from: Some(EnvVarSource {secret_key_ref: Some(SecretKeySelector {name: secret_name, key: secret_key, ..}), ..}), ..}) if name == "envFromSecret" && secret_name == "my-secret" && secret_key == "my-key")
);
assert_eq!(container.volume_mounts.as_ref().unwrap().len(), 1);
assert!(
Expand Down
7 changes: 4 additions & 3 deletions crates/stackable-operator/src/builder/pod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl PodBuilder {
) -> &mut Self {
self.image_pull_secrets
.get_or_insert_with(Vec::new)
.extend(secrets.map(|s| LocalObjectReference { name: Some(s) }));
.extend(secrets.map(|name| LocalObjectReference { name }));
self
}

Expand Down Expand Up @@ -699,7 +699,8 @@ mod tests {
pod_spec.volumes.as_ref().and_then(|volumes| volumes
.first()
.as_ref()
.and_then(|volume| volume.config_map.as_ref()?.name.clone())),
.and_then(|volume| volume.config_map.as_ref())
.map(|cm| cm.name.clone())),
Some("configmap".to_string())
);
assert_eq!(pod_spec.termination_grace_period_seconds, Some(42));
Expand All @@ -715,7 +716,7 @@ mod tests {
assert_eq!(
pod.spec.unwrap().image_pull_secrets.unwrap(),
vec![LocalObjectReference {
name: Some("company-registry-secret".to_string())
name: "company-registry-secret".to_string()
}]
);
}
Expand Down
4 changes: 3 additions & 1 deletion crates/stackable-operator/src/builder/pod/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ mod tests {
// Because we support older Kubernetes versions as well, we can
// not use it for now, as we would not work on older Kubernetes
// clusters.
app_armor_profile: None
app_armor_profile: None,
// This attribute is supported starting with Kubernetes 1.31.
supplemental_groups_policy: None,
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/stackable-operator/src/builder/pod/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl VolumeBuilder {

pub fn with_config_map(&mut self, name: impl Into<String>) -> &mut Self {
self.volume_source = VolumeSource::ConfigMap(ConfigMapVolumeSource {
name: Some(name.into()),
name: name.into(),
..ConfigMapVolumeSource::default()
});
self
Expand Down Expand Up @@ -565,7 +565,7 @@ mod tests {

assert_eq!(vol.name, "name".to_string());
assert_eq!(
vol.config_map.and_then(|cm| cm.name),
vol.config_map.map(|cm| cm.name),
Some("configmap".to_string())
);

Expand Down
8 changes: 4 additions & 4 deletions crates/stackable-operator/src/commons/authentication/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl AuthenticationProvider {
value_from: Some(EnvVarSource {
secret_key_ref: Some(SecretKeySelector {
key: CLIENT_ID_SECRET_KEY.to_string(),
name: Some(secret_name.clone()),
name: secret_name.clone(),
..Default::default()
}),
..Default::default()
Expand All @@ -199,7 +199,7 @@ impl AuthenticationProvider {
value_from: Some(EnvVarSource {
secret_key_ref: Some(SecretKeySelector {
key: CLIENT_SECRET_SECRET_KEY.to_string(),
name: Some(secret_name),
name: secret_name,
..Default::default()
}),
..Default::default()
Expand Down Expand Up @@ -366,12 +366,12 @@ mod test {
vec![
SecretKeySelector {
key: CLIENT_ID_SECRET_KEY.to_string(),
name: Some(secret_name.to_string()),
name: secret_name.to_string(),
optional: None,
},
SecretKeySelector {
key: CLIENT_SECRET_SECRET_KEY.to_string(),
name: Some(secret_name.to_string()),
name: secret_name.to_string(),
optional: None,
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ mod tests {
app_version_label: "1.4.1-latest-and-greatest".to_string(),
product_version: "1.4.1".to_string(),
image_pull_policy: "Always".to_string(),
pull_secrets: Some(vec![LocalObjectReference{name: Some("myPullSecrets1".to_string())}, LocalObjectReference{name: Some("myPullSecrets2".to_string())}]),
pull_secrets: Some(vec![LocalObjectReference{name: "myPullSecrets1".to_string()}, LocalObjectReference{name: "myPullSecrets2".to_string()}]),
}
)]
fn test_correct_resolved_image(
Expand Down
29 changes: 29 additions & 0 deletions crates/stackable-versioned-macros/src/attrs/common/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ impl ItemAttributes {
errors.handle(self.validate_action_combinations(item_ident, item_type));
errors.handle(self.validate_action_order(item_ident, item_type));
errors.handle(self.validate_item_name(item_ident, item_type));
errors.handle(self.validate_changed_item_name(item_type));
errors.handle(self.validate_item_attributes(item_attrs));

// TODO (@Techassi): Add hint if a field or variant is added in the
Expand Down Expand Up @@ -294,6 +295,34 @@ impl ItemAttributes {
}
Ok(())
}

/// This associated function is called by the top-level validation function
/// and validates that parameters provided to the `changed` actions are
/// valid.
fn validate_changed_item_name(&self, item_type: &ItemType) -> Result<(), Error> {
let prefix = match item_type {
ItemType::Field => DEPRECATED_FIELD_PREFIX,
ItemType::Variant => DEPRECATED_VARIANT_PREFIX,
};

let mut errors = Error::accumulator();

// This ensures that `from_name` doesn't include the deprecation prefix.
for change in &self.changes {
if let Some(from_name) = change.from_name.as_ref() {
if from_name.starts_with(prefix) {
errors.push(
Error::custom(format!(
"the previous {item_type} name must not start with the deprecation prefix"
))
.with_span(&from_name.span()),
);
}
}
}

errors.finish()
}
}

// TODO (@Techassi): Add validation for when default_fn is "" (empty path).
Expand Down
3 changes: 3 additions & 0 deletions crates/stackable-versioned-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,11 @@ pub struct FooSpec {
bar: usize,
baz: bool,
}
# fn main() {
let merged_crd = Foo::merged_crd("v1").unwrap();
println!("{}", serde_yaml::to_string(&merged_crd).unwrap());
# }
```
"#
)]
Expand Down
16 changes: 16 additions & 0 deletions crates/stackable-versioned-macros/tests/default/fail/changed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use stackable_versioned_macros::versioned;

fn main() {
#[versioned(
version(name = "v1alpha1"),
version(name = "v1beta1"),
version(name = "v1")
)]
struct Foo {
#[versioned(
changed(since = "v1beta1", from_name = "deprecated_bar"),
changed(since = "v1", from_name = "deprecated_baz")
)]
bar: usize,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: the previous field name must not start with the deprecation prefix
--> tests/default/fail/changed.rs:11:52
|
11 | changed(since = "v1beta1", from_name = "deprecated_bar"),
| ^^^^^^^^^^^^^^^^

error: the previous field name must not start with the deprecation prefix
--> tests/default/fail/changed.rs:12:47
|
12 | changed(since = "v1", from_name = "deprecated_baz")
| ^^^^^^^^^^^^^^^^
2 changes: 2 additions & 0 deletions crates/stackable-versioned/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

### Added

- Add `from_name` parameter validation ([#865]).
- Add new `from_type` parameter to `changed()` action ([#844]).
- Pass through container and item attributes (including doc-comments). Add
attribute for version specific docs ([#847]).
Expand Down Expand Up @@ -33,6 +34,7 @@ All notable changes to this project will be documented in this file.
[#857]: https://github.com/stackabletech/operator-rs/pull/857
[#859]: https://github.com/stackabletech/operator-rs/pull/859
[#860]: https://github.com/stackabletech/operator-rs/pull/860
[#865]: https://github.com/stackabletech/operator-rs/pull/865

## [0.1.1] - 2024-07-10

Expand Down

0 comments on commit 064cc13

Please sign in to comment.