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

my changes #9

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
db3f2dd
initial refactoring
reggie-k Sep 29, 2023
5202333
initial linting and fromAppComponents=false
reggie-k Sep 29, 2023
ff93e4c
initial linting and isInvokedFromApp=false
reggie-k Sep 29, 2023
dfd6642
upstream sync
reggie-k Sep 29, 2023
7a282c6
add endpoint
alexymantha Oct 1, 2023
2a4e8ec
typo
alexymantha Oct 1, 2023
0d33770
missing import
alexymantha Oct 1, 2023
57352b4
fix proto3
alexymantha Oct 1, 2023
64f1fc5
Update generated code
alexymantha Oct 2, 2023
1b6aa1f
Merge branch 'master' into appset-resource-events
alexymantha Oct 2, 2023
d2a7e1f
formatting
alexymantha Oct 2, 2023
06d33bb
add tests
alexymantha Oct 2, 2023
22c2e31
fix selector
alexymantha Oct 2, 2023
c6017bd
Merge branch 'argoproj:master' into master
reggie-k Oct 4, 2023
19c5c08
disable delete for AppSets
reggie-k Oct 4, 2023
7441362
Merge branch 'master' into appset-resource-events
alexymantha Oct 6, 2023
58d0f2b
Merge branch 'master' into appset-resource-events
alexymantha Oct 7, 2023
5c22b5a
Merge branch 'master' into appset-resource-events
alexymantha Oct 20, 2023
cca6e2d
Merge branch 'master' into appset-resource-events
alexymantha Nov 5, 2023
edaab01
upstream sync
reggie-k Nov 18, 2023
9e1acf0
regression fix
reggie-k Nov 18, 2023
ad609c6
Merge branch 'master' into appset-resource-events
alexymantha Nov 18, 2023
f7a17a1
fixed formatting
reggie-k Nov 26, 2023
ed3d8ce
fixed formatting
reggie-k Nov 26, 2023
c579e35
cleanup
reggie-k Nov 26, 2023
668bdb5
support appset-resource-tree
reggie-k Nov 26, 2023
c6a167a
atempt to maximize isApp and isInvokedFromAppsCtx
reggie-k Nov 26, 2023
6dd506b
attempt to maximize isApp and isInvokedFromAppsCtx
reggie-k Nov 30, 2023
687b455
attempt to maximize isApp and isInvokedFromAppsCtx
reggie-k Nov 30, 2023
253a432
useContext in some more places and improve dynamicity
reggie-k Dec 2, 2023
35de291
linting fixes in ctx and abstract objects reference
reggie-k Dec 2, 2023
e72c302
linting fixes in ctx and abstract objects reference
reggie-k Dec 2, 2023
38cac5d
attempt to fix the tests
reggie-k Dec 3, 2023
905f93d
attempt to fix the tests
reggie-k Dec 3, 2023
c4ab34e
change how the AppSet health is calculated
reggie-k Dec 3, 2023
c8d09d7
master sync
reggie-k Dec 3, 2023
157a845
fixed AppSet health status bar and added its statuses to css
reggie-k Dec 3, 2023
0169af6
Merge branch 'master' into appset-resource-events
alexymantha Dec 16, 2023
e6f2ed8
preparation for resource tree changes
reggie-k Dec 23, 2023
8fefa8a
preparation for resource tree changes
reggie-k Dec 23, 2023
0ff530e
Merge branch 'master' into appset-resource-events
alexymantha Dec 23, 2023
f514455
Merge branch 'master' into appset-resource-events
alexymantha Jan 3, 2024
d378a8e
master sync
reggie-k Jan 10, 2024
c099054
placate flyout with abstractTree
reggie-k Jan 10, 2024
b7c4835
Merge branch 'appset-resource-events' of https://github.com/alexymant…
reggie-k Jan 10, 2024
54883f3
objectListKind and isListOfApplications Keith changes
reggie-k Mar 6, 2024
88df870
upstream sync
reggie-k Mar 6, 2024
1be8d65
getQuery unified
reggie-k Mar 6, 2024
5ddf36e
remove isInvokedFromAppsPath from utils
reggie-k Mar 14, 2024
2283cd9
remove isInvokedFromAppsPath from utils
reggie-k Mar 14, 2024
4084486
linting
reggie-k Mar 14, 2024
61acd38
my changes
reggie-k Mar 18, 2024
2ddecdf
undo changes
reggie-k Mar 25, 2024
2ccc5ad
new changes
reggie-k Mar 25, 2024
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
36 changes: 36 additions & 0 deletions assets/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,42 @@
}
}
},
"/api/v1/applicationsets/{name}/events": {
"get": {
"tags": [
"ApplicationSetService"
],
"summary": "ListResourceEvents returns a list of event resources",
"operationId": "ApplicationSetService_ListResourceEvents",
"parameters": [
{
"type": "string",
"name": "name",
"in": "path",
"required": true
},
{
"type": "string",
"name": "appsetNamespace",
"in": "query"
}
],
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1EventList"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/runtimeError"
}
}
}
}
},
"/api/v1/certificates": {
"get": {
"tags": [
Expand Down
351 changes: 314 additions & 37 deletions pkg/apiclient/applicationset/applicationset.pb.go

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions pkg/apiclient/applicationset/applicationset.pb.gw.go

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

35 changes: 35 additions & 0 deletions server/applicationset/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
v1 "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/labels"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
Expand All @@ -39,6 +40,7 @@ type Server struct {
ns string
db db.ArgoDB
enf *rbac.Enforcer
kubeclientset kubernetes.Interface
appclientset appclientset.Interface
appsetInformer cache.SharedIndexInformer
appsetLister applisters.ApplicationSetLister
Expand Down Expand Up @@ -67,6 +69,7 @@ func NewServer(
ns: namespace,
db: db,
enf: enf,
kubeclientset: kubeclientset,
appclientset: appclientset,
appsetInformer: appsetInformer,
appsetLister: appsetLister,
Expand Down Expand Up @@ -280,6 +283,38 @@ func (s *Server) Delete(ctx context.Context, q *applicationset.ApplicationSetDel

}

// ListResourceEvents returns a list of event resources
func (s *Server) ListResourceEvents(ctx context.Context, q *applicationset.ApplicationSetResourceEventsQuery) (*v1.EventList, error) {
namespace := s.appsetNamespaceOrDefault(q.AppsetNamespace)

if !s.isNamespaceEnabled(namespace) {
return nil, security.NamespaceNotPermittedError(namespace)
}

a, err := s.appclientset.ArgoprojV1alpha1().ApplicationSets(namespace).Get(ctx, q.Name, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("error getting ApplicationSet: %w", err)
}

if err = s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceApplicationSets, rbacpolicy.ActionGet, a.RBACName(s.ns)); err != nil {
return nil, err
}

fieldSelector := fields.SelectorFromSet(map[string]string{
"involvedObject.name": a.Name,
"involvedObject.uid": string(a.UID),
"involvedObject.namespace": a.Namespace,
}).String()

log.Infof("Querying for resource events with field selector: %s", fieldSelector)
opts := metav1.ListOptions{FieldSelector: fieldSelector}
list, err := s.kubeclientset.CoreV1().Events(namespace).List(ctx, opts)
if err != nil {
return nil, fmt.Errorf("error listing resource events: %w", err)
}
return list, nil
}

func (s *Server) validateAppSet(ctx context.Context, appset *v1alpha1.ApplicationSet) (string, error) {
if appset == nil {
return "", fmt.Errorf("ApplicationSet cannot be validated for nil value")
Expand Down
15 changes: 14 additions & 1 deletion server/applicationset/applicationset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option go_package = "github.com/argoproj/argo-cd/v2/pkg/apiclient/applicationset
package applicationset;

import "google/api/annotations.proto";
import "k8s.io/api/core/v1/generated.proto";
import "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1/generated.proto";

// ApplicationSetGetQuery is a query for applicationset resources
Expand All @@ -28,6 +29,13 @@ message ApplicationSetListQuery {
}


// ApplicationSetEventsQuery is a query for applicationset resource events
message ApplicationSetResourceEventsQuery {
string name = 1;
string appsetNamespace = 5;
}


message ApplicationSetResponse {
string project = 1;
github.com.argoproj.argo_cd.v2.pkg.apis.application.v1alpha1.ApplicationSet applicationset = 2;
Expand Down Expand Up @@ -60,6 +68,11 @@ service ApplicationSetService {
option (google.api.http).get = "/api/v1/applicationsets";
}

// ListResourceEvents returns a list of event resources
rpc ListResourceEvents(ApplicationSetResourceEventsQuery) returns (k8s.io.api.core.v1.EventList) {
option (google.api.http).get = "/api/v1/applicationsets/{name}/events";
}

//Create creates an applicationset
rpc Create (ApplicationSetCreateRequest) returns (github.com.argoproj.argo_cd.v2.pkg.apis.application.v1alpha1.ApplicationSet) {
option (google.api.http) = {
Expand All @@ -73,4 +86,4 @@ service ApplicationSetService {
option (google.api.http).delete = "/api/v1/applicationsets/{name}";
}

}
}
Loading
Loading