-
Notifications
You must be signed in to change notification settings - Fork 671
/
cluster_resource_provider.go
46 lines (35 loc) · 1.67 KB
/
cluster_resource_provider.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
package runtime
import (
"os"
"time"
"github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces"
"github.com/flyteorg/flyte/flytestdlib/config"
)
const clusterResourceKey = "cluster_resources"
var clusterResourceConfig = config.MustRegisterSection(clusterResourceKey, &interfaces.ClusterResourceConfig{
TemplateData: make(map[string]interfaces.DataSource),
RefreshInterval: config.Duration{
Duration: time.Minute,
},
CustomData: make(map[interfaces.DomainName]interfaces.TemplateData),
})
// Implementation of an interfaces.ClusterResourceConfiguration
type ClusterResourceConfigurationProvider struct{}
func (p *ClusterResourceConfigurationProvider) GetTemplatePath() string {
return os.ExpandEnv(clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).TemplatePath)
}
func (p *ClusterResourceConfigurationProvider) GetTemplateData() interfaces.TemplateData {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).TemplateData
}
func (p *ClusterResourceConfigurationProvider) GetRefreshInterval() time.Duration {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).RefreshInterval.Duration
}
func (p *ClusterResourceConfigurationProvider) GetCustomTemplateData() map[interfaces.DomainName]interfaces.TemplateData {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).CustomData
}
func (p *ClusterResourceConfigurationProvider) IsStandaloneDeployment() bool {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).StandaloneDeployment
}
func NewClusterResourceConfigurationProvider() interfaces.ClusterResourceConfiguration {
return &ClusterResourceConfigurationProvider{}
}