Skip to content
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
8 changes: 4 additions & 4 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewService(gitFactory git.ClientFactory, cache cache.Cache) *Service {
}

// ListDir lists the contents of a GitHub repo
func (s *Service) ListDir(ctx context.Context, q *ListDirRequest) (*ListDirResponse, error) {
func (s *Service) ListDir(ctx context.Context, q *ListDirRequest) (*FileList, error) {
appRepoPath := tempRepoPath(q.Repo.Repo)
s.repoLock.Lock(appRepoPath)
defer s.repoLock.Unlock(appRepoPath)
Expand All @@ -58,7 +58,7 @@ func (s *Service) ListDir(ctx context.Context, q *ListDirRequest) (*ListDirRespo
return nil, err
}
cacheKey := listDirCacheKey(commitSHA, q)
var res ListDirResponse
var res FileList
err = s.cache.Get(cacheKey, &res)
if err == nil {
log.Infof("manifest cache hit: %s", cacheKey)
Expand All @@ -75,8 +75,8 @@ func (s *Service) ListDir(ctx context.Context, q *ListDirRequest) (*ListDirRespo
return nil, err
}

res = ListDirResponse{
Data: lsFiles,
res = FileList{
Items: lsFiles,
}
err = s.cache.Set(&cache.Item{
Key: cacheKey,
Expand Down
126 changes: 63 additions & 63 deletions reposerver/repository/repository.pb.go

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

8 changes: 4 additions & 4 deletions reposerver/repository/repository.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ message ListDirRequest {
string path = 3;
}

// ListDirResponse returns the contents of the repo of a ListDir request
message ListDirResponse {
repeated string data = 1;
// FileList returns the contents of the repo of a ListDir request
message FileList {
repeated string items = 1;
}

// GetFileRequest return
Expand All @@ -59,7 +59,7 @@ service RepositoryService {
}

// ListDir returns the file contents at the specified repo and path
rpc ListDir(ListDirRequest) returns (ListDirResponse) {
rpc ListDir(ListDirRequest) returns (FileList) {
}

// GetFile returns the file contents at the specified repo and path
Expand Down
24 changes: 24 additions & 0 deletions server/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/api/core/v1"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -147,6 +148,29 @@ func (s *Server) Get(ctx context.Context, q *ApplicationQuery) (*appv1.Applicati
return s.appclientset.ArgoprojV1alpha1().Applications(s.ns).Get(*q.Name, metav1.GetOptions{})
}

// ListResourceEvents returns a list of event resources
func (s *Server) ListResourceEvents(ctx context.Context, q *ApplicationResourceEventsQuery) (*v1.EventList, error) {
config, namespace, err := s.getApplicationClusterConfig(*q.AppName)
if err != nil {
return nil, err
}
kubeClientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, err
}

fieldSelector := fields.SelectorFromSet(map[string]string{
"involvedObject.name": *q.ResName,
"involvedObject.uid": *q.ResUid,
"involvedObject.namespace": namespace,
}).String()

log.Infof("Querying for resource events with field selector: %s", fieldSelector)
opts := metav1.ListOptions{FieldSelector: fieldSelector}

return kubeClientset.CoreV1().Events(namespace).List(opts)
}

// Update updates an application
func (s *Server) Update(ctx context.Context, a *appv1.Application) (*appv1.Application, error) {
err := s.validateApp(ctx, &a.Spec)
Expand Down
Loading