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