-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathls_operator.go
110 lines (90 loc) · 3.82 KB
/
ls_operator.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package lso
import (
"context"
"github.com/openshift/assisted-service/internal/common"
"github.com/openshift/assisted-service/internal/operators/api"
"github.com/openshift/assisted-service/models"
)
// lsOperator is an LSO OLM operator plugin; it implements api.Operator
type lsOperator struct {
}
var Operator = models.MonitoredOperator{
Name: "lso",
OperatorType: models.OperatorTypeOlm,
Namespace: "openshift-local-storage",
SubscriptionName: "local-storage-operator",
TimeoutSeconds: 70 * 60,
}
// New LSOperator creates new instance of a Local Storage Operator installation plugin
func NewLSOperator() *lsOperator {
return &lsOperator{}
}
// GetName reports the name of an operator this Operator manages
func (l *lsOperator) GetName() string {
return Operator.Name
}
func (l *lsOperator) GetFullName() string {
return "Local Storage Operator"
}
// GetDependencies provides a list of dependencies of the Operator
func (l *lsOperator) GetDependencies(cluster *common.Cluster) ([]string, error) {
return make([]string, 0), nil
}
// GetClusterValidationID returns cluster validation ID for the Operator
func (l *lsOperator) GetClusterValidationID() string {
return string(models.ClusterValidationIDLsoRequirementsSatisfied)
}
// GetHostValidationID returns host validation ID for the Operator
func (l *lsOperator) GetHostValidationID() string {
return string(models.HostValidationIDLsoRequirementsSatisfied)
}
// ValidateCluster always return "valid" result
func (l *lsOperator) ValidateCluster(_ context.Context, _ *common.Cluster) (api.ValidationResult, error) {
return api.ValidationResult{Status: api.Success, ValidationId: l.GetClusterValidationID(), Reasons: []string{}}, nil
}
// ValidateHost always return "valid" result
func (l *lsOperator) ValidateHost(_ context.Context, _ *common.Cluster, _ *models.Host, _ *models.ClusterHostRequirementsDetails) (api.ValidationResult, error) {
return api.ValidationResult{Status: api.Success, ValidationId: l.GetHostValidationID(), Reasons: []string{}}, nil
}
// GenerateManifests generates manifests for the operator
func (l *lsOperator) GenerateManifests(c *common.Cluster) (map[string][]byte, []byte, error) {
return Manifests()
}
// GetProperties provides description of operator properties: none required
func (l *lsOperator) GetProperties() models.OperatorProperties {
return models.OperatorProperties{}
}
// GetMonitoredOperator returns MonitoredOperator corresponding to the LSO
func (l *lsOperator) GetMonitoredOperator() *models.MonitoredOperator {
return &Operator
}
// GetHostRequirements provides operator's requirements towards the host
func (l *lsOperator) GetHostRequirements(context.Context, *common.Cluster, *models.Host) (*models.ClusterHostRequirementsDetails, error) {
return &models.ClusterHostRequirementsDetails{}, nil
}
// GetPreflightRequirements returns operator hardware requirements that can be determined with cluster data only
func (l *lsOperator) GetPreflightRequirements(context context.Context, cluster *common.Cluster) (*models.OperatorHardwareRequirements, error) {
dependecies, err := l.GetDependencies(cluster)
if err != nil {
return &models.OperatorHardwareRequirements{}, err
}
return &models.OperatorHardwareRequirements{
OperatorName: l.GetName(),
Dependencies: dependecies,
Requirements: &models.HostTypeHardwareRequirementsWrapper{
Master: &models.HostTypeHardwareRequirements{
Quantitative: &models.ClusterHostRequirementsDetails{},
},
Worker: &models.HostTypeHardwareRequirements{
Quantitative: &models.ClusterHostRequirementsDetails{},
},
},
}, nil
}
func (l *lsOperator) GetFeatureSupportID() models.FeatureSupportLevelID {
return models.FeatureSupportLevelIDLSO
}
// GetBundleLabels returns the bundle labels for the LSO operator
func (l *lsOperator) GetBundleLabels() []string {
return []string(Operator.Bundles)
}