-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: main
Are you sure you want to change the base?
Conversation
962315c
to
9d06207
Compare
9d06207
to
7d524e8
Compare
func count(bools ...bool) int { | ||
var c int | ||
for _, b := range bools { | ||
if b { | ||
c++ | ||
} | ||
} | ||
return c | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
pkg/archive/custom_test.go
Outdated
There was a problem hiding this comment.
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?
pkg/archive/custom.go
Outdated
ReplacePattern *ReplacePattern `yaml:"replace_pattern"` | ||
ExcludePath *ExcludePath `yaml:"exclude_path"` | ||
Reason string `yaml:"reason"` | ||
FormatStr string `yaml:"format"` |
There was a problem hiding this comment.
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
No description provided.