github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/pkg/model/update_settings.go (about) 1 package model 2 3 import ( 4 "time" 5 6 "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" 7 ) 8 9 const ( 10 DefaultMaxParallelUpdates = 3 11 ) 12 13 type UpdateSettings struct { 14 maxParallelUpdates int // max number of updates to run concurrently 15 k8sUpsertTimeout time.Duration // timeout for k8s upsert operations 16 17 // A list of images to suppress the warning for. 18 SuppressUnusedImageWarnings []string 19 } 20 21 func (us UpdateSettings) MaxParallelUpdates() int { 22 // Min. value is 1 23 if us.maxParallelUpdates < 1 { 24 return 1 25 } 26 return us.maxParallelUpdates 27 } 28 29 func (us UpdateSettings) WithMaxParallelUpdates(n int) UpdateSettings { 30 // Min. value is 1 31 if n < 1 { 32 n = 1 33 } 34 us.maxParallelUpdates = n 35 return us 36 } 37 38 func (us UpdateSettings) K8sUpsertTimeout() time.Duration { 39 // Min. value is 1s 40 if us.k8sUpsertTimeout < time.Second { 41 return time.Second 42 } 43 return us.k8sUpsertTimeout 44 } 45 46 func (us UpdateSettings) WithK8sUpsertTimeout(timeout time.Duration) UpdateSettings { 47 // Min. value is 1s 48 if us.k8sUpsertTimeout < time.Second { 49 timeout = time.Second 50 } 51 us.k8sUpsertTimeout = timeout 52 return us 53 } 54 55 func DefaultUpdateSettings() UpdateSettings { 56 return UpdateSettings{ 57 maxParallelUpdates: DefaultMaxParallelUpdates, 58 k8sUpsertTimeout: v1alpha1.KubernetesApplyTimeoutDefault, 59 } 60 }