mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-20 15:00:51 +02:00
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:
+17
-1
@@ -3,8 +3,14 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
)
|
||||
|
||||
// defaultTrackLogsInterval is the default --track-logs-interval shared by
|
||||
// the sync and apply commands. It mirrors kubedog's defaultLogsInterval;
|
||||
// keep the two in sync.
|
||||
const defaultTrackLogsInterval = 10 * time.Second
|
||||
|
||||
// SyncOptions is the options for the build command
|
||||
type SyncOptions struct {
|
||||
// Set is the set flag
|
||||
@@ -63,6 +69,8 @@ type SyncOptions struct {
|
||||
TrackLogs bool
|
||||
// TrackFailedLogs streams logs only for pods that enter a failed state.
|
||||
TrackFailedLogs bool
|
||||
// TrackLogsInterval is the interval between kubedog log output updates.
|
||||
TrackLogsInterval time.Duration
|
||||
// HelmStuckGrace, when > 0, enables the helm-killer safety valve. See
|
||||
// ReleaseSpec.HelmStuckGrace for details. Value is in seconds.
|
||||
HelmStuckGrace int
|
||||
@@ -93,7 +101,7 @@ type SyncOptions struct {
|
||||
|
||||
// NewSyncOptions creates a new Apply
|
||||
func NewSyncOptions() *SyncOptions {
|
||||
return &SyncOptions{}
|
||||
return &SyncOptions{TrackLogsInterval: defaultTrackLogsInterval}
|
||||
}
|
||||
|
||||
// SyncImpl is impl for applyOptions
|
||||
@@ -254,6 +262,11 @@ func (t *SyncImpl) TrackFailedLogs() bool {
|
||||
return t.SyncOptions.TrackFailedLogs
|
||||
}
|
||||
|
||||
// TrackLogsInterval returns the kubedog log output interval.
|
||||
func (t *SyncImpl) TrackLogsInterval() time.Duration {
|
||||
return t.SyncOptions.TrackLogsInterval
|
||||
}
|
||||
|
||||
// HelmStuckGrace returns the helm-stuck-grace value (seconds, 0 = disabled).
|
||||
func (t *SyncImpl) HelmStuckGrace() int {
|
||||
return t.SyncOptions.HelmStuckGrace
|
||||
@@ -349,5 +362,8 @@ func (t *SyncImpl) ValidateConfig() error {
|
||||
if t.SyncOptions.TrackMode != "" && !slices.Contains(validTrackModes, t.SyncOptions.TrackMode) {
|
||||
return fmt.Errorf("--track-mode must be 'helm', 'helm-legacy', or 'kubedog', got: %s", t.SyncOptions.TrackMode)
|
||||
}
|
||||
if t.SyncOptions.TrackLogsInterval < time.Second {
|
||||
return fmt.Errorf("--track-logs-interval must be at least 1s, got: %s", t.SyncOptions.TrackLogsInterval)
|
||||
}
|
||||
return t.GlobalImpl.ValidateConfig()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user