-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Remington Breeze <[email protected]> Signed-off-by: Sunghoon Kang <[email protected]> Co-authored-by: Sunghoon Kang <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,013 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,9 @@ rules: | |
resources: | ||
- events | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- patch | ||
- apiGroups: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"sort" | ||
|
||
"connectrpc.com/connect" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/fields" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
kargoapi "github.com/akuity/kargo/api/v1alpha1" | ||
"github.com/akuity/kargo/internal/kubeclient" | ||
svcv1alpha1 "github.com/akuity/kargo/pkg/api/service/v1alpha1" | ||
) | ||
|
||
func (s *server) ListProjectEvents( | ||
ctx context.Context, | ||
req *connect.Request[svcv1alpha1.ListProjectEventsRequest], | ||
) (*connect.Response[svcv1alpha1.ListProjectEventsResponse], error) { | ||
project := req.Msg.GetProject() | ||
if err := validateFieldNotEmpty("project", project); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := s.validateProjectExists(ctx, project); err != nil { | ||
return nil, err | ||
} | ||
|
||
var eventsList corev1.EventList | ||
if err := s.client.List( | ||
ctx, | ||
&eventsList, | ||
client.InNamespace(req.Msg.GetProject()), | ||
// List Kargo related events only | ||
client.MatchingFieldsSelector{ | ||
Selector: fields.OneTermEqualSelector( | ||
kubeclient.EventsByInvolvedObjectAPIGroupIndexField, | ||
kargoapi.GroupVersion.Group, | ||
), | ||
}, | ||
); err != nil { | ||
return nil, fmt.Errorf("list events: %w", err) | ||
} | ||
|
||
sort.Slice(eventsList.Items, func(i, j int) bool { | ||
return eventsList.Items[i].LastTimestamp.Time.After(eventsList.Items[j].LastTimestamp.Time) | ||
}) | ||
|
||
events := make([]*corev1.Event, len(eventsList.Items)) | ||
for i := range eventsList.Items { | ||
events[i] = &eventsList.Items[i] | ||
} | ||
|
||
return connect.NewResponse(&svcv1alpha1.ListProjectEventsResponse{ | ||
Events: events, | ||
}), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
pkg/api/service/v1alpha1/svcv1alpha1connect/service.connect.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.