Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ifeq ($(FIPS_ENABLE),yes)
RELEASE_LOC := release-fips
endif

SPECTRO_VERSION ?= 4.7.0-dev
SPECTRO_VERSION ?= 4.8.0-dev
TAG ?= v0.6.1-spectro-${SPECTRO_VERSION}
ARCH ?= amd64
ALL_ARCH = amd64 arm64
Expand Down
28 changes: 22 additions & 6 deletions api/v1beta3/cloudstackcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta3

import (
"context"
"fmt"

"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -36,25 +37,36 @@ var cloudstackclusterlog = logf.Log.WithName("cloudstackcluster-resource")
func (r *CloudStackCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
WithDefaulter(r). // registers webhook.CustomDefaulter
WithValidator(r). // registers webhook.CustomValidator
Complete()
}

//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,verbs=create;update,versions=v1beta3,name=mcloudstackcluster.kb.io,admissionReviewVersions=v1;v1beta1

var _ webhook.Defaulter = &CloudStackCluster{}
var _ webhook.CustomDefaulter = &CloudStackCluster{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *CloudStackCluster) Default() {
func (r *CloudStackCluster) Default(_ context.Context, obj runtime.Object) error {
r, ok := obj.(*CloudStackCluster)
if !ok {
return fmt.Errorf("expected *CloudStackCluster, got %T", obj)
}
cloudstackclusterlog.V(1).Info("entered api default setting webhook", "api resource name", r.Name)
// No defaulted values supported yet.
return nil
}

// +kubebuilder:webhook:name=vcloudstackcluster.kb.io,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackclusters,versions=v1beta3,verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackcluster,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1

var _ webhook.Validator = &CloudStackCluster{}
var _ webhook.CustomValidator = &CloudStackCluster{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
func (r *CloudStackCluster) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
r, ok := obj.(*CloudStackCluster)
if !ok {
return nil, fmt.Errorf("expected *CloudStackCluster, got %T", obj)
}
cloudstackclusterlog.V(1).Info("entered validate create webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand Down Expand Up @@ -85,7 +97,11 @@ func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *CloudStackCluster) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
r, ok := new.(*CloudStackCluster)
if !ok {
return nil, fmt.Errorf("expected *CloudStackCluster, got %T", new)
}
cloudstackclusterlog.V(1).Info("entered validate update webhook", "api resource name", r.Name)

spec := r.Spec
Expand Down Expand Up @@ -151,7 +167,7 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackCluster) ValidateDelete() (admission.Warnings, error) {
func (r *CloudStackCluster) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
cloudstackclusterlog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
// No deletion validations. Deletion webhook not enabled.
return nil, nil
Expand Down
28 changes: 22 additions & 6 deletions api/v1beta3/cloudstackmachine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta3

import (
"context"
"fmt"
"reflect"

Expand All @@ -36,25 +37,36 @@ var cloudstackmachinelog = logf.Log.WithName("cloudstackmachine-resource")
func (r *CloudStackMachine) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
WithDefaulter(r). // registers webhook.CustomDefaulter
WithValidator(r). // registers webhook.CustomValidator
Complete()
}

//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachine,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachines,verbs=create;update,versions=v1beta3,name=mcloudstackmachine.kb.io,admissionReviewVersions=v1;v1beta1

var _ webhook.Defaulter = &CloudStackMachine{}
var _ webhook.CustomDefaulter = &CloudStackMachine{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *CloudStackMachine) Default() {
func (r *CloudStackMachine) Default(_ context.Context, obj runtime.Object) error {
r, ok := obj.(*CloudStackMachine)
if !ok {
return fmt.Errorf("expected *CloudStackCluster, got %T", obj)
}
cloudstackmachinelog.V(1).Info("entered api default setting webhook, no defaults to set", "api resource name", r.Name)
// No defaulted values supported yet.
return nil
}

//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachine,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachines,verbs=create;update,versions=v1beta3,name=vcloudstackmachine.kb.io,admissionReviewVersions=v1;v1beta1

var _ webhook.Validator = &CloudStackMachine{}
var _ webhook.CustomValidator = &CloudStackMachine{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
func (r *CloudStackMachine) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
r, ok := obj.(*CloudStackMachine)
if !ok {
return nil, fmt.Errorf("expected *CloudStackMachine, got %T", obj)
}
cloudstackmachinelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand All @@ -69,7 +81,11 @@ func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *CloudStackMachine) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
r, ok := new.(*CloudStackMachine)
if !ok {
return nil, fmt.Errorf("expected *CloudStackMachine, got %T", new)
}
cloudstackmachinelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand Down Expand Up @@ -103,7 +119,7 @@ func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnin
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachine) ValidateDelete() (admission.Warnings, error) {
func (r *CloudStackMachine) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
cloudstackmachinelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
// No deletion validations. Deletion webhook not enabled.
return nil, nil
Expand Down
28 changes: 22 additions & 6 deletions api/v1beta3/cloudstackmachinetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta3

import (
"context"
"fmt"
"reflect"
"strings"
Expand All @@ -37,25 +38,36 @@ var cloudstackmachinetemplatelog = logf.Log.WithName("cloudstackmachinetemplate-
func (r *CloudStackMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
WithDefaulter(r). // registers webhook.CustomDefaulter
WithValidator(r). // registers webhook.CustomValidator
Complete()
}

// +kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachinetemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta3,name=mcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1;v1beta1

var _ webhook.Defaulter = &CloudStackMachineTemplate{}
var _ webhook.CustomDefaulter = &CloudStackMachineTemplate{}

// Default implements webhook.Defaulter so a webhook will be registered for the type
func (r *CloudStackMachineTemplate) Default() {
func (r *CloudStackMachineTemplate) Default(_ context.Context, obj runtime.Object) error {
r, ok := obj.(*CloudStackMachineTemplate)
if !ok {
return fmt.Errorf("expected *CloudStackMachineTemplate, got %T", obj)
}
cloudstackmachinetemplatelog.V(1).Info("entered default setting webhook", "api resource name", r.Name)
// No defaulted values supported yet.
return nil
}

// +kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta3-cloudstackmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta3,name=vcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1;v1beta1

var _ webhook.Validator = &CloudStackMachineTemplate{}
var _ webhook.CustomValidator = &CloudStackMachineTemplate{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachineTemplate) ValidateCreate() (admission.Warnings, error) {
func (r *CloudStackMachineTemplate) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
r, ok := obj.(*CloudStackMachineTemplate)
if !ok {
return nil, fmt.Errorf("expected *CloudStackMachineTemplate, got %T", obj)
}
cloudstackmachinetemplatelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)

var errorList field.ErrorList
Expand All @@ -80,7 +92,11 @@ func (r *CloudStackMachineTemplate) ValidateCreate() (admission.Warnings, error)
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *CloudStackMachineTemplate) ValidateUpdate(_ context.Context, old runtime.Object, new runtime.Object) (admission.Warnings, error) {
r, ok := new.(*CloudStackMachineTemplate)
if !ok {
return nil, fmt.Errorf("expected *CloudStackMachineTemplate, got %T", new)
}
cloudstackmachinetemplatelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)

oldMachineTemplate, ok := old.(*CloudStackMachineTemplate)
Expand Down Expand Up @@ -111,7 +127,7 @@ func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) (admissio
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *CloudStackMachineTemplate) ValidateDelete() (admission.Warnings, error) {
func (r *CloudStackMachineTemplate) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
cloudstackmachinetemplatelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
// No deletion validations. Deletion webhook not enabled.
return nil, nil
Expand Down
82 changes: 41 additions & 41 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@ require (
github.com/go-logr/logr v1.4.2
github.com/hashicorp/go-multierror v1.1.1
github.com/jellydator/ttlcache/v3 v3.2.0
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/onsi/ginkgo/v2 v2.23.3
github.com/onsi/gomega v1.36.3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
github.com/smallfish/simpleyaml v0.1.0
github.com/spf13/pflag v1.0.5
github.com/spf13/pflag v1.0.6
go.uber.org/mock v0.5.1
golang.org/x/text v0.23.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.31.3
k8s.io/apimachinery v0.31.3
k8s.io/client-go v0.31.3
k8s.io/component-base v0.31.3
k8s.io/api v0.32.3
k8s.io/apimachinery v0.32.3
k8s.io/client-go v0.32.3
k8s.io/component-base v0.32.3
k8s.io/klog/v2 v2.130.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/cluster-api v1.9.6
sigs.k8s.io/controller-runtime v0.19.6
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
sigs.k8s.io/cluster-api v1.10.4
sigs.k8s.io/controller-runtime v0.20.4
)

require (
cel.dev/expr v0.18.0 // indirect
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
Expand All @@ -37,29 +38,28 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/cel-go v0.22.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -70,40 +70,40 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.28.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.1 // indirect
google.golang.org/protobuf v1.36.1 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.30.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
google.golang.org/grpc v1.67.3 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiextensions-apiserver v0.31.3 // indirect
k8s.io/apiserver v0.31.3 // indirect
k8s.io/cluster-bootstrap v0.31.3 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
k8s.io/apiextensions-apiserver v0.32.3 // indirect
k8s.io/apiserver v0.32.3 // indirect
k8s.io/cluster-bootstrap v0.32.3 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

Expand Down
Loading