/
vspherevalidator_types.go
110 lines (91 loc) · 4.93 KB
/
vspherevalidator_types.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 v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// VsphereValidatorSpec defines the desired state of VsphereValidator
type VsphereValidatorSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Auth VsphereAuth `json:"auth" yaml:"auth"`
Datacenter string `json:"datacenter" yaml:"datacenter"`
EntityPrivilegeValidationRules []EntityPrivilegeValidationRule `json:"entityPrivilegeValidationRules,omitempty" yaml:"entityPrivilegeValidationRules,omitempty"`
RolePrivilegeValidationRules []GenericRolePrivilegeValidationRule `json:"rolePrivilegeValidationRules,omitempty" yaml:"rolePrivilegeValidationRules,omitempty"`
TagValidationRules []TagValidationRule `json:"tagValidationRules,omitempty" yaml:"tagValidationRules,omitempty"`
ComputeResourceRules []ComputeResourceRule `json:"computeResourceRules,omitempty" yaml:"computeResourceRules,omitempty"`
NTPValidationRules []NTPValidationRule `json:"ntpValidationRules,omitempty" yaml:"ntpValidationRules,omitempty"`
}
type VsphereAuth struct {
SecretName string `json:"secretName" yaml:"secretName"`
}
type NTPValidationRule struct {
Name string `json:"name" yaml:"name"`
// ClusterName is required when the vCenter Host(s) reside beneath a Cluster in the vCenter object hierarchy
ClusterName string `json:"clusterName,omitempty" yaml:"clusterName,omitempty"`
Hosts []string `json:"hosts" yaml:"hosts"`
}
type ComputeResourceRule struct {
Name string `json:"name" yaml:"name"`
// ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
ClusterName string `json:"clusterName,omitempty" yaml:"clusterName"`
Scope string `json:"scope" yaml:"scope"`
EntityName string `json:"entityName" yaml:"entityName"`
NodepoolResourceRequirements []NodepoolResourceRequirement `json:"nodepoolResourceRequirements" yaml:"nodepoolResourceRequirements"`
}
type EntityPrivilegeValidationRule struct {
Name string `json:"name" yaml:"name"`
Username string `json:"username" yaml:"username"`
// ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
ClusterName string `json:"clusterName,omitempty" yaml:"clusterName"`
EntityType string `json:"entityType" yaml:"entityType"`
EntityName string `json:"entityName" yaml:"entityName"`
Privileges []string `json:"privileges" yaml:"privileges"`
}
type GenericRolePrivilegeValidationRule struct {
Username string `json:"username" yaml:"username"`
Privileges []string `json:"privileges" yaml:"privileges"`
}
type TagValidationRule struct {
Name string `json:"name" yaml:"name"`
// ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
ClusterName string `json:"clusterName,omitempty" yaml:"clusterName"`
EntityType string `json:"entityType" yaml:"entityType"`
EntityName string `json:"entityName" yaml:"entityName"`
Tag string `json:"tag" yaml:"tag"`
}
type NodepoolResourceRequirement struct {
Name string `json:"name" yaml:"name"`
NumberOfNodes int `json:"numberOfNodes" yaml:"numberOfNodes"`
CPU string `json:"cpu" yaml:"cpu"`
Memory string `json:"memory" yaml:"memory"`
DiskSpace string `json:"diskSpace" yaml:"diskSpace"`
}
// VsphereValidatorStatus defines the observed state of VsphereValidator
type VsphereValidatorStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// VsphereValidator is the Schema for the vspherevalidators API
type VsphereValidator struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec VsphereValidatorSpec `json:"spec,omitempty"`
Status VsphereValidatorStatus `json:"status,omitempty"`
}
func (s VsphereValidatorSpec) ResultCount() int {
return len(s.RolePrivilegeValidationRules) + len(s.EntityPrivilegeValidationRules) + len(s.ComputeResourceRules) +
len(s.TagValidationRules) + len(s.NTPValidationRules)
}
//+kubebuilder:object:root=true
// VsphereValidatorList contains a list of VsphereValidator
type VsphereValidatorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VsphereValidator `json:"items"`
}
func init() {
SchemeBuilder.Register(&VsphereValidator{}, &VsphereValidatorList{})
}