From 8c1663894ac834278981d2092d96aae92bc91d8a Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Tue, 27 Feb 2018 21:17:11 -0800 Subject: [PATCH] Implement application watch API --- pkg/apis/application/v1alpha1/generated.pb.go | 347 +++++++++++++----- pkg/apis/application/v1alpha1/generated.proto | 12 + pkg/apis/application/v1alpha1/types.go | 13 + .../v1alpha1/zz_generated.deepcopy.go | 17 + server/application/application.go | 27 ++ server/application/application.pb.go | 125 +++++-- server/application/application.pb.gw.go | 58 +++ server/application/application.proto | 6 + server/application/forwarder_overwrite.go | 21 ++ 9 files changed, 509 insertions(+), 117 deletions(-) create mode 100644 server/application/forwarder_overwrite.go diff --git a/pkg/apis/application/v1alpha1/generated.pb.go b/pkg/apis/application/v1alpha1/generated.pb.go index 8b0d03de4596b..8aeaf87a2eb43 100644 --- a/pkg/apis/application/v1alpha1/generated.pb.go +++ b/pkg/apis/application/v1alpha1/generated.pb.go @@ -13,6 +13,7 @@ ApplicationSource ApplicationSpec ApplicationStatus + ApplicationWatchEvent Cluster ClusterConfig ClusterList @@ -27,6 +28,8 @@ import proto "github.com/gogo/protobuf/proto" import fmt "fmt" import math "math" +import k8s_io_apimachinery_pkg_watch "k8s.io/apimachinery/pkg/watch" + import strings "strings" import reflect "reflect" @@ -63,33 +66,37 @@ func (m *ApplicationStatus) Reset() { *m = ApplicationStatus{ func (*ApplicationStatus) ProtoMessage() {} func (*ApplicationStatus) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{4} } +func (m *ApplicationWatchEvent) Reset() { *m = ApplicationWatchEvent{} } +func (*ApplicationWatchEvent) ProtoMessage() {} +func (*ApplicationWatchEvent) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{5} } + func (m *Cluster) Reset() { *m = Cluster{} } func (*Cluster) ProtoMessage() {} -func (*Cluster) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{5} } +func (*Cluster) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{6} } func (m *ClusterConfig) Reset() { *m = ClusterConfig{} } func (*ClusterConfig) ProtoMessage() {} -func (*ClusterConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{6} } +func (*ClusterConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{7} } func (m *ClusterList) Reset() { *m = ClusterList{} } func (*ClusterList) ProtoMessage() {} -func (*ClusterList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{7} } +func (*ClusterList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{8} } func (m *ComparisonResult) Reset() { *m = ComparisonResult{} } func (*ComparisonResult) ProtoMessage() {} -func (*ComparisonResult) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{8} } +func (*ComparisonResult) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{9} } func (m *Repository) Reset() { *m = Repository{} } func (*Repository) ProtoMessage() {} -func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{9} } +func (*Repository) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{10} } func (m *RepositoryList) Reset() { *m = RepositoryList{} } func (*RepositoryList) ProtoMessage() {} -func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{10} } +func (*RepositoryList) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{11} } func (m *TLSClientConfig) Reset() { *m = TLSClientConfig{} } func (*TLSClientConfig) ProtoMessage() {} -func (*TLSClientConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{11} } +func (*TLSClientConfig) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{12} } func init() { proto.RegisterType((*Application)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application") @@ -97,6 +104,7 @@ func init() { proto.RegisterType((*ApplicationSource)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSource") proto.RegisterType((*ApplicationSpec)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSpec") proto.RegisterType((*ApplicationStatus)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationStatus") + proto.RegisterType((*ApplicationWatchEvent)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationWatchEvent") proto.RegisterType((*Cluster)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Cluster") proto.RegisterType((*ClusterConfig)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ClusterConfig") proto.RegisterType((*ClusterList)(nil), "github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ClusterList") @@ -271,6 +279,36 @@ func (m *ApplicationStatus) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ApplicationWatchEvent) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ApplicationWatchEvent) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintGenerated(dAtA, i, uint64(len(m.Type))) + i += copy(dAtA[i:], m.Type) + dAtA[i] = 0x12 + i++ + i = encodeVarintGenerated(dAtA, i, uint64(m.Application.Size())) + n7, err := m.Application.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n7 + return i, nil +} + func (m *Cluster) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -297,11 +335,11 @@ func (m *Cluster) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintGenerated(dAtA, i, uint64(m.Config.Size())) - n7, err := m.Config.MarshalTo(dAtA[i:]) + n8, err := m.Config.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n7 + i += n8 return i, nil } @@ -335,11 +373,11 @@ func (m *ClusterConfig) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.TLSClientConfig.Size())) - n8, err := m.TLSClientConfig.MarshalTo(dAtA[i:]) + n9, err := m.TLSClientConfig.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n8 + i += n9 return i, nil } @@ -361,11 +399,11 @@ func (m *ClusterList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n9, err := m.ListMeta.MarshalTo(dAtA[i:]) + n10, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n9 + i += n10 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -399,19 +437,19 @@ func (m *ComparisonResult) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedAt.Size())) - n10, err := m.ComparedAt.MarshalTo(dAtA[i:]) + n11, err := m.ComparedAt.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n11 dAtA[i] = 0x12 i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ComparedTo.Size())) - n11, err := m.ComparedTo.MarshalTo(dAtA[i:]) + n12, err := m.ComparedTo.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n12 dAtA[i] = 0x1a i++ i = encodeVarintGenerated(dAtA, i, uint64(len(m.Status))) @@ -501,11 +539,11 @@ func (m *RepositoryList) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size())) - n12, err := m.ListMeta.MarshalTo(dAtA[i:]) + n13, err := m.ListMeta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n13 if len(m.Items) > 0 { for _, msg := range m.Items { dAtA[i] = 0x12 @@ -634,6 +672,16 @@ func (m *ApplicationStatus) Size() (n int) { return n } +func (m *ApplicationWatchEvent) Size() (n int) { + var l int + _ = l + l = len(m.Type) + n += 1 + l + sovGenerated(uint64(l)) + l = m.Application.Size() + n += 1 + l + sovGenerated(uint64(l)) + return n +} + func (m *Cluster) Size() (n int) { var l int _ = l @@ -816,6 +864,17 @@ func (this *ApplicationStatus) String() string { }, "") return s } +func (this *ApplicationWatchEvent) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ApplicationWatchEvent{`, + `Type:` + fmt.Sprintf("%v", this.Type) + `,`, + `Application:` + strings.Replace(strings.Replace(this.Application.String(), "Application", "Application", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} func (this *Cluster) String() string { if this == nil { return "nil" @@ -1489,6 +1548,115 @@ func (m *ApplicationStatus) Unmarshal(dAtA []byte) error { } return nil } +func (m *ApplicationWatchEvent) 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 ErrIntOverflowGenerated + } + 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: ApplicationWatchEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ApplicationWatchEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + 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 ErrInvalidLengthGenerated + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = k8s_io_apimachinery_pkg_watch.EventType(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Application", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenerated + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenerated + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Application.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenerated(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthGenerated + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Cluster) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2681,72 +2849,77 @@ func init() { } var fileDescriptorGenerated = []byte{ - // 1069 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x23, 0x35, - 0x14, 0xef, 0xb4, 0x49, 0x9a, 0x3a, 0xdd, 0xb6, 0x18, 0x09, 0xa2, 0x1e, 0xb2, 0xd5, 0x20, 0x50, - 0x41, 0xec, 0x0c, 0x2d, 0x7f, 0x04, 0x1c, 0x90, 0x3a, 0x69, 0x11, 0x61, 0xcb, 0xb2, 0x72, 0xb2, - 0x17, 0x84, 0x00, 0x77, 0xe2, 0x4e, 0xdc, 0x64, 0xc6, 0x23, 0xdb, 0x13, 0xd4, 0xdb, 0xde, 0x90, - 0x90, 0x90, 0xe0, 0x53, 0x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x43, 0x62, 0x1e, 0x10, 0x89, 0xc8, 0x98, 0x0a, 0xca, 0x22, 0xfd, 0xcc, 0x35, 0xef, 0x05, 0xc3, - 0xb1, 0xd1, 0x2b, 0x69, 0xd1, 0x0c, 0x1a, 0xbe, 0x0a, 0x56, 0x39, 0x89, 0xd9, 0x3d, 0x74, 0xac, - 0x6b, 0x63, 0xcd, 0xdb, 0x34, 0x17, 0x57, 0x51, 0x2a, 0x46, 0x53, 0x3d, 0xdc, 0x01, 0x95, 0x18, - 0xcb, 0x81, 0xce, 0xe9, 0x5a, 0x9e, 0xf7, 0xbb, 0x58, 0x0e, 0x90, 0xd6, 0xc0, 0xb7, 0x41, 0x83, - 0x44, 0x63, 0xca, 0x59, 0x14, 0x92, 0x48, 0x36, 0x2b, 0x1a, 0xf8, 0xbc, 0x01, 0x36, 0x8e, 0x72, - 0x15, 0x2a, 0xe2, 0xec, 0x6f, 0xca, 0x89, 0xeb, 0x4e, 0x4b, 0x48, 0xbf, 0xd0, 0xa4, 0xed, 0xba, - 0x4a, 0x48, 0x73, 0x16, 0x4a, 0x48, 0x9f, 0x91, 0xb1, 0x65, 0xff, 0x38, 0x13, 0x63, 0x5d, 0x58, - 0xf0, 0x07, 0x0b, 0x6c, 0xf9, 0x2c, 0x8c, 0x31, 0xa7, 0x82, 0x45, 0x88, 0x88, 0x64, 0x24, 0x8d, - 0x5b, 0xb7, 0x17, 0x70, 0xab, 0x3d, 0x43, 0xe9, 0x35, 0x8d, 0x57, 0x5b, 0xb3, 0x1a, 0x34, 0x67, - 0xde, 0xfe, 0xc5, 0x02, 0xab, 0xed, 0x51, 0x22, 0x24, 0xe1, 0xf0, 0x15, 0x50, 0x13, 0x84, 0x8f, - 0x09, 0x37, 0xb9, 0xcf, 0x5f, 0xa7, 0xa5, 0xc8, 0x68, 0x55, 0x02, 0x23, 0x1c, 0x12, 0x93, 0xe8, - 0x2c, 0x81, 0x77, 0x70, 0x48, 0x90, 0xd6, 0xc0, 0x18, 0xd4, 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87, 0xe4, 0x5c, 0x03, 0x2b, 0x1a, 0xd8, - 0x50, 0xbf, 0x12, 0xb7, 0x53, 0x11, 0x9a, 0xea, 0xa0, 0x0d, 0x6a, 0x3e, 0xd6, 0xa8, 0xaa, 0x46, - 0x01, 0xbd, 0x19, 0x0e, 0x34, 0xc8, 0x68, 0x3c, 0xe7, 0xe2, 0xb2, 0xb5, 0xf4, 0xe0, 0xb2, 0xb5, - 0xf4, 0xf0, 0xb2, 0xb5, 0x74, 0x7f, 0xd2, 0xb2, 0x2e, 0x26, 0x2d, 0xeb, 0xc1, 0xa4, 0x65, 0x3d, - 0x9c, 0xb4, 0xac, 0xbf, 0x26, 0x2d, 0xeb, 0xfb, 0xbf, 0x5b, 0x4b, 0x9f, 0xd5, 0xa7, 0xb1, 0xfb, - 0x2f, 0x00, 0x00, 0xff, 0xff, 0x29, 0xde, 0x0e, 0x9e, 0xde, 0x0c, 0x00, 0x00, + // 1138 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcf, 0x6f, 0x23, 0xb5, + 0x17, 0xef, 0xb4, 0x69, 0x9a, 0xbe, 0x74, 0xdb, 0x7e, 0xfd, 0x15, 0x10, 0xf5, 0x90, 0x56, 0x83, + 0x80, 0x82, 0xd8, 0x09, 0x2d, 0xbf, 0x39, 0x20, 0x75, 0xd2, 0x22, 0x4a, 0xcb, 0xb2, 0x72, 0xb3, + 0x42, 0x42, 0x08, 0x70, 0x27, 0x6e, 0xe2, 0x26, 0x33, 0x1e, 0xd9, 0x4e, 0x56, 0x3d, 0x20, 0xed, + 0x0d, 0x09, 0x09, 0x09, 0xfe, 0x0a, 0xee, 0x1c, 0xf8, 0x0f, 0x90, 0x7a, 0x5c, 0x09, 0x24, 0x56, + 0x08, 0x55, 0x34, 0x7b, 0xe1, 0x6f, 0xd8, 0x13, 0xb2, 0xc7, 0x99, 0x99, 0x24, 0xaa, 0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24, 0x0d, 0x7a, 0x22, 0x19, 0x98, + 0xa5, 0x4c, 0xed, 0xbe, 0xb5, 0xe3, 0x14, 0x81, 0xb6, 0x01, 0x92, 0xe7, 0xe0, 0x56, 0x96, 0xfc, + 0xb4, 0x40, 0x8f, 0x52, 0x0f, 0xce, 0xa1, 0xd0, 0x26, 0x94, 0x02, 0x2a, 0xd4, 0xae, 0xce, 0x9f, + 0xbe, 0x80, 0x25, 0x7f, 0x49, 0xb3, 0xd7, 0xad, 0x0d, 0xa7, 0x5e, 0xf4, 0x02, 0x2c, 0x74, 0xe8, + 0x99, 0x01, 0x16, 0x0c, 0xb0, 0xac, 0x7f, 0x98, 0x0e, 0x12, 0x13, 0x1e, 0xfa, 0x90, 0x0b, 0xc5, + 0x80, 0x18, 0xd4, 0xbc, 0x41, 0x81, 0x79, 0x19, 0x76, 0x0c, 0xc8, 0x7a, 0x7c, 0xef, 0xfc, 0xb2, + 0x3a, 0x73, 0xff, 0xb2, 0x3a, 0xf3, 0xe0, 0xb2, 0x3a, 0x73, 0x6f, 0x50, 0x75, 0xce, 0x07, 0x55, + 0xe7, 0xfe, 0xa0, 0xea, 0x3c, 0x18, 0x54, 0x9d, 0xbf, 0x06, 0x55, 0xe7, 0xfb, 0x87, 0xd5, 0x99, + 0xcf, 0x4a, 0xc3, 0xdc, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x6f, 0x6a, 0xc7, 0xc4, 0x0d, + 0x00, 0x00, } diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index d2702ebb1a027..6bcdeec0cea0a 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -57,6 +57,18 @@ message ApplicationStatus { optional ComparisonResult comparisonResult = 1; } +// ApplicationWatchEvent contains information about application change. +message ApplicationWatchEvent { + optional string type = 1; + + // Application is: + // * If Type is Added or Modified: the new state of the object. + // * If Type is Deleted: the state of the object immediately before deletion. + // * If Type is Error: *api.Status is recommended; other types may make sense + // depending on context. + optional Application application = 2; +} + // Cluster is the definition of a cluster resource message Cluster { // Server is the API server URL of the Kubernetes cluster diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index 47c44b00146b0..d25b9d88ef1ad 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -2,6 +2,7 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/rest" ) @@ -16,6 +17,18 @@ type Application struct { Status ApplicationStatus `json:"status" protobuf:"bytes,3,opt,name=status"` } +// ApplicationWatchEvent contains information about application change. +type ApplicationWatchEvent struct { + Type watch.EventType `protobuf:"bytes,1,opt,name=type,casttype=k8s.io/apimachinery/pkg/watch.EventType"` + + // Application is: + // * If Type is Added or Modified: the new state of the object. + // * If Type is Deleted: the state of the object immediately before deletion. + // * If Type is Error: *api.Status is recommended; other types may make sense + // depending on context. + Application Application `protobuf:"bytes,2,opt,name=application"` +} + // ApplicationList is list of Application resources // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type ApplicationList struct { diff --git a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go index d4e03438701d0..807d5b4aaa6ad 100644 --- a/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go @@ -119,6 +119,23 @@ func (in *ApplicationStatus) DeepCopy() *ApplicationStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApplicationWatchEvent) DeepCopyInto(out *ApplicationWatchEvent) { + *out = *in + in.Application.DeepCopyInto(&out.Application) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationWatchEvent. +func (in *ApplicationWatchEvent) DeepCopy() *ApplicationWatchEvent { + if in == nil { + return nil + } + out := new(ApplicationWatchEvent) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Cluster) DeepCopyInto(out *Cluster) { *out = *in diff --git a/server/application/application.go b/server/application/application.go index f6f017b62b6bf..2ae031c8914c6 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -3,6 +3,7 @@ package application import ( appv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" appclientset "github.com/argoproj/argo-cd/pkg/client/clientset/versioned" + log "github.com/sirupsen/logrus" "golang.org/x/net/context" apiv1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -56,3 +57,29 @@ func (s *Server) ListPods(ctx context.Context, q *ApplicationQuery) (*apiv1.PodL // TODO: filter by the app label return s.kubeclientset.CoreV1().Pods(s.ns).List(metav1.ListOptions{}) } + +func (s *Server) Watch(q *ApplicationQuery, ws ApplicationService_WatchServer) error { + w, err := s.appclientset.ArgoprojV1alpha1().Applications(s.ns).Watch(metav1.ListOptions{}) + if err != nil { + return err + } + go func() { + for next := range w.ResultChan() { + app := *next.Object.(*appv1.Application) + if q.Name == "" || q.Name == app.Name { + err = ws.Send(&appv1.ApplicationWatchEvent{ + Type: next.Type, + Application: app, + }) + if err != nil { + log.Warnf("Unable to send stream message: %v", err) + } + } + } + }() + select { + case <-ws.Context().Done(): + w.Stop() + } + return nil +} diff --git a/server/application/application.pb.go b/server/application/application.pb.go index 95fa99bcc37b5..06f4c4f7ab77a 100644 --- a/server/application/application.pb.go +++ b/server/application/application.pb.go @@ -84,6 +84,8 @@ const _ = grpc.SupportPackageIsVersion4 type ApplicationServiceClient interface { // List returns list of applications List(ctx context.Context, in *ApplicationQuery, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationList, error) + // Watch returns stream of application change events. + Watch(ctx context.Context, in *ApplicationQuery, opts ...grpc.CallOption) (ApplicationService_WatchClient, error) // Create creates a application Create(ctx context.Context, in *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // Get returns a application by name @@ -113,6 +115,38 @@ func (c *applicationServiceClient) List(ctx context.Context, in *ApplicationQuer return out, nil } +func (c *applicationServiceClient) Watch(ctx context.Context, in *ApplicationQuery, opts ...grpc.CallOption) (ApplicationService_WatchClient, error) { + stream, err := grpc.NewClientStream(ctx, &_ApplicationService_serviceDesc.Streams[0], c.cc, "/application.ApplicationService/Watch", opts...) + if err != nil { + return nil, err + } + x := &applicationServiceWatchClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type ApplicationService_WatchClient interface { + Recv() (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationWatchEvent, error) + grpc.ClientStream +} + +type applicationServiceWatchClient struct { + grpc.ClientStream +} + +func (x *applicationServiceWatchClient) Recv() (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationWatchEvent, error) { + m := new(github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationWatchEvent) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func (c *applicationServiceClient) Create(ctx context.Context, in *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, opts ...grpc.CallOption) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) { out := new(github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application) err := grpc.Invoke(ctx, "/application.ApplicationService/Create", in, out, c.cc, opts...) @@ -163,6 +197,8 @@ func (c *applicationServiceClient) ListPods(ctx context.Context, in *Application type ApplicationServiceServer interface { // List returns list of applications List(context.Context, *ApplicationQuery) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationList, error) + // Watch returns stream of application change events. + Watch(*ApplicationQuery, ApplicationService_WatchServer) error // Create creates a application Create(context.Context, *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application) (*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application, error) // Get returns a application by name @@ -197,6 +233,27 @@ func _ApplicationService_List_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _ApplicationService_Watch_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ApplicationQuery) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ApplicationServiceServer).Watch(m, &applicationServiceWatchServer{stream}) +} + +type ApplicationService_WatchServer interface { + Send(*github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationWatchEvent) error + grpc.ServerStream +} + +type applicationServiceWatchServer struct { + grpc.ServerStream +} + +func (x *applicationServiceWatchServer) Send(m *github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.ApplicationWatchEvent) error { + return x.ServerStream.SendMsg(m) +} + func _ApplicationService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(github_com_argoproj_argo_cd_pkg_apis_application_v1alpha1.Application) if err := dec(in); err != nil { @@ -316,40 +373,48 @@ var _ApplicationService_serviceDesc = grpc.ServiceDesc{ Handler: _ApplicationService_ListPods_Handler, }, }, - Streams: []grpc.StreamDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Watch", + Handler: _ApplicationService_Watch_Handler, + ServerStreams: true, + }, + }, Metadata: "server/application/application.proto", } func init() { proto.RegisterFile("server/application/application.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 442 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xcd, 0xaa, 0x13, 0x31, - 0x14, 0x66, 0xb4, 0x8c, 0x1a, 0x37, 0x12, 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f, 0xb1, 0x45, 0x16, 0x71, 0xe0, 0xa4, 0x13, 0x17, 0x07, 0xa4, 0x4c, 0xc8, - 0x50, 0x72, 0x7f, 0xf1, 0x7d, 0x0f, 0x16, 0xe3, 0xee, 0x0e, 0x30, 0xaa, 0x24, 0x37, 0x2f, 0x1f, - 0x7f, 0x21, 0xbb, 0x22, 0x63, 0x33, 0xd9, 0xc6, 0xa1, 0x8f, 0x87, 0xa7, 0xa7, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x3d, 0x0e, 0x72, 0x71, 0xf6, 0x04, 0x00, 0x00, + // 474 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xcd, 0x6a, 0x14, 0x41, + 0x10, 0xa6, 0x35, 0x2e, 0xb1, 0xbd, 0x48, 0x1b, 0x45, 0x27, 0x09, 0x2e, 0x63, 0x90, 0x18, 0xb0, + 0x3b, 0xab, 0x17, 0xf1, 0xe6, 0x3f, 0x8a, 0x87, 0x35, 0x22, 0x82, 0x17, 0xe9, 0x4c, 0x17, 0xbd, + 0xe3, 0xee, 0x76, 0x37, 0xdd, 0x9d, 0x01, 0x11, 0x2f, 0xbe, 0x80, 0x88, 0x0f, 0xe0, 0x73, 0xf8, + 0x02, 0x82, 0x67, 0x5f, 0xc1, 0x07, 0x91, 0xae, 0x64, 0x48, 0xaf, 0x1b, 0x77, 0x2f, 0x73, 0xf0, + 0x56, 0x54, 0xd5, 0xd4, 0xf7, 0x33, 0x5d, 0x45, 0xb7, 0x02, 0xf8, 0x06, 0xbc, 0x90, 0xce, 0x4d, + 0xea, 0x4a, 0xc6, 0xda, 0x9a, 0x3c, 0xe6, 0xce, 0xdb, 0x68, 0xd9, 0xb9, 0x2c, 0x55, 0xac, 0x69, + 0xab, 0x2d, 0xe6, 0x45, 0x8a, 0x0e, 0x5b, 0x8a, 0x0d, 0x6d, 0xad, 0x9e, 0x80, 0x90, 0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x48, 0x6c, 0x93, 0xad, 0xb7, 0xc4, 0x42, 0xf4, 0x20, 0xa7, 0x33, 0xfc, 0x76, 0x09, + 0xfb, 0x4e, 0x68, 0xef, 0x81, 0x07, 0x19, 0x81, 0x3d, 0xee, 0x86, 0x43, 0xd1, 0xd1, 0x9c, 0xf2, + 0x2a, 0x2a, 0xb8, 0x52, 0x9e, 0x68, 0xed, 0x5d, 0xb2, 0xc3, 0xbe, 0x10, 0x7a, 0xfa, 0x09, 0x2c, + 0xfd, 0xdd, 0x5d, 0xf1, 0x99, 0x73, 0x34, 0xe7, 0x23, 0x3e, 0xa4, 0x07, 0xfb, 0x91, 0xfd, 0x24, + 0xb4, 0xf7, 0xca, 0xa9, 0xff, 0xd1, 0x4f, 0x81, 0xfc, 0x6f, 0x14, 0x5b, 0x27, 0xf3, 0x9f, 0x42, + 0x94, 0x4a, 0x46, 0xc9, 0x51, 0x48, 0xf2, 0xd7, 0xd0, 0xde, 0x43, 0x98, 0x40, 0x84, 0x65, 0x0e, + 0xf7, 0xff, 0x55, 0x6e, 0x37, 0xb6, 0xf5, 0x6e, 0x67, 0xa1, 0x77, 0x8e, 0xae, 0xa6, 0x9d, 0x1a, + 0x5a, 0x15, 0x96, 0x21, 0xae, 0xf3, 0xc3, 0x83, 0x95, 0xa4, 0xf3, 0x74, 0xb0, 0x78, 0x33, 0xe0, + 0x43, 0xab, 0x70, 0x27, 0xb7, 0x11, 0xac, 0x64, 0xfd, 0x05, 0x60, 0xc2, 0x59, 0x15, 0xee, 0xef, + 0xbe, 0xe1, 0x8b, 0x8e, 0xda, 0xfc, 0xed, 0xdd, 0xef, 0xe1, 0x01, 0xbb, 0xfd, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x92, 0x9b, 0x4d, 0x26, 0x98, 0x05, 0x00, 0x00, } diff --git a/server/application/application.pb.gw.go b/server/application/application.pb.gw.go index 4c8a17cf83311..5a7a508687319 100644 --- a/server/application/application.pb.gw.go +++ b/server/application/application.pb.gw.go @@ -46,6 +46,31 @@ func request_ApplicationService_List_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_ApplicationService_Watch_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_ApplicationService_Watch_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationServiceClient, req *http.Request, pathParams map[string]string) (ApplicationService_WatchClient, runtime.ServerMetadata, error) { + var protoReq ApplicationQuery + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ApplicationService_Watch_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + stream, err := client.Watch(ctx, &protoReq) + if err != nil { + return nil, metadata, err + } + header, err := stream.Header() + if err != nil { + return nil, metadata, err + } + metadata.HeaderMD = header + return stream, metadata, nil + +} + func request_ApplicationService_Create_0(ctx context.Context, marshaler runtime.Marshaler, client ApplicationServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq v1alpha1.Application var metadata runtime.ServerMetadata @@ -238,6 +263,35 @@ func RegisterApplicationServiceHandlerClient(ctx context.Context, mux *runtime.S }) + mux.Handle("GET", pattern_ApplicationService_Watch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + 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_ApplicationService_Watch_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_ApplicationService_Watch_0(ctx, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_ApplicationService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -389,6 +443,8 @@ func RegisterApplicationServiceHandlerClient(ctx context.Context, mux *runtime.S var ( pattern_ApplicationService_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "applications"}, "")) + pattern_ApplicationService_Watch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "stream", "applications"}, "")) + pattern_ApplicationService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "applications"}, "")) pattern_ApplicationService_Get_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "applications", "name"}, "")) @@ -403,6 +459,8 @@ var ( var ( forward_ApplicationService_List_0 = runtime.ForwardResponseMessage + forward_ApplicationService_Watch_0 = runtime.ForwardResponseStream + forward_ApplicationService_Create_0 = runtime.ForwardResponseMessage forward_ApplicationService_Get_0 = runtime.ForwardResponseMessage diff --git a/server/application/application.proto b/server/application/application.proto index 2169c5d4de275..ce57d18949d98 100644 --- a/server/application/application.proto +++ b/server/application/application.proto @@ -27,6 +27,12 @@ service ApplicationService { option (google.api.http).get = "/api/v1/applications"; } + // Watch returns stream of application change events. + rpc Watch(ApplicationQuery) returns (stream github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationWatchEvent) { + option (google.api.http).get = "/api/v1/stream/applications"; + } + + // Create creates a application rpc Create(github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application) returns (github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Application) { option (google.api.http) = { diff --git a/server/application/forwarder_overwrite.go b/server/application/forwarder_overwrite.go new file mode 100644 index 0000000000000..1290f72860586 --- /dev/null +++ b/server/application/forwarder_overwrite.go @@ -0,0 +1,21 @@ +package application + +import ( + "net/http" + + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "golang.org/x/net/context" +) + +func init() { + forward_ApplicationService_Watch_0 = func(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, req *http.Request, recv func() (proto.Message, error), opts ...func(context.Context, http.ResponseWriter, proto.Message) error) { + opts = append(opts, func(i context.Context, writer http.ResponseWriter, message proto.Message) error { + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Transfer-Encoding", "chunked") + w.Header().Set("X-Content-Type-Options", "nosniff") + return nil + }) + runtime.ForwardResponseStream(ctx, mux, marshaler, w, req, recv, opts...) + } +}