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 .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25.7
1.26.3
4 changes: 0 additions & 4 deletions api/v1alpha1/clusterfederatedtrustdomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,3 @@ type ClusterFederatedTrustDomainList struct {
metav1.ListMeta `json:"metadata"`
Items []ClusterFederatedTrustDomain `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterFederatedTrustDomain{}, &ClusterFederatedTrustDomainList{})
}
29 changes: 9 additions & 20 deletions api/v1alpha1/clusterfederatedtrustdomain_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ import (
"github.com/spiffe/go-spiffe/v2/bundle/spiffebundle"
"github.com/spiffe/go-spiffe/v2/spiffeid"
"github.com/spiffe/spire-controller-manager/pkg/spireapi"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// log is for logging in this package.
var clusterfederatedtrustdomainlog = logf.Log.WithName("clusterfederatedtrustdomain-resource")

func (r *ClusterFederatedTrustDomain) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
return ctrl.NewWebhookManagedBy(mgr, r).
WithValidator(&ClusterFederatedTrustDomainCustomValidator{}).
Complete()
}
Expand All @@ -50,30 +47,22 @@ type ClusterFederatedTrustDomainCustomValidator struct {
// TODO(user): Add more fields as needed for validation
}

var _ webhook.CustomValidator = &ClusterFederatedTrustDomainCustomValidator{}
var _ admission.Validator[*ClusterFederatedTrustDomain] = &ClusterFederatedTrustDomainCustomValidator{}

// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
o, ok := obj.(*ClusterFederatedTrustDomain)
if !ok {
return nil, fmt.Errorf("expected a ClusterFederatedTrustDomain object but got %T", obj)
}
clusterfederatedtrustdomainlog.Info("validate create", "name", o.Name)
return r.validate(o)
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateCreate(_ context.Context, obj *ClusterFederatedTrustDomain) (admission.Warnings, error) {
clusterfederatedtrustdomainlog.Info("validate create", "name", obj.Name)
return r.validate(obj)
}

// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateUpdate(_ context.Context, _ runtime.Object, nobj runtime.Object) (admission.Warnings, error) {
o, ok := nobj.(*ClusterFederatedTrustDomain)
if !ok {
return nil, fmt.Errorf("expected a ClusterFederatedTrustDomain object but got %T", nobj)
}
clusterfederatedtrustdomainlog.Info("validate update", "name", o.Name)
return r.validate(o)
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateUpdate(_ context.Context, _ *ClusterFederatedTrustDomain, nobj *ClusterFederatedTrustDomain) (admission.Warnings, error) {
clusterfederatedtrustdomainlog.Info("validate update", "name", nobj.Name)
return r.validate(nobj)
}

// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateDelete(context.Context, runtime.Object) (admission.Warnings, error) {
func (r *ClusterFederatedTrustDomainCustomValidator) ValidateDelete(context.Context, *ClusterFederatedTrustDomain) (admission.Warnings, error) {
// Deletes are not validated.
return nil, nil
}
Expand Down
4 changes: 0 additions & 4 deletions api/v1alpha1/clusterspiffeid_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,3 @@ type ClusterSPIFFEIDList struct {
metav1.ListMeta `json:"metadata"`
Items []ClusterSPIFFEID `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterSPIFFEID{}, &ClusterSPIFFEIDList{})
}
31 changes: 9 additions & 22 deletions api/v1alpha1/clusterspiffeid_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ import (
"github.com/spiffe/go-spiffe/v2/spiffeid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

Expand All @@ -43,8 +41,7 @@ const (
var clusterspiffeidlog = logf.Log.WithName("clusterspiffeid-resource")

func (r *ClusterSPIFFEID) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
return ctrl.NewWebhookManagedBy(mgr, r).
WithValidator(&ClusterSPIFFEIDCustomValidator{}).
Complete()
}
Expand All @@ -58,32 +55,22 @@ type ClusterSPIFFEIDCustomValidator struct {
// TODO(user): Add more fields as needed for validation
}

var _ webhook.CustomValidator = &ClusterSPIFFEIDCustomValidator{}
var _ admission.Validator[*ClusterSPIFFEID] = &ClusterSPIFFEIDCustomValidator{}

// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterSPIFFEIDCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
o, ok := obj.(*ClusterSPIFFEID)
if !ok {
return nil, fmt.Errorf("expected a ClusterSPIFFEID object but got %T", obj)
}
clusterspiffeidlog.Info("validate create", "name", o.Name)

return r.validate(o)
func (r *ClusterSPIFFEIDCustomValidator) ValidateCreate(_ context.Context, obj *ClusterSPIFFEID) (admission.Warnings, error) {
clusterspiffeidlog.Info("validate create", "name", obj.Name)
return r.validate(obj)
}

// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterSPIFFEIDCustomValidator) ValidateUpdate(_ context.Context, _ runtime.Object, nobj runtime.Object) (admission.Warnings, error) {
o, ok := nobj.(*ClusterSPIFFEID)
if !ok {
return nil, fmt.Errorf("expected a ClusterSPIFFEID object but got %T", nobj)
}
clusterspiffeidlog.Info("validate update", "name", o.Name)

return r.validate(o)
func (r *ClusterSPIFFEIDCustomValidator) ValidateUpdate(_ context.Context, _ *ClusterSPIFFEID, nobj *ClusterSPIFFEID) (admission.Warnings, error) {
clusterspiffeidlog.Info("validate update", "name", nobj.Name)
return r.validate(nobj)
}

// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type
func (r *ClusterSPIFFEIDCustomValidator) ValidateDelete(context.Context, runtime.Object) (admission.Warnings, error) {
func (r *ClusterSPIFFEIDCustomValidator) ValidateDelete(context.Context, *ClusterSPIFFEID) (admission.Warnings, error) {
// Deletes are not validated.
return nil, nil
}
Expand Down
4 changes: 0 additions & 4 deletions api/v1alpha1/clusterstaticentry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,3 @@ type ClusterStaticEntryList struct {
metav1.ListMeta `json:"metadata"`
Items []ClusterStaticEntry `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterStaticEntry{}, &ClusterStaticEntryList{})
}
4 changes: 0 additions & 4 deletions api/v1alpha1/controllermanagerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,3 @@ type ControllerWebhook struct {
// +optional
CertDir string `json:"certDir,omitempty"`
}

func init() {
SchemeBuilder.Register(&ControllerManagerConfig{})
}
31 changes: 22 additions & 9 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,30 @@ limitations under the License.
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "spire.spiffe.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
const GroupName = "spire.spiffe.io"

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
var (
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ClusterFederatedTrustDomain{},
&ClusterFederatedTrustDomainList{},
&ClusterSPIFFEID{},
&ClusterSPIFFEIDList{},
&ClusterStaticEntry{},
&ClusterStaticEntryList{},
&ControllerManagerConfig{},
)

metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
2 changes: 1 addition & 1 deletion demo/greeter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25.7-alpine AS builder
FROM golang:1.26.3-alpine AS builder
WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
Expand Down
2 changes: 1 addition & 1 deletion demo/greeter/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module greeter

go 1.25.7
go 1.26.3

require (
github.com/spiffe/go-spiffe/v2 v2.6.0
Expand Down
30 changes: 14 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/spiffe/spire-controller-manager

go 1.25.7
go 1.26.3

require (
github.com/go-logr/logr v1.4.3
Expand All @@ -16,13 +16,13 @@ require (
github.com/stretchr/testify v1.11.1
go.uber.org/zap v1.27.1
google.golang.org/grpc v1.79.3
google.golang.org/protobuf v1.36.11
k8s.io/api v0.35.3
k8s.io/apimachinery v0.35.3
k8s.io/client-go v0.35.3
k8s.io/component-base v0.35.3
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
sigs.k8s.io/controller-runtime v0.22.4
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af
Comment thread
alecholmez marked this conversation as resolved.
k8s.io/api v0.36.0
k8s.io/apimachinery v0.36.0
k8s.io/client-go v0.36.0
k8s.io/component-base v0.36.0
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
sigs.k8s.io/controller-runtime v0.24.1
)

require (
Expand Down Expand Up @@ -52,8 +52,6 @@ require (
github.com/go-openapi/swag/typeutils v0.25.1 // indirect
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -62,7 +60,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand All @@ -79,15 +77,15 @@ require (
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.41.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.34.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/apiextensions-apiserver v0.36.0 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading