kuma
1package universal
2
3import (
4"time"
5
6"github.com/pkg/errors"
7"go.uber.org/multierr"
8
9"github.com/kumahq/kuma/pkg/config"
10config_types "github.com/kumahq/kuma/pkg/config/types"
11)
12
13func DefaultUniversalRuntimeConfig() *UniversalRuntimeConfig {
14return &UniversalRuntimeConfig{
15DataplaneCleanupAge: config_types.Duration{Duration: 3 * 24 * time.Hour},
16VIPRefreshInterval: config_types.Duration{Duration: 500 * time.Millisecond},
17}
18}
19
20var _ config.Config = &UniversalRuntimeConfig{}
21
22// UniversalRuntimeConfig defines Universal-specific configuration
23type UniversalRuntimeConfig struct {
24config.BaseConfig
25
26// DataplaneCleanupAge defines how long Dataplane should be offline to be cleaned up by GC
27DataplaneCleanupAge config_types.Duration `json:"dataplaneCleanupAge" envconfig:"kuma_runtime_universal_dataplane_cleanup_age"`
28// VIPRefreshInterval defines how often all meshes' VIPs should be recomputed
29VIPRefreshInterval config_types.Duration `json:"vipRefreshInterval" envconfig:"kuma_runtime_universal_vip_refresh_interval"`
30}
31
32func (u *UniversalRuntimeConfig) Validate() error {
33var errs error
34if u.DataplaneCleanupAge.Duration <= 0 {
35errs = multierr.Append(errs, errors.Errorf(".DataplaneCleanupAge must be positive"))
36}
37if u.VIPRefreshInterval.Duration <= 0 {
38errs = multierr.Append(errs, errors.Errorf(".VIPRefreshInterval must be positive"))
39}
40return errs
41}
42