feat(dev): add --watch-interval flag to dev validate and dev test#171
feat(dev): add --watch-interval flag to dev validate and dev test#171
Conversation
Adds a configurable `--watch-interval` / `-i` duration flag (default: 5s) to both `dev validate` and `dev test`. This prevents poll overlap when a validation run takes longer than the hardcoded 5s interval. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @pbrissaud's task in 1m 6s —— View job PR Review:
|
| devValidateCmd.Flags().StringVar(&devValidateDir, "dir", "", "Path to challenge directory (default: auto-detect)") | ||
| devValidateCmd.Flags().BoolVarP(&devValidateWatch, "watch", "w", false, "Continuously re-run validations every 5 seconds") | ||
| devValidateCmd.Flags().BoolVarP(&devValidateWatch, "watch", "w", false, "Continuously re-run validations at the given interval (see --watch-interval)") | ||
| devValidateCmd.Flags().DurationVarP(&devValidateWatchInterval, "watch-interval", "i", 5*time.Second, "Interval between watch re-runs (e.g. 10s, 1m)") |
There was a problem hiding this comment.
The --watch-interval flag has no lower-bound validation. If a user passes --watch-interval 0s or a negative duration, time.NewTicker will panic at runtime:
panic: non-positive interval for NewTicker
Consider adding a validation check before passing the interval to TickerWatchLoop:
if devValidateWatch && devValidateWatchInterval <= 0 {
return fmt.Errorf("--watch-interval must be a positive duration (e.g. 5s, 1m)")
}Same applies to dev_test_cmd.go line 100.
time.NewTicker panics on a zero or negative duration. Return a clear error instead of crashing when --watch-interval <= 0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @pbrissaud's task in 45s —— View job PR Review Update:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
--watch-interval/-iduration flag (default5s) todev validateanddev test5*time.SecondinTickerWatchLoopcalls with the user-supplied value--watchusage keeps the 5s defaultFixes #165
Test plan
./bin/kubeasy dev validate <slug> --watchbehaves identically to before (5s interval)./bin/kubeasy dev validate <slug> --watch --watch-interval 15spolls every 15s./bin/kubeasy dev test <slug> --watch -i 30spolls every 30stask test:unitpassestask lintreports 0 issues🤖 Generated with Claude Code