-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Introduce ClusterCloudEventSource #5816
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick skim and think it looks OK but not a go expert. @JorTurFer Can you share your wisdom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick skim and think it looks OK but not a go expert. @JorTurFer Can you share your wisdom?
Co-authored-by: Tom Kerkhove <kerkhove.tom@gmail.com> Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is on the right track, but I would like us to try to reduce the code duplication a bit ideally.
I created a sample PR to communicate my ideas better in #5924, most importantly I think we should explore some options to not copy-paste the reconciler. #5924 discusses one potential way how this might be achievable, ptal
|
||
// Reconcile performs reconciliation on the identified EventSource resource based on the request information passed, returns the result and an error (if any). | ||
// | ||
//nolint:dupl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick diff with CloudEventSourceReconciler
and these two seem to be identical, I was wondering if we could reuse the common code rather than duplicate it.
type CloudEventSourceInterface interface { | ||
GetKind() string | ||
GetName() string | ||
GetNamespace() string | ||
GetSpec() CloudEventSourceSpec | ||
GetStatus() CloudEventSourceStatus | ||
GetGeneration() int64 | ||
GenerateIdentifier() string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can embed client.Object
from controller-runtime to make a good amount of code simpler
type CloudEventSourceInterface interface { | |
GetKind() string | |
GetName() string | |
GetNamespace() string | |
GetSpec() CloudEventSourceSpec | |
GetStatus() CloudEventSourceStatus | |
GetGeneration() int64 | |
GenerateIdentifier() string | |
} | |
type CloudEventSourceInterface interface { | |
client.Object | |
GetSpec() CloudEventSourceSpec | |
GetStatus() CloudEventSourceStatus | |
GenerateIdentifier() string | |
} |
func (cces *ClusterCloudEventSource) GetKind() string { | ||
return cces.Kind | ||
} | ||
|
||
func (cces *ClusterCloudEventSource) GetName() string { | ||
return cces.Name | ||
} | ||
|
||
func (cces *ClusterCloudEventSource) GetNamespace() string { | ||
return cces.Namespace | ||
} | ||
|
||
func (cces *ClusterCloudEventSource) GetSpec() CloudEventSourceSpec { | ||
return cces.Spec | ||
} | ||
|
||
func (cces *ClusterCloudEventSource) GetStatus() CloudEventSourceStatus { | ||
return *cces.Status.DeepCopy() | ||
} | ||
|
||
func (cces *ClusterCloudEventSource) GetGeneration() int64 { | ||
return cces.Generation | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which would also make many of these not necessary
func (cces *ClusterCloudEventSource) GetKind() string { | |
return cces.Kind | |
} | |
func (cces *ClusterCloudEventSource) GetName() string { | |
return cces.Name | |
} | |
func (cces *ClusterCloudEventSource) GetNamespace() string { | |
return cces.Namespace | |
} | |
func (cces *ClusterCloudEventSource) GetSpec() CloudEventSourceSpec { | |
return cces.Spec | |
} | |
func (cces *ClusterCloudEventSource) GetStatus() CloudEventSourceStatus { | |
return *cces.Status.DeepCopy() | |
} | |
func (cces *ClusterCloudEventSource) GetGeneration() int64 { | |
return cces.Generation | |
} | |
func (cces *ClusterCloudEventSource) GetSpec() CloudEventSourceSpec { | |
return cces.Spec | |
} | |
func (cces *ClusterCloudEventSource) GetStatus() CloudEventSourceStatus { | |
return *cces.Status.DeepCopy() | |
} |
if err = (eventingcontrollers.NewClusterCloudEventSourceReconciler( | ||
mgr.GetClient(), | ||
eventEmitter, | ||
)).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", "ClusterCloudEventSource") | ||
os.Exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be worthwhile to explore having one just controller with Watch
on both cluster and namespaced version of the CloudEventSource
Thanks @wozniakjan, I think triggerauthentication & clustertriggerauthentication can be refactor as well. |
That is a good point, I will try to find some time later this month to check for any code duplication candidates for TA and CTA |
Introduce ClusterCloudEventSource
Checklist
Relates to #3533