Skip to content

Commit 883c0bf

Browse files
author
Matt Welke
authored
fix: YAML rendering of structs embedded in rules (#351)
## Description In previous PRs, we made the plugin rules implement the new `validationrule.Interface` interface. We did not include YAML tags in rules to specify that the new field (`validationrule.ManuallyNamed` or `validationrule.AutomaticallyNamed` depending on the rule) should not be included when the rules are rendered to YAML. The validatorctl CLI renders the rules to YAML as part of what it does, so this caused errors when validatorctl tried to apply validator CRDs it generated to its cluster. Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
1 parent e45ddc9 commit 883c0bf

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

api/v1alpha1/vspherevalidator_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type VsphereAuth struct {
4646

4747
// NTPValidationRule defines the NTP validation rule
4848
type NTPValidationRule struct {
49-
validationrule.ManuallyNamed `json:",inline"`
49+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
5050

5151
// RuleName is the name of the NTP validation rule
5252
RuleName string `json:"name" yaml:"name"`
@@ -70,7 +70,7 @@ func (r *NTPValidationRule) SetName(name string) {
7070

7171
// ComputeResourceRule defines the compute resource validation rule
7272
type ComputeResourceRule struct {
73-
validationrule.ManuallyNamed `json:",inline"`
73+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
7474

7575
// RuleName is the name of the compute resource validation rule
7676
RuleName string `json:"name" yaml:"name"`
@@ -98,7 +98,7 @@ func (r *ComputeResourceRule) SetName(name string) {
9898

9999
// EntityPrivilegeValidationRule defines the entity privilege validation rule
100100
type EntityPrivilegeValidationRule struct {
101-
validationrule.ManuallyNamed `json:",inline"`
101+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
102102

103103
// RuleName is the name of the entity privilege validation rule
104104
RuleName string `json:"name" yaml:"name"`
@@ -128,7 +128,7 @@ func (r *EntityPrivilegeValidationRule) SetName(name string) {
128128

129129
// GenericRolePrivilegeValidationRule defines the generic role privilege validation rule
130130
type GenericRolePrivilegeValidationRule struct {
131-
validationrule.AutomaticallyNamed `json:",inline"`
131+
validationrule.AutomaticallyNamed `json:",inline" yaml:",omitempty"`
132132

133133
// Username is the username to validate against
134134
Username string `json:"username" yaml:"username"`
@@ -145,7 +145,7 @@ func (r GenericRolePrivilegeValidationRule) Name() string {
145145

146146
// TagValidationRule defines the tag validation rule
147147
type TagValidationRule struct {
148-
validationrule.ManuallyNamed `json:",inline"`
148+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
149149

150150
// RuleName is the name of the tag validation rule
151151
RuleName string `json:"name" yaml:"name"`

0 commit comments

Comments
 (0)