diff --git a/assets/swagger.json b/assets/swagger.json index b7f0cdefabe1c..178097ab8e204 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -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": [ diff --git a/pkg/apiclient/applicationset/applicationset.pb.go b/pkg/apiclient/applicationset/applicationset.pb.go index 8f717d1f6920f..818e4b4411ab4 100644 --- a/pkg/apiclient/applicationset/applicationset.pb.go +++ b/pkg/apiclient/applicationset/applicationset.pb.go @@ -17,6 +17,7 @@ import ( codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" io "io" + v1 "k8s.io/api/core/v1" math "math" math_bits "math/bits" ) @@ -156,6 +157,62 @@ func (m *ApplicationSetListQuery) GetAppsetNamespace() string { return "" } +// ApplicationSetEventsQuery is a query for applicationset resource events +type ApplicationSetResourceEventsQuery struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + AppsetNamespace string `protobuf:"bytes,5,opt,name=appsetNamespace,proto3" json:"appsetNamespace,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ApplicationSetResourceEventsQuery) Reset() { *m = ApplicationSetResourceEventsQuery{} } +func (m *ApplicationSetResourceEventsQuery) String() string { return proto.CompactTextString(m) } +func (*ApplicationSetResourceEventsQuery) ProtoMessage() {} +func (*ApplicationSetResourceEventsQuery) Descriptor() ([]byte, []int) { + return fileDescriptor_eacb9df0ce5738fa, []int{2} +} +func (m *ApplicationSetResourceEventsQuery) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ApplicationSetResourceEventsQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ApplicationSetResourceEventsQuery.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ApplicationSetResourceEventsQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApplicationSetResourceEventsQuery.Merge(m, src) +} +func (m *ApplicationSetResourceEventsQuery) XXX_Size() int { + return m.Size() +} +func (m *ApplicationSetResourceEventsQuery) XXX_DiscardUnknown() { + xxx_messageInfo_ApplicationSetResourceEventsQuery.DiscardUnknown(m) +} + +var xxx_messageInfo_ApplicationSetResourceEventsQuery proto.InternalMessageInfo + +func (m *ApplicationSetResourceEventsQuery) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *ApplicationSetResourceEventsQuery) GetAppsetNamespace() string { + if m != nil { + return m.AppsetNamespace + } + return "" +} + type ApplicationSetResponse struct { Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` Applicationset *v1alpha1.ApplicationSet `protobuf:"bytes,2,opt,name=applicationset,proto3" json:"applicationset,omitempty"` @@ -168,7 +225,7 @@ func (m *ApplicationSetResponse) Reset() { *m = ApplicationSetResponse{} func (m *ApplicationSetResponse) String() string { return proto.CompactTextString(m) } func (*ApplicationSetResponse) ProtoMessage() {} func (*ApplicationSetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_eacb9df0ce5738fa, []int{2} + return fileDescriptor_eacb9df0ce5738fa, []int{3} } func (m *ApplicationSetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -223,7 +280,7 @@ func (m *ApplicationSetCreateRequest) Reset() { *m = ApplicationSetCreat func (m *ApplicationSetCreateRequest) String() string { return proto.CompactTextString(m) } func (*ApplicationSetCreateRequest) ProtoMessage() {} func (*ApplicationSetCreateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_eacb9df0ce5738fa, []int{3} + return fileDescriptor_eacb9df0ce5738fa, []int{4} } func (m *ApplicationSetCreateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,7 +336,7 @@ func (m *ApplicationSetDeleteRequest) Reset() { *m = ApplicationSetDelet func (m *ApplicationSetDeleteRequest) String() string { return proto.CompactTextString(m) } func (*ApplicationSetDeleteRequest) ProtoMessage() {} func (*ApplicationSetDeleteRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_eacb9df0ce5738fa, []int{4} + return fileDescriptor_eacb9df0ce5738fa, []int{5} } func (m *ApplicationSetDeleteRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -325,6 +382,7 @@ func (m *ApplicationSetDeleteRequest) GetAppsetNamespace() string { func init() { proto.RegisterType((*ApplicationSetGetQuery)(nil), "applicationset.ApplicationSetGetQuery") proto.RegisterType((*ApplicationSetListQuery)(nil), "applicationset.ApplicationSetListQuery") + proto.RegisterType((*ApplicationSetResourceEventsQuery)(nil), "applicationset.ApplicationSetResourceEventsQuery") proto.RegisterType((*ApplicationSetResponse)(nil), "applicationset.ApplicationSetResponse") proto.RegisterType((*ApplicationSetCreateRequest)(nil), "applicationset.ApplicationSetCreateRequest") proto.RegisterType((*ApplicationSetDeleteRequest)(nil), "applicationset.ApplicationSetDeleteRequest") @@ -335,40 +393,45 @@ func init() { } var fileDescriptor_eacb9df0ce5738fa = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xdf, 0x8a, 0x13, 0x31, - 0x14, 0xc6, 0xc9, 0x76, 0xad, 0xbb, 0x11, 0x14, 0x02, 0xee, 0xd6, 0x51, 0x6a, 0x99, 0x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 0xe3, 0x5a, 0x87, 0xb4, 0x6d, - 0x43, 0x66, 0x3d, 0xa7, 0x89, 0x35, 0x3b, 0xce, 0x2f, 0xfa, 0x8e, 0x7c, 0x46, 0x78, 0x3d, 0x77, - 0x39, 0xb9, 0xb1, 0x18, 0x73, 0xda, 0x09, 0xde, 0xd3, 0x55, 0x72, 0xe6, 0x69, 0xfd, 0xeb, 0x96, - 0xf5, 0x0a, 0xd9, 0x3e, 0x85, 0x95, 0x7c, 0x47, 0xb8, 0x59, 0x38, 0x8c, 0xdc, 0x5a, 0x8c, 0x59, - 0xf3, 0xe1, 0x8a, 0x25, 0x65, 0x16, 0xf3, 0xa6, 0x7f, 0x1a, 0xe6, 0x5d, 0xd7, 0x90, 0x1f, 0x10, - 0x6e, 0x16, 0x5e, 0x5b, 0x86, 0x5d, 0x73, 0xa4, 0xb7, 0xc4, 0x31, 0xd5, 0x58, 0xa8, 0xde, 0x78, - 0x77, 0xc9, 0x1b, 0x3f, 0x78, 0xfc, 0x63, 0xd2, 0x46, 0x3f, 0x27, 0x6d, 0xf4, 0x7b, 0xd2, 0x46, - 0x2f, 0xee, 0xfd, 0xdb, 0x28, 0x0e, 0x93, 0x18, 0x52, 0x77, 0xf6, 0x1f, 0x34, 0xed, 0x00, 0xbe, - 0xf3, 0x37, 0x00, 0x00, 0xff, 0xff, 0x96, 0x3f, 0x16, 0xa7, 0x2a, 0x06, 0x00, 0x00, + // 607 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xdf, 0x6a, 0x13, 0x4f, + 0x14, 0xc7, 0x99, 0xb6, 0xbf, 0xfc, 0xda, 0x11, 0x14, 0x06, 0x6c, 0xe3, 0xaa, 0xb1, 0x2e, 0x98, + 0xc6, 0x4a, 0x67, 0x48, 0xbc, 0x11, 0xbd, 0xf2, 0x1f, 0x45, 0x08, 0xa2, 0x5b, 0xf0, 0x42, 0x2f, +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0x00, 0xff, 0xff, 0xb1, 0x98, 0xf7, 0x9c, 0x49, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -387,6 +450,8 @@ type ApplicationSetServiceClient interface { Get(ctx context.Context, in *ApplicationSetGetQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationSet, error) //List returns list of applicationset List(ctx context.Context, in *ApplicationSetListQuery, opts ...grpc.CallOption) (*v1alpha1.ApplicationSetList, error) + // ListResourceEvents returns a list of event resources + ListResourceEvents(ctx context.Context, in *ApplicationSetResourceEventsQuery, opts ...grpc.CallOption) (*v1.EventList, error) //Create creates an applicationset Create(ctx context.Context, in *ApplicationSetCreateRequest, opts ...grpc.CallOption) (*v1alpha1.ApplicationSet, error) // Delete deletes an application set @@ -419,6 +484,15 @@ func (c *applicationSetServiceClient) List(ctx context.Context, in *ApplicationS return out, nil } +func (c *applicationSetServiceClient) ListResourceEvents(ctx context.Context, in *ApplicationSetResourceEventsQuery, opts ...grpc.CallOption) (*v1.EventList, error) { + out := new(v1.EventList) + err := c.cc.Invoke(ctx, "/applicationset.ApplicationSetService/ListResourceEvents", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *applicationSetServiceClient) Create(ctx context.Context, in *ApplicationSetCreateRequest, opts ...grpc.CallOption) (*v1alpha1.ApplicationSet, error) { out := new(v1alpha1.ApplicationSet) err := c.cc.Invoke(ctx, "/applicationset.ApplicationSetService/Create", in, out, opts...) @@ -443,6 +517,8 @@ type ApplicationSetServiceServer interface { Get(context.Context, *ApplicationSetGetQuery) (*v1alpha1.ApplicationSet, error) //List returns list of applicationset List(context.Context, *ApplicationSetListQuery) (*v1alpha1.ApplicationSetList, error) + // ListResourceEvents returns a list of event resources + ListResourceEvents(context.Context, *ApplicationSetResourceEventsQuery) (*v1.EventList, error) //Create creates an applicationset Create(context.Context, *ApplicationSetCreateRequest) (*v1alpha1.ApplicationSet, error) // Delete deletes an application set @@ -459,6 +535,9 @@ func (*UnimplementedApplicationSetServiceServer) Get(ctx context.Context, req *A func (*UnimplementedApplicationSetServiceServer) List(ctx context.Context, req *ApplicationSetListQuery) (*v1alpha1.ApplicationSetList, error) { return nil, status.Errorf(codes.Unimplemented, "method List not implemented") } +func (*UnimplementedApplicationSetServiceServer) ListResourceEvents(ctx context.Context, req *ApplicationSetResourceEventsQuery) (*v1.EventList, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListResourceEvents not implemented") +} func (*UnimplementedApplicationSetServiceServer) Create(ctx context.Context, req *ApplicationSetCreateRequest) (*v1alpha1.ApplicationSet, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } @@ -506,6 +585,24 @@ func _ApplicationSetService_List_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _ApplicationSetService_ListResourceEvents_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplicationSetResourceEventsQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApplicationSetServiceServer).ListResourceEvents(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/applicationset.ApplicationSetService/ListResourceEvents", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApplicationSetServiceServer).ListResourceEvents(ctx, req.(*ApplicationSetResourceEventsQuery)) + } + return interceptor(ctx, in, info, handler) +} + func _ApplicationSetService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ApplicationSetCreateRequest) if err := dec(in); err != nil { @@ -554,6 +651,10 @@ var _ApplicationSetService_serviceDesc = grpc.ServiceDesc{ MethodName: "List", Handler: _ApplicationSetService_List_Handler, }, + { + MethodName: "ListResourceEvents", + Handler: _ApplicationSetService_ListResourceEvents_Handler, + }, { MethodName: "Create", Handler: _ApplicationSetService_Create_Handler, @@ -658,6 +759,47 @@ func (m *ApplicationSetListQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *ApplicationSetResourceEventsQuery) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ApplicationSetResourceEventsQuery) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ApplicationSetResourceEventsQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if len(m.AppsetNamespace) > 0 { + i -= len(m.AppsetNamespace) + copy(dAtA[i:], m.AppsetNamespace) + i = encodeVarintApplicationset(dAtA, i, uint64(len(m.AppsetNamespace))) + i-- + dAtA[i] = 0x2a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintApplicationset(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ApplicationSetResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -851,6 +993,26 @@ func (m *ApplicationSetListQuery) Size() (n int) { return n } +func (m *ApplicationSetResourceEventsQuery) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovApplicationset(uint64(l)) + } + l = len(m.AppsetNamespace) + if l > 0 { + n += 1 + l + sovApplicationset(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *ApplicationSetResponse) Size() (n int) { if m == nil { return 0 @@ -1178,6 +1340,121 @@ func (m *ApplicationSetListQuery) Unmarshal(dAtA []byte) error { } return nil } +func (m *ApplicationSetResourceEventsQuery) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApplicationset + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ApplicationSetResourceEventsQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ApplicationSetResourceEventsQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApplicationset + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApplicationset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApplicationset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppsetNamespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApplicationset + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApplicationset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApplicationset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppsetNamespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApplicationset(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApplicationset + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ApplicationSetResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/pkg/apiclient/applicationset/applicationset.pb.gw.go b/pkg/apiclient/applicationset/applicationset.pb.gw.go index 5e4c73f7add3b..4ae82a36fcd4c 100644 --- a/pkg/apiclient/applicationset/applicationset.pb.gw.go +++ b/pkg/apiclient/applicationset/applicationset.pb.gw.go @@ -141,6 +141,78 @@ func local_request_ApplicationSetService_List_0(ctx context.Context, marshaler r } +var ( + filter_ApplicationSetService_ListResourceEvents_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_ApplicationSetService_ListResourceEvents_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationSetServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ApplicationSetResourceEventsQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApplicationSetService_ListResourceEvents_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListResourceEvents(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_ApplicationSetService_ListResourceEvents_0(ctx context.Context, marshaler runtime.Marshaler, server ApplicationSetServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ApplicationSetResourceEventsQuery + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApplicationSetService_ListResourceEvents_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListResourceEvents(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_ApplicationSetService_Create_0 = &utilities.DoubleArray{Encoding: map[string]int{"applicationset": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -317,6 +389,29 @@ func RegisterApplicationSetServiceHandlerServer(ctx context.Context, mux *runtim }) + mux.Handle("GET", pattern_ApplicationSetService_ListResourceEvents_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ApplicationSetService_ListResourceEvents_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ApplicationSetService_ListResourceEvents_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_ApplicationSetService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -444,6 +539,26 @@ func RegisterApplicationSetServiceHandlerClient(ctx context.Context, mux *runtim }) + mux.Handle("GET", pattern_ApplicationSetService_ListResourceEvents_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ApplicationSetService_ListResourceEvents_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ApplicationSetService_ListResourceEvents_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_ApplicationSetService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -492,6 +607,8 @@ var ( pattern_ApplicationSetService_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "applicationsets"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_ApplicationSetService_ListResourceEvents_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "applicationsets", "name", "events"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_ApplicationSetService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "applicationsets"}, "", runtime.AssumeColonVerbOpt(true))) pattern_ApplicationSetService_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "applicationsets", "name"}, "", runtime.AssumeColonVerbOpt(true))) @@ -502,6 +619,8 @@ var ( forward_ApplicationSetService_List_0 = runtime.ForwardResponseMessage + forward_ApplicationSetService_ListResourceEvents_0 = runtime.ForwardResponseMessage + forward_ApplicationSetService_Create_0 = runtime.ForwardResponseMessage forward_ApplicationSetService_Delete_0 = runtime.ForwardResponseMessage diff --git a/server/applicationset/applicationset.go b/server/applicationset/applicationset.go index d67815bd9a53d..fc3982bcc5d0e 100644 --- a/server/applicationset/applicationset.go +++ b/server/applicationset/applicationset.go @@ -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" @@ -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 @@ -67,6 +69,7 @@ func NewServer( ns: namespace, db: db, enf: enf, + kubeclientset: kubeclientset, appclientset: appclientset, appsetInformer: appsetInformer, appsetLister: appsetLister, @@ -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") diff --git a/server/applicationset/applicationset.proto b/server/applicationset/applicationset.proto index 2a857d41a00ce..49f058b7c7a90 100644 --- a/server/applicationset/applicationset.proto +++ b/server/applicationset/applicationset.proto @@ -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 @@ -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; @@ -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) = { @@ -73,4 +86,4 @@ service ApplicationSetService { option (google.api.http).delete = "/api/v1/applicationsets/{name}"; } -} \ No newline at end of file +} diff --git a/server/applicationset/applicationset_test.go b/server/applicationset/applicationset_test.go index c5a299c85f358..d552f9d5b3813 100644 --- a/server/applicationset/applicationset_test.go +++ b/server/applicationset/applicationset_test.go @@ -51,7 +51,17 @@ func newTestAppSetServer(objects ...runtime.Object) *Server { enf.SetDefaultRole("role:admin") } scopedNamespaces := "" - return newTestAppSetServerWithEnforcerConfigure(f, scopedNamespaces, objects...) + return newTestAppSetServerWithEnforcerConfigure(f, scopedNamespaces, []runtime.Object{}, objects...) +} + +// return an ApplicationServiceServer which returns fake data +func newTestAppSetServerWithKubeObjects(kubeObjects []runtime.Object, objects ...runtime.Object) *Server { + f := func(enf *rbac.Enforcer) { + _ = enf.SetBuiltinPolicy(assets.BuiltinPolicyCSV) + enf.SetDefaultRole("role:admin") + } + scopedNamespaces := "" + return newTestAppSetServerWithEnforcerConfigure(f, scopedNamespaces, kubeObjects, objects...) } // return an ApplicationServiceServer which returns fake data @@ -61,11 +71,11 @@ func newTestNamespacedAppSetServer(objects ...runtime.Object) *Server { enf.SetDefaultRole("role:admin") } scopedNamespaces := "argocd" - return newTestAppSetServerWithEnforcerConfigure(f, scopedNamespaces, objects...) + return newTestAppSetServerWithEnforcerConfigure(f, scopedNamespaces, []runtime.Object{}, objects...) } -func newTestAppSetServerWithEnforcerConfigure(f func(*rbac.Enforcer), namespace string, objects ...runtime.Object) *Server { - kubeclientset := fake.NewSimpleClientset(&v1.ConfigMap{ +func newTestAppSetServerWithEnforcerConfigure(f func(*rbac.Enforcer), namespace string, kubeObjects []runtime.Object, objects ...runtime.Object) *Server { + kubeObjects = append(kubeObjects, &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNamespace, Name: "argocd-cm", @@ -83,6 +93,7 @@ func newTestAppSetServerWithEnforcerConfigure(f func(*rbac.Enforcer), namespace "server.secretkey": []byte("test"), }, }) + kubeclientset := fake.NewSimpleClientset(kubeObjects...) ctx := context.Background() db := db.NewDB(testNamespace, settings.NewSettingsManager(ctx, kubeclientset, testNamespace), kubeclientset) _, err := db.CreateRepository(ctx, fakeRepo()) @@ -474,3 +485,67 @@ func TestUpdateAppSet(t *testing.T) { }) } + +func TestListResourceEventsAppSet(t *testing.T) { + appSet := newTestAppSet(func(appset *appsv1.ApplicationSet) { + appset.Name = "AppSet1" + }) + + event1 := &v1.Event{ + ObjectMeta: metav1.ObjectMeta{ + Name: "event1", + Namespace: testNamespace, + }, + InvolvedObject: v1.ObjectReference{ + Name: appSet.Name, + Namespace: testNamespace, + UID: appSet.UID, + }, + } + + event2 := &v1.Event{ + ObjectMeta: metav1.ObjectMeta{ + Name: "event2", + Namespace: "other-namespace", + }, + InvolvedObject: v1.ObjectReference{ + Name: appSet.Name, + Namespace: "other-namespace", + UID: appSet.UID, + }, + } + + t.Run("List events in default namespace", func(t *testing.T) { + + appSetServer := newTestAppSetServerWithKubeObjects([]runtime.Object{event1, event2}, appSet) + + q := applicationset.ApplicationSetResourceEventsQuery{Name: "AppSet1"} + + res, err := appSetServer.ListResourceEvents(context.Background(), &q) + assert.NoError(t, err) + assert.Len(t, res.Items, 1) + assert.Equal(t, res.Items[0].Message, event1.Message) + }) + + t.Run("List events in named namespace", func(t *testing.T) { + + appSetServer := newTestAppSetServerWithKubeObjects([]runtime.Object{event1, event2}, appSet) + + q := applicationset.ApplicationSetResourceEventsQuery{Name: "AppSet1", AppsetNamespace: testNamespace} + + res, err := appSetServer.ListResourceEvents(context.Background(), &q) + assert.NoError(t, err) + assert.Len(t, res.Items, 1) + assert.Equal(t, res.Items[0].Message, event1.Message) + }) + + t.Run("List events in not allowed namespace", func(t *testing.T) { + + appSetServer := newTestAppSetServerWithKubeObjects([]runtime.Object{event1, event2}, appSet) + + q := applicationset.ApplicationSetResourceEventsQuery{Name: "AppSet1", AppsetNamespace: "NOT-ALLOWED"} + + _, err := appSetServer.ListResourceEvents(context.Background(), &q) + assert.Equal(t, "namespace 'NOT-ALLOWED' is not permitted", err.Error()) + }) +}