Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: ⚠️ Bump to CR v0.15.0 #1002

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ require (
github.com/onsi/gomega v1.27.8
github.com/pkg/errors v0.9.1
golang.org/x/net v0.11.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
k8s.io/client-go v0.27.2
k8s.io/utils v0.0.0-20230209194617-a36077c30491
sigs.k8s.io/cluster-api v1.4.2
sigs.k8s.io/controller-runtime v0.14.5
sigs.k8s.io/controller-runtime v0.15.0

)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -40,31 +40,31 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 //indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Expand Down
434 changes: 49 additions & 385 deletions api/go.sum

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions api/v1beta1/metal3cluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func (c *Metal3Cluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
Expand All @@ -40,18 +41,18 @@ func (c *Metal3Cluster) Default() {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Cluster) ValidateCreate() error {
return c.validate()
func (c *Metal3Cluster) ValidateCreate() (admission.Warnings, error) {
return nil, c.validate()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Cluster) ValidateUpdate(old runtime.Object) error {
return c.validate()
func (c *Metal3Cluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
return nil, c.validate()
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Cluster) ValidateDelete() error {
return nil
func (c *Metal3Cluster) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

func (c *Metal3Cluster) validate() error {
Expand Down
12 changes: 8 additions & 4 deletions api/v1beta1/metal3cluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ func TestMetal3ClusterValidation(t *testing.T) {
g := NewWithT(t)

if tt.expectErr {
g.Expect(tt.c.ValidateCreate()).NotTo(Succeed())
g.Expect(tt.c.ValidateUpdate(nil)).NotTo(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).To(HaveOccurred())
_, err = tt.c.ValidateUpdate(nil)
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(tt.c.ValidateCreate()).To(Succeed())
g.Expect(tt.c.ValidateUpdate(nil)).To(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).ToNot(HaveOccurred())
_, err = tt.c.ValidateUpdate(nil)
g.Expect(err).ToNot(HaveOccurred())
}
})
}
Expand Down
19 changes: 10 additions & 9 deletions api/v1beta1/metal3data_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func (c *Metal3Data) SetupWebhookWithManager(mgr ctrl.Manager) error {
Expand All @@ -40,7 +41,7 @@ func (c *Metal3Data) Default() {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Data) ValidateCreate() error {
func (c *Metal3Data) ValidateCreate() (admission.Warnings, error) {
allErrs := field.ErrorList{}
if (c.Spec.TemplateReference != "" && c.Name != c.Spec.TemplateReference+"-"+strconv.Itoa(c.Spec.Index)) ||
(c.Spec.TemplateReference == "" && c.Name != c.Spec.Template.Name+"-"+strconv.Itoa(c.Spec.Index)) {
Expand All @@ -64,17 +65,17 @@ func (c *Metal3Data) ValidateCreate() error {
}

if len(allErrs) == 0 {
return nil
return nil, nil
}
return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Data) ValidateUpdate(old runtime.Object) error {
func (c *Metal3Data) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
allErrs := field.ErrorList{}
oldMetal3Data, ok := old.(*Metal3Data)
if !ok || oldMetal3Data == nil {
return apierrors.NewInternalError(errors.New("unable to convert existing object"))
return nil, apierrors.NewInternalError(errors.New("unable to convert existing object"))
}

if c.Spec.Index != oldMetal3Data.Spec.Index {
Expand Down Expand Up @@ -140,12 +141,12 @@ func (c *Metal3Data) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) == 0 {
return nil
return nil, nil
}
return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3Data) ValidateDelete() error {
return nil
func (c *Metal3Data) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
18 changes: 12 additions & 6 deletions api/v1beta1/metal3data_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,19 @@ func TestMetal3DataCreateValidation(t *testing.T) {
}

if tt.expectErr {
g.Expect(obj.ValidateCreate()).NotTo(Succeed())
_, err := obj.ValidateCreate()
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(obj.ValidateCreate()).To(Succeed())
_, err := obj.ValidateCreate()
g.Expect(err).ToNot(HaveOccurred())
}

obj.Spec.Index = -1
g.Expect(obj.ValidateCreate()).NotTo(Succeed())
_, err := obj.ValidateCreate()
g.Expect(err).To(HaveOccurred())

g.Expect(obj.ValidateDelete()).To(Succeed())
_, err = obj.ValidateDelete()
g.Expect(err).ToNot(HaveOccurred())
})
}
}
Expand Down Expand Up @@ -279,9 +283,11 @@ func TestMetal3DataUpdateValidation(t *testing.T) {
}

if tt.expectErr {
g.Expect(newData.ValidateUpdate(oldData)).NotTo(Succeed())
_, err := newData.ValidateUpdate(oldData)
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(newData.ValidateUpdate(oldData)).To(Succeed())
_, err := newData.ValidateUpdate(oldData)
g.Expect(err).ToNot(HaveOccurred())
}
})
}
Expand Down
19 changes: 10 additions & 9 deletions api/v1beta1/metal3dataclaim_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func (c *Metal3DataClaim) SetupWebhookWithManager(mgr ctrl.Manager) error {
Expand All @@ -38,7 +39,7 @@ func (c *Metal3DataClaim) Default() {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataClaim) ValidateCreate() error {
func (c *Metal3DataClaim) ValidateCreate() (admission.Warnings, error) {
allErrs := field.ErrorList{}
if c.Spec.Template.Name == "" {
allErrs = append(allErrs,
Expand All @@ -51,17 +52,17 @@ func (c *Metal3DataClaim) ValidateCreate() error {
}

if len(allErrs) == 0 {
return nil
return nil, nil
}
return apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs)
return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataClaim) ValidateUpdate(old runtime.Object) error {
func (c *Metal3DataClaim) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
allErrs := field.ErrorList{}
oldMetal3DataClaim, ok := old.(*Metal3DataClaim)
if !ok || oldMetal3DataClaim == nil {
return apierrors.NewInternalError(errors.New("unable to convert existing object"))
return nil, apierrors.NewInternalError(errors.New("unable to convert existing object"))
}

if c.Spec.Template.Name != oldMetal3DataClaim.Spec.Template.Name {
Expand Down Expand Up @@ -91,12 +92,12 @@ func (c *Metal3DataClaim) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) == 0 {
return nil
return nil, nil
}
return apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs)
return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataClaim) ValidateDelete() error {
return nil
func (c *Metal3DataClaim) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}
12 changes: 8 additions & 4 deletions api/v1beta1/metal3dataclaim_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ func TestMetal3DataClaimValidation(t *testing.T) {
g := NewWithT(t)

if tt.expectErr {
g.Expect(tt.c.ValidateCreate()).NotTo(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(tt.c.ValidateCreate()).To(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).ToNot(HaveOccurred())
}
})
}
Expand Down Expand Up @@ -197,9 +199,11 @@ func TestMetal3DataClaimUpdateValidation(t *testing.T) {
}

if tt.expectErr {
g.Expect(newDataClaim.ValidateUpdate(oldDataClaim)).NotTo(Succeed())
_, err := newDataClaim.ValidateUpdate(oldDataClaim)
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(newDataClaim.ValidateUpdate(oldDataClaim)).To(Succeed())
_, err := newDataClaim.ValidateUpdate(oldDataClaim)
g.Expect(err).ToNot(HaveOccurred())
}
})
}
Expand Down
17 changes: 9 additions & 8 deletions api/v1beta1/metal3datatemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func (c *Metal3DataTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
Expand Down Expand Up @@ -88,16 +89,16 @@ func (c *Metal3DataTemplate) Default() {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataTemplate) ValidateCreate() error {
return c.validate()
func (c *Metal3DataTemplate) ValidateCreate() (admission.Warnings, error) {
return nil, c.validate()
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataTemplate) ValidateUpdate(old runtime.Object) error {
func (c *Metal3DataTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
allErrs := field.ErrorList{}
oldM3dt, ok := old.(*Metal3DataTemplate)
if !ok || oldM3dt == nil {
return apierrors.NewInternalError(errors.New("unable to convert existing object"))
return nil, apierrors.NewInternalError(errors.New("unable to convert existing object"))
}

if !reflect.DeepEqual(c.Spec.MetaData, oldM3dt.Spec.MetaData) {
Expand All @@ -121,14 +122,14 @@ func (c *Metal3DataTemplate) ValidateUpdate(old runtime.Object) error {
}

if len(allErrs) == 0 {
return nil
return nil, nil
}
return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs)
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (c *Metal3DataTemplate) ValidateDelete() error {
return nil
func (c *Metal3DataTemplate) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

func (c *Metal3DataTemplate) validate() error {
Expand Down
15 changes: 10 additions & 5 deletions api/v1beta1/metal3datatemplate_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ func TestMetal3DataTemplateValidation(t *testing.T) {
g := NewWithT(t)

if tt.expectErr {
g.Expect(tt.c.ValidateCreate()).NotTo(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(tt.c.ValidateCreate()).To(Succeed())
_, err := tt.c.ValidateCreate()
g.Expect(err).ToNot(HaveOccurred())
}

g.Expect(tt.c.ValidateDelete()).To(Succeed())
_, err := tt.c.ValidateDelete()
g.Expect(err).ToNot(HaveOccurred())
})
}
}
Expand Down Expand Up @@ -200,9 +203,11 @@ func TestMetal3DataTemplateUpdateValidation(t *testing.T) {
}

if tt.expectErr {
g.Expect(newDT.ValidateUpdate(oldDT)).NotTo(Succeed())
_, err := newDT.ValidateUpdate(oldDT)
g.Expect(err).To(HaveOccurred())
} else {
g.Expect(newDT.ValidateUpdate(oldDT)).To(Succeed())
_, err := newDT.ValidateUpdate(oldDT)
g.Expect(err).ToNot(HaveOccurred())
}
})
}
Expand Down
Loading