55
66 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
77
8+ "github.com/validator-labs/validator/pkg/validationrule"
9+
810 "github.com/validator-labs/validator-plugin-vsphere/pkg/constants"
911 "github.com/validator-labs/validator-plugin-vsphere/pkg/vsphere"
1012)
@@ -41,18 +43,34 @@ type VsphereAuth struct {
4143
4244// NTPValidationRule defines the NTP validation rule
4345type NTPValidationRule struct {
44- // Name is the name of the NTP validation rule
45- Name string `json:"name" yaml:"name"`
46+ validationrule.ManuallyNamed `json:"-"`
47+
48+ // RuleName is the name of the NTP validation rule
49+ RuleName string `json:"name" yaml:"name"`
4650 // ClusterName is required when the vCenter Host(s) reside beneath a Cluster in the vCenter object hierarchy
4751 ClusterName string `json:"clusterName,omitempty" yaml:"clusterName,omitempty"`
4852 // Hosts is the list of vCenter Hosts to validate NTP configuration
4953 Hosts []string `json:"hosts" yaml:"hosts"`
5054}
5155
56+ var _ validationrule.Interface = (* NTPValidationRule )(nil )
57+
58+ // Name returns the name of the NTPValidationRule.
59+ func (r NTPValidationRule ) Name () string {
60+ return r .RuleName
61+ }
62+
63+ // SetName sets the name of the NTPValidationRule.
64+ func (r * NTPValidationRule ) SetName (name string ) {
65+ r .RuleName = name
66+ }
67+
5268// ComputeResourceRule defines the compute resource validation rule
5369type ComputeResourceRule struct {
54- // Name is the name of the compute resource validation rule
55- Name string `json:"name" yaml:"name"`
70+ validationrule.ManuallyNamed `json:"-"`
71+
72+ // RuleName is the name of the compute resource validation rule
73+ RuleName string `json:"name" yaml:"name"`
5674 // ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
5775 ClusterName string `json:"clusterName,omitempty" yaml:"clusterName"`
5876 // Scope is the scope of the compute resource validation rule
@@ -63,10 +81,24 @@ type ComputeResourceRule struct {
6381 NodepoolResourceRequirements []NodepoolResourceRequirement `json:"nodepoolResourceRequirements" yaml:"nodepoolResourceRequirements"`
6482}
6583
84+ var _ validationrule.Interface = (* ComputeResourceRule )(nil )
85+
86+ // Name returns the name of the ComputeResourceRule.
87+ func (r ComputeResourceRule ) Name () string {
88+ return r .RuleName
89+ }
90+
91+ // SetName sets the name of the ComputeResourceRule.
92+ func (r * ComputeResourceRule ) SetName (name string ) {
93+ r .RuleName = name
94+ }
95+
6696// EntityPrivilegeValidationRule defines the entity privilege validation rule
6797type EntityPrivilegeValidationRule struct {
68- // Name is the name of the entity privilege validation rule
69- Name string `json:"name" yaml:"name"`
98+ validationrule.ManuallyNamed `json:"-"`
99+
100+ // RuleName is the name of the entity privilege validation rule
101+ RuleName string `json:"name" yaml:"name"`
70102 // Username is the username to validate against
71103 Username string `json:"username" yaml:"username"`
72104 // ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
@@ -79,18 +111,41 @@ type EntityPrivilegeValidationRule struct {
79111 Privileges []string `json:"privileges" yaml:"privileges"`
80112}
81113
114+ var _ validationrule.Interface = (* EntityPrivilegeValidationRule )(nil )
115+
116+ // Name returns the name of the EntityPrivilegeValidationRule.
117+ func (r EntityPrivilegeValidationRule ) Name () string {
118+ return r .RuleName
119+ }
120+
121+ // SetName sets the name of the EntityPrivilegeValidationRule.
122+ func (r * EntityPrivilegeValidationRule ) SetName (name string ) {
123+ r .RuleName = name
124+ }
125+
82126// GenericRolePrivilegeValidationRule defines the generic role privilege validation rule
83127type GenericRolePrivilegeValidationRule struct {
128+ validationrule.AutomaticallyNamed `json:"-"`
129+
84130 // Username is the username to validate against
85131 Username string `json:"username" yaml:"username"`
86132 // Privileges is the list of privileges to validate that the user has
87133 Privileges []string `json:"privileges" yaml:"privileges"`
88134}
89135
136+ var _ validationrule.Interface = (* GenericRolePrivilegeValidationRule )(nil )
137+
138+ // Name returns the name of the GenericRolePrivilegeValidationRule.
139+ func (r GenericRolePrivilegeValidationRule ) Name () string {
140+ return r .Username
141+ }
142+
90143// TagValidationRule defines the tag validation rule
91144type TagValidationRule struct {
92- // Name is the name of the tag validation rule
93- Name string `json:"name" yaml:"name"`
145+ validationrule.ManuallyNamed `json:"-"`
146+
147+ // RuleName is the name of the tag validation rule
148+ RuleName string `json:"name" yaml:"name"`
94149 // ClusterName is required when the vCenter Entity resides beneath a Cluster in the vCenter object hierarchy
95150 ClusterName string `json:"clusterName,omitempty" yaml:"clusterName"`
96151 // EntityType is the type of the entity to validate
@@ -101,6 +156,18 @@ type TagValidationRule struct {
101156 Tag string `json:"tag" yaml:"tag"`
102157}
103158
159+ var _ validationrule.Interface = (* TagValidationRule )(nil )
160+
161+ // Name returns the name of the TagValidationRule.
162+ func (r TagValidationRule ) Name () string {
163+ return r .RuleName
164+ }
165+
166+ // SetName sets the name of the TagValidationRule.
167+ func (r * TagValidationRule ) SetName (name string ) {
168+ r .RuleName = name
169+ }
170+
104171// NodepoolResourceRequirement defines the resource requirements for a nodepool
105172type NodepoolResourceRequirement struct {
106173 // Name is the name of the nodepool
0 commit comments