Skip to content

feat: IntoValidated trait for config validation - #1329

Open
Maleware wants to merge 6 commits into
mainfrom
feat/IntoValidated
Open

Maleware wants to merge 6 commits into
mainfrom
feat/IntoValidated

Conversation

@Maleware

Copy link
Copy Markdown
Member

Description

Adds trait IntoValidated used in hdfs-operator for further usage across operators.

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Changes are OpenShift compatible
  • CRD changes approved
  • CRD documentation for all fields, following the style guide.
  • Integration tests passed (for non trivial changes)
  • Changes need to be "offline" compatible

Reviewer

  • Code contains useful comments
  • Code contains useful logging statements
  • (Integration-)Test cases added
  • Documentation added or updated. Follows the style guide.
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Feature Tracker has been updated
  • Proper release label has been added

@Maleware Maleware self-assigned this Nov 13, 2026
@Maleware Maleware moved this to Development: In Progress in Stackable Engineering Nov 13, 2026
@Maleware
Maleware marked this pull request as ready for review November 13, 2026 09:01
@Maleware Maleware moved this from Development: In Progress to Development: Waiting for Review in Stackable Engineering Nov 13, 2026
@Techassi
Techassi self-requested a review November 13, 2026 09:04
@Techassi Techassi moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Nov 13, 2026

@Techassi Techassi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of comments.

I would also argue that the same thing can be achieved with TryFrom, making this whole trait obsolete.

Comment on lines +22 to +23
/// Turns a role group's merged config into the validated config the build step works with.
trait IntoValidated {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that this trait is not tied to role(s) and/or role group(s) at all. This trait can be applied to any "turn this into a validated that".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done cc55450


/// Turns a role group's merged config into the validated config the build step works with.
trait IntoValidated {
/// `ValidatedConfig` of the `Config` to validate.

@Techassi Techassi Nov 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs mention ValidatedConfig, but this type is called Validated. Also, the doc comment should again be more generic, like "The validated type".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done cc55450

type ConfigError;

/// Consumes the merged config, as nothing needs it once it is validated.
fn validate(self) -> Result<Self::Validated, Self::ConfigError>;

@Techassi Techassi Nov 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trait is called IntoValidated and as such, this function should also be named into_validated

Suggested change
fn validate(self) -> Result<Self::Validated, Self::ConfigError>;
fn into_validated(self) -> Result<Self::Validated, Self::ConfigError>;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but we usually do something like

validated = RawStruct.validate();

I like how this reads and like to keep the function name. Better if we rename to trait Validation ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep this trait, and prefer validate over into_validated, the trait should be named Validate.

use crate::role_utils::{Role, RoleGroup};

/// Turns a role group's merged config into the validated config the build step works with.
trait IntoValidated {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trait is not public and thus cannot be used outside of this crate, which I guess is not the intention.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Maleware and others added 4 commits November 13, 2026 10:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development: In Review

Development

Successfully merging this pull request may close these issues.

2 participants