From e7026952568a6017bf0d16c2980d7eb88c2f8b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Thu, 18 Jan 2024 18:09:19 +0100 Subject: [PATCH 1/2] Add Logging::for_container helper --- src/product_logging/spec.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/product_logging/spec.rs b/src/product_logging/spec.rs index 071e31d9..5e9c1df8 100644 --- a/src/product_logging/spec.rs +++ b/src/product_logging/spec.rs @@ -1,7 +1,6 @@ //! Logging structure used within Custom Resource Definitions -use std::collections::BTreeMap; -use std::fmt::Display; +use std::{borrow::Cow, collections::BTreeMap, fmt::Display}; use crate::config::{ fragment::{self, Fragment, FromFragment}, @@ -81,6 +80,19 @@ where pub containers: BTreeMap, } +impl Logging +where + T: Clone + Display + Ord, +{ + /// Get the logging configuration for `container`, falling back to the default. + pub fn for_container(&self, container: &T) -> Cow { + self.containers + .get(container) + .map(Cow::Borrowed) + .unwrap_or_default() + } +} + /// Log configuration of the container #[derive(Clone, Debug, Default, Eq, Fragment, JsonSchema, PartialEq)] #[fragment(path_overrides(fragment = "crate::config::fragment"))] From 19c8665938a7fc2f2aa36cb215c5645402bb377b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Natalie=20Klestrup=20R=C3=B6ijezon?= Date: Thu, 18 Jan 2024 18:11:36 +0100 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0041d85..dbed9275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Added `Option::as_ref_or_else` to `utils` ([#717]). - Added `ListenerOperatorVolumeSourceBuilder::build_pvc` ([#719]). +- Added `Logging::for_container` ([#721]). ### Changed @@ -16,6 +17,7 @@ All notable changes to this project will be documented in this file. [#717]: https://github.com/stackabletech/operator-rs/pull/717 [#719]: https://github.com/stackabletech/operator-rs/pull/719 +[#721]: https://github.com/stackabletech/operator-rs/pull/721 ## [0.61.0] - 2024-01-15