Skip to content

Commit f724215

Browse files
authored
fix: allow gitlab eventsource to work without projects or groups (#3508)
Signed-off-by: Priscillesg <[email protected]>
1 parent 3dd723f commit f724215

File tree

8 files changed

+10
-11
lines changed

8 files changed

+10
-11
lines changed

api/jsonschema/schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@
20872087
"type": "string"
20882088
},
20892089
"projects": {
2090-
"description": "List of project IDs or project namespace paths like \"whynowy/test\". Projects and groups cannot be empty at the same time.",
2090+
"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.",
20912091
"items": {
20922092
"type": "string"
20932093
},

api/openapi-spec/swagger.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/APIs.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -10099,8 +10099,9 @@ event payload.
1009910099
<em>(Optional)</em>
1010010100
<p>
1010110101

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

1010610107
</td>

pkg/apis/events/v1alpha1/eventsource_types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,8 @@ type GitlabEventSource struct {
858858
// Metadata holds the user defined metadata which will passed along the event payload.
859859
// +optional
860860
Metadata map[string]string `json:"metadata,omitempty" protobuf:"bytes,9,rep,name=metadata"`
861-
// List of project IDs or project namespace paths like "whynowy/test". Projects and groups cannot be empty at the same time.
861+
// List of project IDs or project namespace paths like "whynowy/test".
862+
// If neither a project nor a group is defined, the EventSource will not manage webhooks.
862863
// +optional
863864
Projects []string `json:"projects,omitempty" protobuf:"bytes,10,rep,name=projects"`
864865
// SecretToken references to k8 secret which holds the Secret Token used by webhook config

pkg/apis/events/v1alpha1/generated.proto

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/events/v1alpha1/openapi_generated.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/eventsources/sources/gitlab/validate.go

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ func validate(eventSource *v1alpha1.GitlabEventSource) error {
3030
if eventSource == nil {
3131
return v1alpha1.ErrNilEventSource
3232
}
33-
if len(eventSource.GetProjects()) == 0 && len(eventSource.GetGroups()) == 0 {
34-
return fmt.Errorf("projects and groups cannot be empty at the same time")
35-
}
3633
if eventSource.Events == nil {
3734
return fmt.Errorf("events can't be empty")
3835
}

pkg/eventsources/sources/gitlab/validate_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func TestValidateEventSource(t *testing.T) {
3434

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

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

0 commit comments

Comments
 (0)