add --track-logs-interval flag (#2807)

* add --track-logs-interval flag

Signed-off-by: pznamensky <kompastver@gmail.com>

* address review nits: logsInterval plumbing and test coverage

- kubedog: move defaultLogsInterval next to TrackOptions in options.go,
  where the field it defaults lives
- kubedog: pass logsInterval through newProgressPrinter instead of a
  post-construction field assignment; zero falls back to the default
- kubedog: cover WithLogsInterval and the LogsInterval default in
  tracker tests
- config: document that defaultTrackLogsInterval is shared by sync and
  apply and mirrors kubedog's default
- config: add a negative-interval validation test case

Signed-off-by: yxxhero <aiopsclub@163.com>

---------

Signed-off-by: pznamensky <kompastver@gmail.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
pznamensky
2026-09-30 08:30:21 +08:00
committed by GitHub
co-authored by yxxhero
parent 9263200ed7
commit 5ed585e223
17 changed files with 246 additions and 55 deletions
+11 -1
View File
@@ -33,6 +33,7 @@ func TestNewTrackOptions(t *testing.T) {
assert.Equal(t, 5*time.Minute, opts.Timeout)
assert.Equal(t, false, opts.Logs)
assert.Equal(t, 10*time.Minute, opts.LogsSince)
assert.Equal(t, 10*time.Second, opts.LogsInterval)
}
func TestTrackOptions_WithTimeout(t *testing.T) {
@@ -49,6 +50,13 @@ func TestTrackOptions_WithLogs(t *testing.T) {
assert.True(t, opts.Logs)
}
func TestTrackOptions_WithLogsInterval(t *testing.T) {
opts := NewTrackOptions()
opts = opts.WithLogsInterval(3 * time.Second)
assert.Equal(t, 3*time.Second, opts.LogsInterval)
}
func TestTrackOptions_Chaining(t *testing.T) {
opts := NewTrackOptions()
opts = opts.
@@ -375,7 +383,8 @@ func TestTrackOptions_Chaining_AllSetters(t *testing.T) {
WithQPS(50).
WithBurst(80).
WithColor(true).
WithBaselines(baselines)
WithBaselines(baselines).
WithLogsInterval(30 * time.Second)
assert.Equal(t, 2*time.Minute, opts.Timeout)
assert.True(t, opts.Logs)
@@ -385,6 +394,7 @@ func TestTrackOptions_Chaining_AllSetters(t *testing.T) {
assert.Equal(t, 80, opts.Burst)
assert.True(t, opts.Color)
assert.Equal(t, baselines, opts.Baselines)
assert.Equal(t, 30*time.Second, opts.LogsInterval)
}
// makeObj builds an *unstructured.Unstructured with the given path/value