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

Introduce ClusterCloudEventSource #5816

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

SpiritZhou
Copy link
Contributor

@SpiritZhou SpiritZhou commented May 21, 2024

Introduce ClusterCloudEventSource

Checklist

Relates to #3533

Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
@SpiritZhou SpiritZhou requested a review from a team as a code owner May 21, 2024 06:11
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
Signed-off-by: SpiritZhou <iammrzhouzhenghan@gmail.com>
Copy link
Member

@tomkerkhove tomkerkhove left a 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?

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@tomkerkhove tomkerkhove left a 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>
Copy link
Member

@wozniakjan wozniakjan left a 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
Copy link
Member

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.

Comment on lines +26 to +34
type CloudEventSourceInterface interface {
GetKind() string
GetName() string
GetNamespace() string
GetSpec() CloudEventSourceSpec
GetStatus() CloudEventSourceStatus
GetGeneration() int64
GenerateIdentifier() string
}
Copy link
Member

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

Suggested change
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
}

Comment on lines +161 to +183
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
}
Copy link
Member

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

Suggested change
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()
}

Comment on lines +268 to +274
if err = (eventingcontrollers.NewClusterCloudEventSourceReconciler(
mgr.GetClient(),
eventEmitter,
)).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterCloudEventSource")
os.Exit(1)
}
Copy link
Member

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

@SpiritZhou
Copy link
Contributor Author

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

Thanks @wozniakjan, I think triggerauthentication & clustertriggerauthentication can be refactor as well.

@wozniakjan
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants