func (w *WebhookPolicy) ValidateWebhookPolicy(causes []metav1.StatusCause) []metav1.StatusCause {
	if w == nil {
		return append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueInvalid,
			Field:   "webhook",
			Message: "webhook policy config params are missing",
		})
	}
	if w.Service == nil && w.URL == nil {
		causes = append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueNotFound,
			Field:   "url",
			Message: "url should be provided",
		})
	}
	if w.Service != nil && w.URL != nil {
		causes = append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueNotFound,
			Field:   "url",
			Message: "service and url cannot be used simultaneously",
		})
	}
	if w.CABundle != nil {
		rootCAs := x509.NewCertPool()
		//Check that CABundle provided is correctly encoded certificate
		if ok := rootCAs.AppendCertsFromPEM(w.CABundle); !ok {
			causes = append(causes, metav1.StatusCause{
				Type:    metav1.CauseTypeFieldValueInvalid,
				Field:   "caBundle",
				Message: "CA Bundle is not valid",
			})
		}
	}
	if w.URL != nil {
		u, err := url.Parse(*w.URL)
		if err != nil {
			causes = append(causes, metav1.StatusCause{
				Type:    metav1.CauseTypeFieldValueInvalid,
				Field:   "url",
				Message: "url is not valid",
			})
		} else if u.Scheme == "https" {
			if w.CABundle == nil {
				causes = append(causes, metav1.StatusCause{
					Type:    metav1.CauseTypeFieldValueNotFound,
					Field:   "caBundle",
					Message: "CABundle should be provided if HTTPS webhook is used",
				})
			}
		}

	}
	return causes
}
// ValidateWebhookPolicy validates the FleetAutoscaler Webhook policy settings
ValidateWebhookPolicy validates the FleetAutoscaler Webhook policy settings
// ValidateWebhookPolicy validates the FleetAutoscaler Webhook policy settings
func (w *WebhookPolicy) ValidateWebhookPolicy(causes []metav1.StatusCause) []metav1.StatusCause {
	if w == nil {
		return append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueInvalid,
			Field:   "webhook",
			Message: "webhook policy config params are missing",
		})
	}
	if w.Service == nil && w.URL == nil {
		causes = append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueNotFound,
			Field:   "url",
			Message: "url should be provided",
		})
	}
	if w.Service != nil && w.URL != nil {
		causes = append(causes, metav1.StatusCause{
			Type:    metav1.CauseTypeFieldValueNotFound,
			Field:   "url",
			Message: "service and url cannot be used simultaneously",
		})
	}
	if w.CABundle != nil {
		rootCAs := x509.NewCertPool()
		if ok := rootCAs.AppendCertsFromPEM(w.CABundle); !ok {
			causes = append(causes, metav1.StatusCause{
				Type:    metav1.CauseTypeFieldValueInvalid,
				Field:   "caBundle",
				Message: "CA Bundle is not valid",
			})
		}
	}
	if w.URL != nil {
		u, err := url.Parse(*w.URL)
		if err != nil {
			causes = append(causes, metav1.StatusCause{
				Type:    metav1.CauseTypeFieldValueInvalid,
				Field:   "url",
				Message: "url is not valid",
			})
		} else if u.Scheme == "https" {
			if w.CABundle == nil {
				causes = append(causes, metav1.StatusCause{
					Type:    metav1.CauseTypeFieldValueNotFound,
					Field:   "caBundle",
					Message: "CABundle should be provided if HTTPS webhook is used",
				})
			}
		}
	}
	return causes
}
func ( w * WebhookPolicy ) ValidateWebhookPolicy ( causes [ ] metav1 . StatusCause ) [ ] metav1 . StatusCause { if w == nil { return append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueInvalid , Field : " " , Message : " " , } ) } if w . Service == nil && w . URL == nil { causes = append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueNotFound , Field : " " , Message : " " , } ) } if w . Service != nil && w . URL != nil { causes = append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueNotFound , Field : " " , Message : " " , } ) } if w . CABundle != nil { rootCAs := x509 . NewCertPool ( ) if ok := rootCAs . AppendCertsFromPEM ( w . CABundle ) ; ! ok { causes = append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueInvalid , Field : " " , Message : " " , } ) } } if w . URL != nil { u , err := url . Parse ( * w . URL ) if err != nil { causes = append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueInvalid , Field : " " , Message : " " , } ) } else if u . Scheme == " " { if w . CABundle == nil { causes = append ( causes , metav1 . StatusCause { Type : metav1 . CauseTypeFieldValueNotFound , Field : " " , Message : " " , } ) } } } return causes }
ValidateWebhookPolicy validates the FleetAutoscaler Webhook policy settings
ValidateWebhookPolicy validates the FleetAutoscaler Webhook policy settings
//Check that CABundle provided is correctly encoded certificate