Skip to content

Commit 8bd396f

Browse files
committed
apply appropriate validations when either configuration is provided
1 parent 9ba53ff commit 8bd396f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pkg/apis/conventions/v1alpha1/clusterpodconvention_validation.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ func (s *ClusterPodConventionSpec) Validate() validation.FieldErrors {
7777
errs = errs.Also(validation.ErrMissingField("webhook")).Also(validation.ErrMissingField("ytt"))
7878

7979
} else {
80-
// validate via the ytt field as well
81-
// return multiple errors for this to request a desired configuration
82-
8380
// only invoke webhook validations if the ytt configuration is not being used
8481
if s.Ytt == nil && s.Webhook != nil {
8582
errs = errs.Also(s.Webhook.Validate().ViaField("webhook"))
8683
}
87-
// errs = errs.Also(s.Ytt.Validate().ViaField("ytt"))
84+
// only invoke ytt validations if the webhook configuration is not being used
85+
if s.Webhook == nil && s.Ytt != nil {
86+
errs = errs.Also(s.Webhook.Validate().ViaField("ytt"))
87+
}
8888
}
8989

9090
if s.SelectorTarget != PodTemplateSpecLabels && s.SelectorTarget != PodIntentLabels {
@@ -96,13 +96,13 @@ func (s *ClusterPodConventionSpec) Validate() validation.FieldErrors {
9696
return errs
9797
}
9898

99-
// func (s *ClusterPodConventionYttTemplate) Validate() validation.FieldErrors {
100-
// errs := validation.FieldErrors{}
101-
// if s.Template == "" {
102-
// errs = errs.Also(validation.ErrMissingField("template"))
103-
// }
104-
// return errs
105-
// }
99+
func (s *ClusterPodConventionYttTemplate) Validate() validation.FieldErrors {
100+
errs := validation.FieldErrors{}
101+
if s.Template == "" {
102+
errs = errs.Also(validation.ErrMissingField("template"))
103+
}
104+
return errs
105+
}
106106

107107
func (s *ClusterPodConventionWebhook) Validate() validation.FieldErrors {
108108
errs := validation.FieldErrors{}

0 commit comments

Comments
 (0)