Skip to content

Commit 13c23f8

Browse files
committed
main merge, fix conflicts
2 parents 0e7e0a1 + ca54ab7 commit 13c23f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1793
-263
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
CARGO_TERM_COLOR: always
1818
CARGO_INCREMENTAL: '0'
1919
CARGO_PROFILE_DEV_DEBUG: '0'
20-
RUST_TOOLCHAIN_VERSION: "1.71.0"
20+
RUST_TOOLCHAIN_VERSION: "1.75.0"
2121
RUSTFLAGS: "-D warnings"
2222
RUSTDOCFLAGS: "-D warnings"
2323
RUST_LOG: "info"

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,71 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## Added
8+
9+
- Add `stackable_webhook` crate which provides utilities to create webhooks with TLS termination ([#730]).
10+
11+
[#730]: https://github.com/stackabletech/operator-rs/pull/730
12+
13+
## Changed
14+
15+
- Remove `resources` key from `DynamicValues` struct ([#734]).
16+
17+
## Fixed
18+
19+
- Fixed incorrect time calculation ([#735]).
20+
21+
[#734]: https://github.com/stackabletech/operator-rs/pull/734
22+
[#735]: https://github.com/stackabletech/operator-rs/pull/735
23+
24+
## [0.64.0] - 2024-01-31
25+
26+
### Added
27+
28+
- Derive `Hash` and `Ord` instances for `AuthenticationClassProvider`,
29+
so that duplicates can be detected ([#731]).
30+
31+
[#731]: https://github.com/stackabletech/operator-rs/pull/731
32+
33+
## [0.63.0] - 2024-01-26
34+
35+
### Added
36+
37+
- Add Serde `Deserialize` and `Serialize` support for `CpuQuantity` and `MemoryQuantity` ([#724]).
38+
- Add `DynamicValues` struct to work with operator `values.yaml` files during runtime ([#723]).
39+
40+
[#723]: https://github.com/stackabletech/operator-rs/pull/723
41+
[#724]: https://github.com/stackabletech/operator-rs/pull/724
42+
43+
### Changed
44+
45+
- Change Deref target of `KeyPrefix` and `KeyName` from `String` to `str` ([#725]).
46+
- Add Stackable vendor label `stackable.tech/vendor: Stackable` to recommended labels ([#728]).
47+
48+
[#725]: https://github.com/stackabletech/operator-rs/pull/725
49+
[#728]: https://github.com/stackabletech/operator-rs/pull/728
50+
51+
## [0.62.0] - 2024-01-19
52+
53+
### Added
54+
55+
- Added `Option::as_ref_or_else` to `utils` ([#717]).
56+
- Add `iter()` methods to `KeyValuePairs<T>`, and delegate iter() for `Labels`, and `Annotations` ([#720]).
57+
- Implement `IntoIterator` for `KeyValuePairs<T>`, `Labels` and `Annotations` ([#720]).
58+
- Added `ListenerOperatorVolumeSourceBuilder::build_pvc` ([#719]).
59+
- Added `Logging::for_container` ([#721]).
60+
61+
### Changed
62+
63+
- Split `utils` into submodules ([#717]).
64+
- Bump rust to 1.75.0 ([#720]).
65+
- Renamed `ListenerOperatorVolumeSourceBuilder::build` to `::build_ephemeral` ([#719]).
66+
67+
[#717]: https://github.com/stackabletech/operator-rs/pull/717
68+
[#720]: https://github.com/stackabletech/operator-rs/pull/720
69+
[#719]: https://github.com/stackabletech/operator-rs/pull/719
70+
[#721]: https://github.com/stackabletech/operator-rs/pull/721
71+
772
## [0.61.0] - 2024-01-15
873

974
### Added

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "0.61.0"
2+
version = "0.64.0"
33
authors = ["Stackable GmbH <info@stackable.de>"]
44
license = "Apache-2.0"
55
edition = "2021"
@@ -27,12 +27,12 @@ dockerfile-parser = "0.8.0"
2727
either = "1.9.0"
2828
futures = "0.3.28"
2929
json-patch = "1.0.0"
30-
k8s-openapi = { version = "0.20.0", default-features = false, features = [
30+
k8s-openapi = { version = "0.21.0", default-features = false, features = [
3131
"schemars",
3232
"v1_28",
3333
] }
3434
# 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
35-
kube = { version = "0.87.1", default-features = false, features = [
35+
kube = { version = "0.88.1", default-features = false, features = [
3636
"client",
3737
"jsonpatch",
3838
"runtime",
@@ -51,9 +51,9 @@ semver = "1.0"
5151
serde = { version = "1.0.184", features = ["derive"] }
5252
serde_json = "1.0.104"
5353
serde_yaml = "0.9.25"
54-
snafu = "0.7.5"
54+
snafu = "0.8.0"
5555
stackable-operator-derive = { path = "stackable-operator-derive" }
56-
strum = { version = "0.25.0", features = ["derive"] }
56+
strum = { version = "0.26.1", features = ["derive"] }
5757
thiserror = "1.0.44"
5858
time = { version = "0.3.29", optional = true }
5959
tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] }
@@ -67,4 +67,4 @@ rstest = "0.18.1"
6767
tempfile = "3.7.1"
6868

6969
[workspace]
70-
members = ["stackable-operator-derive"]
70+
members = ["stackable-operator-derive", "stackable-webhook"]

fixtures/helm/input-additional.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Partly taken from https://github.com/stackabletech/zookeeper-operator/blob/main/deploy/helm/zookeeper-operator/values.yaml
2+
---
3+
image:
4+
repository: docker.stackable.tech/stackable/zookeeper-operator
5+
pullPolicy: IfNotPresent
6+
pullSecrets: []
7+
nameOverride: ''
8+
fullnameOverride: ''
9+
serviceAccount:
10+
create: true
11+
annotations: {}
12+
name: ''
13+
labels:
14+
stackable.tech/vendor: Stackable
15+
stackable.tech/managed-by: stackablectl
16+
podAnnotations: {}
17+
podSecurityContext: {}
18+
nodeSelector: {}
19+
tolerations: []
20+
affinity: {}

fixtures/helm/input-required.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Partly taken from https://github.com/stackabletech/zookeeper-operator/blob/main/deploy/helm/zookeeper-operator/values.yaml
2+
---
3+
image:
4+
repository: docker.stackable.tech/stackable/zookeeper-operator
5+
pullPolicy: IfNotPresent
6+
pullSecrets: []
7+
nameOverride: ''
8+
fullnameOverride: ''
9+
serviceAccount:
10+
create: true
11+
annotations: {}
12+
name: ''
13+
labels:
14+
stackable.tech/vendor: Stackable
15+
stackable.tech/managed-by: stackablectl

fixtures/helm/output.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
image:
3+
repository: docker.stackable.tech/stackable/zookeeper-operator
4+
pullPolicy: IfNotPresent
5+
pullSecrets: []
6+
nameOverride: ''
7+
fullnameOverride: ''
8+
serviceAccount:
9+
create: true
10+
annotations: {}
11+
name: ''
12+
labels:
13+
stackable.tech/demo: logging
14+
stackable.tech/managed-by: stackablectl
15+
stackable.tech/vendor: Stackable

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.71.0"
2+
channel = "1.75.0"

src/builder/meta.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ mod tests {
343343
assert_eq!(meta.name, Some("foo".to_string()));
344344
assert_eq!(meta.owner_references.as_ref().unwrap().len(), 1);
345345
assert!(
346-
matches!(meta.owner_references.unwrap().get(0), Some(OwnerReference { uid, ..}) if uid == "uid")
346+
matches!(meta.owner_references.unwrap().first(), Some(OwnerReference { uid, ..}) if uid == "uid")
347347
);
348348
assert_eq!(meta.annotations.as_ref().unwrap().len(), 1);
349349
assert_eq!(

src/builder/pod/container.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ mod tests {
392392

393393
assert_eq!(container.name, "testcontainer");
394394
assert!(
395-
matches!(container.env.as_ref().unwrap().get(0), Some(EnvVar {name, value: Some(value), ..}) if name == "foo" && value == "bar")
395+
matches!(container.env.as_ref().unwrap().first(), Some(EnvVar {name, value: Some(value), ..}) if name == "foo" && value == "bar")
396396
);
397397
assert!(
398398
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")
@@ -402,7 +402,7 @@ mod tests {
402402
);
403403
assert_eq!(container.volume_mounts.as_ref().unwrap().len(), 1);
404404
assert!(
405-
matches!(container.volume_mounts.as_ref().unwrap().get(0), Some(VolumeMount {mount_path, name, ..}) if mount_path == "/mount" && name == "configmap")
405+
matches!(container.volume_mounts.as_ref().unwrap().first(), Some(VolumeMount {mount_path, name, ..}) if mount_path == "/mount" && name == "configmap")
406406
);
407407
assert_eq!(container.ports.as_ref().unwrap().len(), 2);
408408
assert_eq!(

src/builder/pod/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl PodBuilder {
351351
) -> Result<&mut Self> {
352352
let listener_reference = ListenerReference::ListenerClass(listener_class.to_string());
353353
let volume = ListenerOperatorVolumeSourceBuilder::new(&listener_reference)
354-
.build()
354+
.build_ephemeral()
355355
.context(ListenerVolumeSnafu { name: volume_name })?;
356356

357357
self.add_volume(Volume {
@@ -440,7 +440,7 @@ impl PodBuilder {
440440
) -> Result<&mut Self> {
441441
let listener_reference = ListenerReference::ListenerName(listener_name.to_string());
442442
let volume = ListenerOperatorVolumeSourceBuilder::new(&listener_reference)
443-
.build()
443+
.build_ephemeral()
444444
.context(ListenerVolumeSnafu { name: volume_name })?;
445445

446446
self.add_volume(Volume {
@@ -691,13 +691,13 @@ mod tests {
691691
pod_spec
692692
.init_containers
693693
.as_ref()
694-
.and_then(|containers| containers.get(0).as_ref().map(|c| c.name.clone())),
694+
.and_then(|containers| containers.first().as_ref().map(|c| c.name.clone())),
695695
Some("init-containername".to_string())
696696
);
697697

698698
assert_eq!(
699699
pod_spec.volumes.as_ref().and_then(|volumes| volumes
700-
.get(0)
700+
.first()
701701
.as_ref()
702702
.and_then(|volume| volume.config_map.as_ref()?.name.clone())),
703703
Some("configmap".to_string())

src/builder/pod/volume.rs

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use k8s_openapi::{
22
api::core::v1::{
33
CSIVolumeSource, ConfigMapVolumeSource, DownwardAPIVolumeSource, EmptyDirVolumeSource,
4-
EphemeralVolumeSource, HostPathVolumeSource, PersistentVolumeClaimSpec,
5-
PersistentVolumeClaimTemplate, PersistentVolumeClaimVolumeSource, ProjectedVolumeSource,
6-
ResourceRequirements, SecretVolumeSource, Volume, VolumeMount,
4+
EphemeralVolumeSource, HostPathVolumeSource, PersistentVolumeClaim,
5+
PersistentVolumeClaimSpec, PersistentVolumeClaimTemplate,
6+
PersistentVolumeClaimVolumeSource, ProjectedVolumeSource, ResourceRequirements,
7+
SecretVolumeSource, Volume, VolumeMount,
78
},
89
apimachinery::pkg::api::resource::Quantity,
910
};
@@ -461,8 +462,27 @@ impl ListenerOperatorVolumeSourceBuilder {
461462
}
462463
}
463464

464-
/// Build an [`EphemeralVolumeSource`] from the builder
465+
fn build_spec(&self) -> PersistentVolumeClaimSpec {
466+
PersistentVolumeClaimSpec {
467+
storage_class_name: Some("listeners.stackable.tech".to_string()),
468+
resources: Some(ResourceRequirements {
469+
requests: Some([("storage".to_string(), Quantity("1".to_string()))].into()),
470+
..ResourceRequirements::default()
471+
}),
472+
access_modes: Some(vec!["ReadWriteMany".to_string()]),
473+
..PersistentVolumeClaimSpec::default()
474+
}
475+
}
476+
477+
#[deprecated(note = "renamed to `build_ephemeral`", since = "0.61.1")]
465478
pub fn build(&self) -> Result<EphemeralVolumeSource, ListenerOperatorVolumeSourceBuilderError> {
479+
self.build_ephemeral()
480+
}
481+
482+
/// Build an [`EphemeralVolumeSource`] from the builder.
483+
pub fn build_ephemeral(
484+
&self,
485+
) -> Result<EphemeralVolumeSource, ListenerOperatorVolumeSourceBuilderError> {
466486
let listener_reference_annotation = self
467487
.listener_reference
468488
.to_annotation()
@@ -475,18 +495,30 @@ impl ListenerOperatorVolumeSourceBuilder {
475495
.with_annotation(listener_reference_annotation)
476496
.build(),
477497
),
478-
spec: PersistentVolumeClaimSpec {
479-
storage_class_name: Some("listeners.stackable.tech".to_string()),
480-
resources: Some(ResourceRequirements {
481-
requests: Some([("storage".to_string(), Quantity("1".to_string()))].into()),
482-
..ResourceRequirements::default()
483-
}),
484-
access_modes: Some(vec!["ReadWriteMany".to_string()]),
485-
..PersistentVolumeClaimSpec::default()
486-
},
498+
spec: self.build_spec(),
487499
}),
488500
})
489501
}
502+
503+
/// Build a [`PersistentVolumeClaim`] from the builder.
504+
pub fn build_pvc(
505+
&self,
506+
name: impl Into<String>,
507+
) -> Result<PersistentVolumeClaim, ListenerOperatorVolumeSourceBuilderError> {
508+
let listener_reference_annotation = self
509+
.listener_reference
510+
.to_annotation()
511+
.context(ListenerReferenceAnnotationSnafu)?;
512+
513+
Ok(PersistentVolumeClaim {
514+
metadata: ObjectMetaBuilder::new()
515+
.name(name)
516+
.with_annotation(listener_reference_annotation)
517+
.build(),
518+
spec: Some(self.build_spec()),
519+
..Default::default()
520+
})
521+
}
490522
}
491523

492524
#[cfg(test)]
@@ -556,7 +588,7 @@ mod tests {
556588
"public".into(),
557589
));
558590

559-
let volume_source = builder.build().unwrap();
591+
let volume_source = builder.build_ephemeral().unwrap();
560592

561593
let volume_claim_template = volume_source.volume_claim_template;
562594
let annotations = volume_claim_template

src/commons/authentication/ldap.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ pub enum Error {
3131
AddLdapTlsClientDetailsVolumes { source: TlsClientDetailsError },
3232
}
3333

34-
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
34+
#[derive(
35+
Clone, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
36+
)]
3537
#[serde(rename_all = "camelCase")]
3638
pub struct AuthenticationProvider {
3739
/// Hostname of the LDAP server, for example: `my.ldap.server`.
@@ -155,7 +157,9 @@ impl AuthenticationProvider {
155157
}
156158
}
157159

158-
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
160+
#[derive(
161+
Clone, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
162+
)]
159163
#[serde(rename_all = "camelCase")]
160164
pub struct FieldNames {
161165
/// The name of the username field

src/commons/authentication/mod.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ pub(crate) const SECRET_BASE_PATH: &str = "/stackable/secrets";
2020
/// Multiple different authentication providers are supported.
2121
/// Learn more in the [authentication concept documentation](DOCS_BASE_URL_PLACEHOLDER/concepts/authentication) and the
2222
/// [Authentication with OpenLDAP tutorial](DOCS_BASE_URL_PLACEHOLDER/tutorials/authentication_with_openldap).
23-
#[derive(Clone, CustomResource, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
23+
#[derive(
24+
Clone,
25+
CustomResource,
26+
Debug,
27+
Deserialize,
28+
Eq,
29+
Hash,
30+
JsonSchema,
31+
Ord,
32+
PartialEq,
33+
PartialOrd,
34+
Serialize,
35+
)]
2436
#[kube(
2537
group = "authentication.stackable.tech",
2638
version = "v1alpha1",
@@ -38,7 +50,9 @@ pub struct AuthenticationClassSpec {
3850
pub provider: AuthenticationClassProvider,
3951
}
4052

41-
#[derive(Clone, Debug, Deserialize, Display, Eq, JsonSchema, PartialEq, Serialize)]
53+
#[derive(
54+
Clone, Debug, Deserialize, Display, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize,
55+
)]
4256
#[serde(rename_all = "camelCase")]
4357
#[allow(clippy::large_enum_variant)]
4458
pub enum AuthenticationClassProvider {

0 commit comments

Comments
 (0)