Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom stabilizer support #374

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

msuozzo
Copy link
Member

@msuozzo msuozzo commented Mar 6, 2025

No description provided.

@msuozzo msuozzo requested a review from wbxyz March 6, 2025 19:58
@msuozzo msuozzo force-pushed the push-mtrvoywukvox branch 3 times, most recently from 962315c to 9d06207 Compare March 6, 2025 20:26
@msuozzo msuozzo force-pushed the push-mtrvoywukvox branch from 9d06207 to 7d524e8 Compare March 6, 2025 21:14
Comment on lines +44 to +34
func count(bools ...bool) int {
var c int
for _, b := range bools {
if b {
c++
}
}
return c
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: Want to re-use this in the StrategyOneOf?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add some docstrings? This will be a common code path to see external contributions, would be nice to make it user friendly.

}

type ReplacePattern struct {
Path string `yaml:"path"`
Copy link
Member

Choose a reason for hiding this comment

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

Offline discussion, we might want this path to be more than just path.Match, potentially a full regex pattern?

If so, should we cache the compiled regex? Maybe store it in a private member of ReplacePattern?

if match, err := path.Match(rp.Path, te.Name); err != nil || !match {
return
}
re := regexp.MustCompile(rp.Pattern)
Copy link
Member

Choose a reason for hiding this comment

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

nit: Should this pattern be cached? Especially if the path becomes a pattern, this could be called many times.

Copy link
Member

Choose a reason for hiding this comment

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

Add a test for directories?

ReplacePattern *ReplacePattern `yaml:"replace_pattern"`
ExcludePath *ExcludePath `yaml:"exclude_path"`
Reason string `yaml:"reason"`
FormatStr string `yaml:"format"`
Copy link
Member

Choose a reason for hiding this comment

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

Can we drop the FormatStr here? The thing invoking CreateCustomStabilizers will provide the format that's actually going to be stabilized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants