Skip to content

Commit

Permalink
remove commented lines of code
Browse files Browse the repository at this point in the history
  • Loading branch information
sircthulhu committed Mar 20, 2024
1 parent e801931 commit 5d2f7be
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
18 changes: 0 additions & 18 deletions api/v1alpha1/etcdcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ var _ webhook.Validator = &EtcdCluster{}
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *EtcdCluster) ValidateCreate() (admission.Warnings, error) {
etcdclusterlog.Info("validate create", "name", r.Name)
//var allErrors field.ErrorList
//// write validation here
//if len(allErrors) > 0 {
// return nil, apierrors.NewInvalid(
// schema.GroupKind{Group: GroupVersion.Group, Kind: "EtcdCluster"},
// r.Name, allErrors)
//}

return nil, nil
}

Expand All @@ -72,16 +64,6 @@ func (r *EtcdCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, er
if old.(*EtcdCluster).Spec.Replicas != r.Spec.Replicas {
warnings = append(warnings, "cluster resize is not currently supported")
}

//var allErrors field.ErrorList
//// write validation here
//var err *apierrors.StatusError
//if len(allErrors) > 0 {
// err = apierrors.NewInvalid(
// schema.GroupKind{Group: GroupVersion.Group, Kind: "EtcdCluster"},
// r.Name, allErrors)
// return warnings, err
//}
return warnings, nil
}

Expand Down
20 changes: 0 additions & 20 deletions api/v1alpha1/etcdcluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,6 @@ var _ = Describe("EtcdCluster Webhook", func() {
})

Context("When creating EtcdCluster under Validating Webhook", func() {
//It("Should deny if replicas is negative", func() {
// etcdCluster := &EtcdCluster{
// Spec: EtcdClusterSpec{
// Replicas: ptr.To(int32(-1)),
// },
// }
// _, err := etcdCluster.ValidateCreate()
// var statusErr *apierrors.StatusError
//
// if gomega.Expect(err).To(gomega.BeAssignableToTypeOf(statusErr)) {
// statusErr = err.(*apierrors.StatusError)
// gomega.Expect(statusErr.ErrStatus.Reason).To(gomega.Equal(metav1.StatusReasonInvalid))
// gomega.Expect(statusErr.ErrStatus.Details.Causes).To(gomega.ContainElement(metav1.StatusCause{
// Type: metav1.CauseTypeFieldValueInvalid,
// Message: "Invalid value: -1: cluster replicas cannot be less than zero",
// Field: "spec.replicas",
// }))
// }
//})

It("Should admit if all required fields are provided", func() {
etcdCluster := &EtcdCluster{
Spec: EtcdClusterSpec{
Expand Down

0 comments on commit 5d2f7be

Please sign in to comment.