Skip to content

Commit

Permalink
Merge branch 'main' into kedamain
Browse files Browse the repository at this point in the history
  • Loading branch information
JorTurFer committed Aug 12, 2024
2 parents 0c09b4b + 19463f8 commit 2c2cec2
Show file tree
Hide file tree
Showing 22 changed files with 979 additions and 335 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/3_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ body:
label: KEDA Version
description: What version of KEDA that are you running?
options:
- "2.15.1"
- "2.15.0"
- "2.14.1"
- "2.14.0"
Expand Down
18 changes: 15 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
## History

- [Unreleased](#unreleased)
- [v2.15.1](#v2151)
- [v2.15.0](#v2150)
- [v2.14.1](#v2141)
- [v2.14.0](#v2140)
Expand Down Expand Up @@ -56,7 +57,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### New

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))
- **CloudEventSource**: Introduce ClusterCloudEventSource ([#3533](https://github.com/kedacore/keda/issues/3533))

#### Experimental

Expand All @@ -70,8 +71,7 @@ Here is an overview of all new **experimental** features:

### Fixes

- **General**: Hashicorp Vault PKI doesn't fail with due to KeyPair mismatch ([#6028](https://github.com/kedacore/keda/issues/6028))
- **JetStream**: Consumer leader change is correctly detected ([#6042](https://github.com/kedacore/keda/issues/6042))
- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

### Deprecations

Expand All @@ -85,6 +85,18 @@ New deprecation(s):

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

### Other

- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX))

## v2.15.1

### Fixes

- **General**: Hashicorp Vault PKI doesn't fail with due to KeyPair mismatch ([#6028](https://github.com/kedacore/keda/issues/6028))
- **JetStream**: Consumer leader change is correctly detected ([#6042](https://github.com/kedacore/keda/issues/6042))


### Other

- **General**: Bump deps and k8s deps to 0.29.7 ([#6035](https://github.com/kedacore/keda/pull/6035))
Expand Down
54 changes: 53 additions & 1 deletion apis/eventing/v1alpha1/cloudeventsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ package v1alpha1

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

v1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1"
)

// +kubebuilder:object:generate=false
type CloudEventSourceInterface interface {
client.Object
GenerateIdentifier() string
GetSpec() *CloudEventSourceSpec
GetStatus() *CloudEventSourceStatus
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// CloudEventSource defines how a KEDA event will be sent to event sink
Expand All @@ -45,6 +54,28 @@ type CloudEventSourceList struct {
Items []CloudEventSource `json:"items"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:resource:path=clustercloudeventsources,scope=Cluster
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Active",type="string",JSONPath=".status.conditions[?(@.type==\"Active\")].status"
type ClusterCloudEventSource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec CloudEventSourceSpec `json:"spec"`
Status CloudEventSourceStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// ClusterCloudEventSourceList is a list of ClusterCloudEventSource resources
type ClusterCloudEventSourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ClusterCloudEventSource `json:"items"`
}

// CloudEventSourceSpec defines the spec of CloudEventSource
type CloudEventSourceSpec struct {
// +optional
Expand Down Expand Up @@ -93,14 +124,35 @@ type EventSubscription struct {
}

func init() {
SchemeBuilder.Register(&CloudEventSource{}, &CloudEventSourceList{})
SchemeBuilder.Register(&CloudEventSource{}, &CloudEventSourceList{}, &ClusterCloudEventSource{}, &ClusterCloudEventSourceList{})
}

func (ces *CloudEventSource) GetSpec() *CloudEventSourceSpec {
return &ces.Spec
}

func (ces *CloudEventSource) GetStatus() *CloudEventSourceStatus {
return &ces.Status
}

// GenerateIdentifier returns identifier for the object in for "kind.namespace.name"
func (ces *CloudEventSource) GenerateIdentifier() string {
return v1alpha1.GenerateIdentifier("CloudEventSource", ces.Namespace, ces.Name)
}

func (cces *ClusterCloudEventSource) GetSpec() *CloudEventSourceSpec {
return &cces.Spec
}

func (cces *ClusterCloudEventSource) GetStatus() *CloudEventSourceStatus {
return &cces.Status
}

// GenerateIdentifier returns identifier for the object in for "kind.cluster-scoped.name"
func (cces *ClusterCloudEventSource) GenerateIdentifier() string {
return v1alpha1.GenerateIdentifier("ClusterCloudEventSource", "cluster-scoped", cces.Name)
}

// GetCloudEventSourceInitializedConditions returns CloudEventSource Conditions initialized to the default -> Status: Unknown
func GetCloudEventSourceInitializedConditions() *v1alpha1.Conditions {
return &v1alpha1.Conditions{{Type: v1alpha1.ConditionActive, Status: metav1.ConditionUnknown}}
Expand Down
37 changes: 35 additions & 2 deletions apis/eventing/v1alpha1/cloudeventsource_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func (ces *CloudEventSource) SetupWebhookWithManager(mgr ctrl.Manager) error {
Complete()
}

func (cces *ClusterCloudEventSource) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(cces).
Complete()
}

// +kubebuilder:webhook:path=/validate-eventing-keda-sh-v1alpha1-cloudeventsource,mutating=false,failurePolicy=ignore,sideEffects=None,groups=eventing.keda.sh,resources=cloudeventsources,verbs=create;update,versions=v1alpha1,name=vcloudeventsource.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &CloudEventSource{}
Expand Down Expand Up @@ -64,6 +70,33 @@ func (ces *CloudEventSource) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

// +kubebuilder:webhook:path=/validate-eventing-keda-sh-v1alpha1-clustercloudeventsource,mutating=false,failurePolicy=ignore,sideEffects=None,groups=eventing.keda.sh,resources=clustercloudeventsources,verbs=create;update,versions=v1alpha1,name=vclustercloudeventsource.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &ClusterCloudEventSource{}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (cces *ClusterCloudEventSource) ValidateCreate() (admission.Warnings, error) {
val, _ := json.MarshalIndent(cces, "", " ")
cloudeventsourcelog.Info(fmt.Sprintf("validating clustercloudeventsource creation for %s", string(val)))
return validateSpec(&cces.Spec)
}

func (cces *ClusterCloudEventSource) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
val, _ := json.MarshalIndent(cces, "", " ")
cloudeventsourcelog.V(1).Info(fmt.Sprintf("validating clustercloudeventsource update for %s", string(val)))

oldCes := old.(*ClusterCloudEventSource)
if isCloudEventSourceRemovingFinalizer(cces.ObjectMeta, oldCes.ObjectMeta, cces.Spec, oldCes.Spec) {
cloudeventsourcelog.V(1).Info("finalizer removal, skipping validation")
return nil, nil
}
return validateSpec(&cces.Spec)
}

func (cces *ClusterCloudEventSource) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

func isCloudEventSourceRemovingFinalizer(om metav1.ObjectMeta, oldOm metav1.ObjectMeta, spec CloudEventSourceSpec, oldSpec CloudEventSourceSpec) bool {
cesSpec, _ := json.MarshalIndent(spec, "", " ")
oldCesSpec, _ := json.MarshalIndent(oldSpec, "", " ")
Expand All @@ -81,15 +114,15 @@ func validateSpec(spec *CloudEventSourceSpec) (admission.Warnings, error) {
if spec.EventSubscription.ExcludedEventTypes != nil {
for _, excludedEventType := range spec.EventSubscription.ExcludedEventTypes {
if !slices.Contains(AllEventTypes, excludedEventType) {
return nil, fmt.Errorf("excludedEventType: %s in cloudeventsource spec is not supported", excludedEventType)
return nil, fmt.Errorf("excludedEventType: %s in cloudeventsource/clustercloudeventsource spec is not supported", excludedEventType)
}
}
}

if spec.EventSubscription.IncludedEventTypes != nil {
for _, includedEventType := range spec.EventSubscription.IncludedEventTypes {
if !slices.Contains(AllEventTypes, includedEventType) {
return nil, fmt.Errorf("includedEventType: %s in cloudeventsource spec is not supported", includedEventType)
return nil, fmt.Errorf("includedEventType: %s in cloudeventsource/clustercloudeventsource spec is not supported", includedEventType)
}
}
}
Expand Down
59 changes: 59 additions & 0 deletions apis/eventing/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "CloudEventSource")
os.Exit(1)
}
if err = (eventingcontrollers.NewClusterCloudEventSourceReconciler(
mgr.GetClient(),
eventEmitter,
)).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterCloudEventSource")
os.Exit(1)
}
//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions cmd/webhooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,8 @@ func setupWebhook(mgr manager.Manager) {
setupLog.Error(err, "unable to create webhook", "webhook", "CloudEventSource")
os.Exit(1)
}
if err := (&eventingv1alpha1.ClusterCloudEventSource{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "ClusterCloudEventSource")
os.Exit(1)
}
}
Loading

0 comments on commit 2c2cec2

Please sign in to comment.