Skip to content

Commit c82abf3

Browse files
author
Matt Welke
authored
fix: YAML rendering of structs embedded in rules (#481)
## 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. This fixes it by adding the YAML tags. Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
1 parent 7c690f3 commit c82abf3

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

api/v1alpha1/awsvalidator_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ type AwsSTSAuth struct {
102102
// Each AmiRule is intended to match a single AMI, as an AmiRule is considered successful if at least one AMI is found.
103103
// Refer to https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html for more information.
104104
type AmiRule struct {
105-
validationrule.ManuallyNamed `json:",inline"`
105+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
106106

107107
RuleName string `json:"name" yaml:"name"`
108108
AmiIDs []string `json:"amiIds,omitempty" yaml:"amiIds,omitempty"`
@@ -132,7 +132,7 @@ type Filter struct {
132132

133133
// IamRoleRule compares the IAM permissions associated with an IAM role against an expected permission set.
134134
type IamRoleRule struct {
135-
validationrule.AutomaticallyNamed `json:",inline"`
135+
validationrule.AutomaticallyNamed `json:",inline" yaml:",omitempty"`
136136

137137
IamRoleName string `json:"iamRoleName" yaml:"iamRoleName"`
138138
Policies []PolicyDocument `json:"iamPolicies" yaml:"iamPolicies"`
@@ -152,7 +152,7 @@ func (r IamRoleRule) IAMPolicies() []PolicyDocument {
152152

153153
// IamUserRule compares the IAM permissions associated with an IAM user against an expected permission set.
154154
type IamUserRule struct {
155-
validationrule.AutomaticallyNamed `json:",inline"`
155+
validationrule.AutomaticallyNamed `json:",inline" yaml:",omitempty"`
156156

157157
IamUserName string `json:"iamUserName" yaml:"iamUserName"`
158158
Policies []PolicyDocument `json:"iamPolicies" yaml:"iamPolicies"`
@@ -172,7 +172,7 @@ func (r IamUserRule) IAMPolicies() []PolicyDocument {
172172

173173
// IamGroupRule compares the IAM permissions associated with an IAM group against an expected permission set.
174174
type IamGroupRule struct {
175-
validationrule.AutomaticallyNamed `json:",inline"`
175+
validationrule.AutomaticallyNamed `json:",inline" yaml:",omitempty"`
176176

177177
IamGroupName string `json:"iamGroupName" yaml:"iamGroupName"`
178178
Policies []PolicyDocument `json:"iamPolicies" yaml:"iamPolicies"`
@@ -192,7 +192,7 @@ func (r IamGroupRule) IAMPolicies() []PolicyDocument {
192192

193193
// IamPolicyRule compares the IAM permissions associated with an IAM policy against an expected permission set.
194194
type IamPolicyRule struct {
195-
validationrule.AutomaticallyNamed `json:",inline"`
195+
validationrule.AutomaticallyNamed `json:",inline" yaml:",omitempty"`
196196

197197
IamPolicyARN string `json:"iamPolicyArn" yaml:"iamPolicyArn"`
198198
Policies []PolicyDocument `json:"iamPolicies" yaml:"iamPolicies"`
@@ -243,7 +243,7 @@ func (c Condition) String() string {
243243

244244
// ServiceQuotaRule ensures that AWS service quotas are within a particular threshold.
245245
type ServiceQuotaRule struct {
246-
validationrule.ManuallyNamed `json:",inline"`
246+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
247247

248248
RuleName string `json:"name" yaml:"name"`
249249
Region string `json:"region" yaml:"region"`
@@ -271,7 +271,7 @@ type ServiceQuota struct {
271271

272272
// TagRule ensures that the tags associated with a particular AWS resource match an expected tag set.
273273
type TagRule struct {
274-
validationrule.ManuallyNamed `json:",inline"`
274+
validationrule.ManuallyNamed `json:",inline" yaml:",omitempty"`
275275

276276
RuleName string `json:"name" yaml:"name"`
277277
Key string `json:"key" yaml:"key"`

0 commit comments

Comments
 (0)