This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathcluster_resource_provider.go
57 lines (47 loc) · 2.31 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
47
48
49
50
51
52
53
54
55
56
57
package runtime
import (
"context"
"time"
"github.com/lyft/flyteadmin/pkg/runtime/interfaces"
"github.com/lyft/flytestdlib/config"
"github.com/lyft/flytestdlib/logger"
)
const clusterResourceKey = "cluster_resources"
var clusterResourceConfig = config.MustRegisterSection(clusterResourceKey, &interfaces.ClusterResourceConfig{})
// Implementation of an interfaces.ClusterResourceConfiguration
type ClusterResourceConfigurationProvider struct{}
func (p *ClusterResourceConfigurationProvider) GetTemplatePath() string {
if clusterResourceConfig != nil && clusterResourceConfig.GetConfig() != nil {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).TemplatePath
}
logger.Warningf(context.Background(),
"Failed to find cluster resource values in config. Returning an empty string for template path")
return ""
}
func (p *ClusterResourceConfigurationProvider) GetTemplateData() interfaces.TemplateData {
if clusterResourceConfig != nil && clusterResourceConfig.GetConfig() != nil {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).TemplateData
}
logger.Warningf(context.Background(),
"Failed to find cluster resource values in config. Returning an empty map for template data")
return make(interfaces.TemplateData)
}
func (p *ClusterResourceConfigurationProvider) GetRefreshInterval() time.Duration {
if clusterResourceConfig != nil && clusterResourceConfig.GetConfig() != nil {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).RefreshInterval.Duration
}
logger.Warningf(context.Background(),
"Failed to find cluster resource values in config. Returning 1 minute for refresh interval")
return time.Minute
}
func (p *ClusterResourceConfigurationProvider) GetCustomTemplateData() map[interfaces.DomainName]interfaces.TemplateData {
if clusterResourceConfig != nil && clusterResourceConfig.GetConfig() != nil {
return clusterResourceConfig.GetConfig().(*interfaces.ClusterResourceConfig).CustomData
}
logger.Warningf(context.Background(),
"Failed to find cucluster resource values in config. Returning an empty map for custom template data")
return make(map[interfaces.DomainName]interfaces.TemplateData)
}
func NewClusterResourceConfigurationProvider() interfaces.ClusterResourceConfiguration {
return &ClusterResourceConfigurationProvider{}
}