Skip to content

Commit 31cc9f5

Browse files
committed
Merge remote-tracking branch 'origin/main' into spike/generic-databases
2 parents 83907d7 + 380e4fb commit 31cc9f5

6 files changed

Lines changed: 65 additions & 48 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-operator/CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,23 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9+
- Implement `Deref` for `kvp::Key` to be more ergonomic to use ([#1182]).
910
- Add support for specifying a `clientAuthenticationMethod` for OIDC ([#1178]).
1011
This was originally done in [#1158] and had been reverted in [#1170].
11-
- Add generic database connection mechanism ([#1163])
12+
- Add generic database connection mechanism ([#1163]).
1213

1314
### Changed
1415

15-
- BREAKING: Change signature of `ContainerBuilder::add_env_vars` from `Vec<EnvVar>` to `IntoIterator<Item = EnvVar>` ([#1163])
16+
- BREAKING: Change signature of `ContainerBuilder::add_env_vars` from `Vec<EnvVar>` to `IntoIterator<Item = EnvVar>` ([#1163]).
17+
18+
### Removed
19+
20+
- BREAKING: Remove unused `add_prefix`, `try_add_prefix`, `set_name`, and `try_set_name` associated
21+
functions from `kvp::Key` to disallow mutable access to inner values ([#1182]).
1622

1723
[#1163]: https://github.com/stackabletech/operator-rs/pull/1163
1824
[#1178]: https://github.com/stackabletech/operator-rs/pull/1178
25+
[#1182]: https://github.com/stackabletech/operator-rs/pull/1182
1926

2027
## [0.108.0] - 2026-03-10
2128

crates/stackable-operator/src/kvp/key.rs

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ pub enum KeyError {
5858
/// [k8s-labels]: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
5959
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
6060
pub struct Key {
61+
/// A cached and formatted representation of a [`Key`] as a [`String`], which enables the
62+
/// implementation of [`Deref`], instead of constructing a new [`String`] every time the string
63+
/// representation of a key is needed.
64+
///
65+
/// ### Safety
66+
///
67+
/// This is safe to do (and cache it), because [`Key`] doesn't provide any **mutable** access
68+
/// to the inner values.
69+
string: String,
70+
6171
prefix: Option<KeyPrefix>,
6272
name: KeyName,
6373
}
@@ -80,12 +90,22 @@ impl FromStr for Key {
8090
_ => return NestedPrefixSnafu.fail(),
8191
};
8292

93+
let prefix = prefix
94+
.map(KeyPrefix::from_str)
95+
.transpose()
96+
.context(KeyPrefixSnafu)?;
97+
98+
let name = KeyName::from_str(name).context(KeyNameSnafu)?;
99+
100+
let string = match prefix {
101+
Some(ref prefix) => format!("{prefix}/{name}"),
102+
None => format!("{name}"),
103+
};
104+
83105
let key = Self {
84-
prefix: prefix
85-
.map(KeyPrefix::from_str)
86-
.transpose()
87-
.context(KeyPrefixSnafu)?,
88-
name: KeyName::from_str(name).context(KeyNameSnafu)?,
106+
string,
107+
prefix,
108+
name,
89109
};
90110

91111
Ok(key)
@@ -102,10 +122,15 @@ impl TryFrom<&str> for Key {
102122

103123
impl Display for Key {
104124
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105-
match &self.prefix {
106-
Some(prefix) => write!(f, "{}/{}", prefix, self.name),
107-
None => write!(f, "{}", self.name),
108-
}
125+
write!(f, "{key}", key = self.string)
126+
}
127+
}
128+
129+
impl Deref for Key {
130+
type Target = str;
131+
132+
fn deref(&self) -> &Self::Target {
133+
self.string.as_str()
109134
}
110135
}
111136

@@ -126,21 +151,6 @@ impl Key {
126151
self.prefix.as_ref()
127152
}
128153

129-
/// Adds or replaces the key prefix. This takes a parsed and validated
130-
/// [`KeyPrefix`] as a parameter. If instead you want to use a raw value,
131-
/// use the [`Key::try_add_prefix()`] function instead.
132-
pub fn add_prefix(&mut self, prefix: KeyPrefix) {
133-
self.prefix = Some(prefix)
134-
}
135-
136-
/// Adds or replaces the key prefix by parsing and validation raw input. If
137-
/// instead you already have a parsed and validated [`KeyPrefix`], use the
138-
/// [`Key::add_prefix()`] function instead.
139-
pub fn try_add_prefix(&mut self, prefix: impl AsRef<str>) -> Result<&mut Self, KeyError> {
140-
self.prefix = Some(KeyPrefix::from_str(prefix.as_ref()).context(KeyPrefixSnafu)?);
141-
Ok(self)
142-
}
143-
144154
/// Retrieves the key's name.
145155
///
146156
/// ```
@@ -156,21 +166,6 @@ impl Key {
156166
pub fn name(&self) -> &KeyName {
157167
&self.name
158168
}
159-
160-
/// Sets the key name. This takes a parsed and validated [`KeyName`] as a
161-
/// parameter. If instead you want to use a raw value, use the
162-
/// [`Key::try_set_name()`] function instead.
163-
pub fn set_name(&mut self, name: KeyName) {
164-
self.name = name
165-
}
166-
167-
/// Sets the key name by parsing and validation raw input. If instead you
168-
/// already have a parsed and validated [`KeyName`], use the
169-
/// [`Key::set_name()`] function instead.
170-
pub fn try_set_name(&mut self, name: impl AsRef<str>) -> Result<&mut Self, KeyError> {
171-
self.name = KeyName::from_str(name.as_ref()).context(KeyNameSnafu)?;
172-
Ok(self)
173-
}
174169
}
175170

176171
/// The error type for key prefix parsing/validation operations.

crates/stackable-telemetry/CHANGELOG.md

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

55
## [Unreleased]
66

7+
## [0.6.3] - 2026-03-30
8+
9+
### Fixed
10+
11+
- Only use ANSI escape sequences if stdout is a terminal/tty. Piping the output to a file will now
12+
result in plain text log messages ([#1183]).
13+
14+
[#1183]: https://github.com/stackabletech/operator-rs/pull/1183
15+
716
## [0.6.2] - 2026-03-09
817

918
### Fixed

crates/stackable-telemetry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stackable-telemetry"
3-
version = "0.6.2"
3+
version = "0.6.3"
44
authors.workspace = true
55
license.workspace = true
66
edition.workspace = true

crates/stackable-telemetry/src/tracing/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//!
77
//! To get started, see [`Tracing`].
88
9-
use std::{ops::Not, path::PathBuf};
9+
use std::{io::IsTerminal, ops::Not, path::PathBuf};
1010

1111
use opentelemetry::trace::TracerProvider;
1212
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
@@ -432,15 +432,21 @@ impl Tracing {
432432

433433
// NOTE (@NickLarsenNZ): There is no elegant way to build the layer depending on formats because the types
434434
// returned from each subscriber "modifier" function is different (sometimes with different generics).
435+
// tracing-subscriber does not auto-detect whether stdout is a terminal
436+
// (https://github.com/tokio-rs/tracing/issues/1160), so we check explicitly.
437+
let use_ansi = std::io::stdout().is_terminal();
438+
435439
match log_format {
436440
Format::Plain => {
437-
let console_output_layer =
438-
tracing_subscriber::fmt::layer().with_filter(env_filter_layer);
441+
let console_output_layer = tracing_subscriber::fmt::layer()
442+
.with_ansi(use_ansi)
443+
.with_filter(env_filter_layer);
439444
layers.push(console_output_layer.boxed());
440445
}
441446
Format::Json => {
442447
let console_output_layer = tracing_subscriber::fmt::layer()
443448
.json()
449+
.with_ansi(use_ansi)
444450
.with_filter(env_filter_layer);
445451
layers.push(console_output_layer.boxed());
446452
}

0 commit comments

Comments
 (0)