Skip to content

fix: allow gitlab eventsource to work without projects or groups #3508

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

Merged
merged 3 commits into from
Mar 18, 2025
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 api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2087,7 +2087,7 @@
"type": "string"
},
"projects": {
"description": "List of project IDs or project namespace paths like \"whynowy/test\". Projects and groups cannot be empty at the same time.",
"description": "List of project IDs or project namespace paths like \"whynowy/test\". If neither a project nor a group is defined, the EventSource will not manage webhooks.",
"items": {
"type": "string"
},
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

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

5 changes: 3 additions & 2 deletions docs/APIs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10099,8 +10099,9 @@ event payload.
<em>(Optional)</em>
<p>

List of project IDs or project namespace paths like “whynowy/test”.
Projects and groups cannot be empty at the same time.
List of project IDs or project namespace paths like “whynowy/test”. If
neither a project nor a group is defined, the EventSource will not
manage webhooks.
</p>

</td>
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/events/v1alpha1/eventsource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ type GitlabEventSource struct {
// Metadata holds the user defined metadata which will passed along the event payload.
// +optional
Metadata map[string]string `json:"metadata,omitempty" protobuf:"bytes,9,rep,name=metadata"`
// List of project IDs or project namespace paths like "whynowy/test". Projects and groups cannot be empty at the same time.
// List of project IDs or project namespace paths like "whynowy/test".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that not defining a group or project means the event source will not manage webhooks?

// If neither a project nor a group is defined, the EventSource will not manage webhooks.
// +optional
Projects []string `json:"projects,omitempty" protobuf:"bytes,10,rep,name=projects"`
// SecretToken references to k8 secret which holds the Secret Token used by webhook config
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/events/v1alpha1/generated.proto

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

2 changes: 1 addition & 1 deletion pkg/apis/events/v1alpha1/openapi_generated.go

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

3 changes: 0 additions & 3 deletions pkg/eventsources/sources/gitlab/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ func validate(eventSource *v1alpha1.GitlabEventSource) error {
if eventSource == nil {
return v1alpha1.ErrNilEventSource
}
if len(eventSource.GetProjects()) == 0 && len(eventSource.GetGroups()) == 0 {
return fmt.Errorf("projects and groups cannot be empty at the same time")
}
if eventSource.Events == nil {
return fmt.Errorf("events can't be empty")
}
Expand Down
1 change: 0 additions & 1 deletion pkg/eventsources/sources/gitlab/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestValidateEventSource(t *testing.T) {

err := listener.ValidateEventSource(context.Background())
assert.Error(t, err)
assert.Equal(t, "projects and groups cannot be empty at the same time", err.Error())

content, err := os.ReadFile(fmt.Sprintf("%s/%s", sources.EventSourceDir, "gitlab.yaml"))
assert.Nil(t, err)
Expand Down
Loading