From 109517dc83a1109e14ed3eba66652ec44ec4d9d2 Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Fri, 7 Feb 2020 11:09:08 -0800 Subject: [PATCH 1/2] chore: Move info.proto et al to correct package --- server/apiserver/argoserver.go | 5 +- server/info/info.pb.go | 560 --------------------------------- server/info/info.pb.gw.go | 147 --------- server/info/info.proto | 22 -- server/info/info.swagger.json | 41 --- server/info/info_server.go | 12 +- 6 files changed, 11 insertions(+), 776 deletions(-) delete mode 100644 server/info/info.pb.go delete mode 100644 server/info/info.pb.gw.go delete mode 100644 server/info/info.proto delete mode 100644 server/info/info.swagger.json diff --git a/server/apiserver/argoserver.go b/server/apiserver/argoserver.go index 3bfc07914523..1dc0635ed107 100644 --- a/server/apiserver/argoserver.go +++ b/server/apiserver/argoserver.go @@ -24,6 +24,7 @@ import ( "github.com/argoproj/argo/errors" "github.com/argoproj/argo/persist/sqldb" cronworkflowpkg "github.com/argoproj/argo/pkg/apiclient/cronworkflow" + info2 "github.com/argoproj/argo/pkg/apiclient/info" workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow" workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive" workflowtemplatepkg "github.com/argoproj/argo/pkg/apiclient/workflowtemplate" @@ -192,7 +193,7 @@ func (as *argoServer) newGRPCServer(offloadNodeStatusRepo sqldb.OffloadNodeStatu grpcServer := grpc.NewServer(sOpts...) - info.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace)) + info2.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace)) workflowpkg.RegisterWorkflowServiceServer(grpcServer, workflow.NewWorkflowServer(offloadNodeStatusRepo)) workflowtemplatepkg.RegisterWorkflowTemplateServiceServer(grpcServer, workflowtemplate.NewWorkflowTemplateServer()) cronworkflowpkg.RegisterCronWorkflowServiceServer(grpcServer, cronworkflow.NewCronWorkflowServer()) @@ -226,7 +227,7 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe // we use our own Marshaler gwMuxOpts := runtime.WithMarshalerOption(runtime.MIMEWildcard, new(json.JSONMarshaler)) gwmux := runtime.NewServeMux(gwMuxOpts) - mustRegisterGWHandler(info.RegisterInfoServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) + mustRegisterGWHandler(info2.RegisterInfoServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(workflowpkg.RegisterWorkflowServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(workflowtemplatepkg.RegisterWorkflowTemplateServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(cronworkflowpkg.RegisterCronWorkflowServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) diff --git a/server/info/info.pb.go b/server/info/info.pb.go deleted file mode 100644 index 5001edcd3d89..000000000000 --- a/server/info/info.pb.go +++ /dev/null @@ -1,560 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: server/info/info.proto - -package info - -import ( - context "context" - fmt "fmt" - _ "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - _ "k8s.io/api/core/v1" - _ "k8s.io/apimachinery/pkg/apis/meta/v1" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type GetInfoRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetInfoRequest) Reset() { *m = GetInfoRequest{} } -func (m *GetInfoRequest) String() string { return proto.CompactTextString(m) } -func (*GetInfoRequest) ProtoMessage() {} -func (*GetInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bc6e4252b6544a4e, []int{0} -} -func (m *GetInfoRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetInfoRequest.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 *GetInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetInfoRequest.Merge(m, src) -} -func (m *GetInfoRequest) XXX_Size() int { - return m.Size() -} -func (m *GetInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetInfoRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetInfoRequest proto.InternalMessageInfo - -type InfoResponse struct { - ManagedNamespace string `protobuf:"bytes,1,opt,name=managedNamespace,proto3" json:"managedNamespace,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InfoResponse) Reset() { *m = InfoResponse{} } -func (m *InfoResponse) String() string { return proto.CompactTextString(m) } -func (*InfoResponse) ProtoMessage() {} -func (*InfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bc6e4252b6544a4e, []int{1} -} -func (m *InfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InfoResponse.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 *InfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_InfoResponse.Merge(m, src) -} -func (m *InfoResponse) XXX_Size() int { - return m.Size() -} -func (m *InfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_InfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_InfoResponse proto.InternalMessageInfo - -func (m *InfoResponse) GetManagedNamespace() string { - if m != nil { - return m.ManagedNamespace - } - return "" -} - -func init() { - proto.RegisterType((*GetInfoRequest)(nil), "info.GetInfoRequest") - proto.RegisterType((*InfoResponse)(nil), "info.InfoResponse") -} - -func init() { proto.RegisterFile("server/info/info.proto", fileDescriptor_bc6e4252b6544a4e) } - -var fileDescriptor_bc6e4252b6544a4e = []byte{ - // 308 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x4a, 0x03, 0x31, - 0x10, 0x86, 0x59, 0x11, 0xc5, 0x58, 0x4a, 0x09, 0x45, 0xa4, 0x48, 0x91, 0xc5, 0x83, 0x78, 0xd8, - 0xd0, 0xea, 0x41, 0x3c, 0xea, 0x41, 0x7a, 0xf1, 0x50, 0x2f, 0xe2, 0x6d, 0xba, 0x9d, 0xa6, 0xb1, - 0xdd, 0x4c, 0x4c, 0xd2, 0x2d, 0x5e, 0x7d, 0x05, 0x5f, 0xca, 0xa3, 0xe0, 0x0b, 0xc8, 0xe2, 0x83, - 0xc8, 0x66, 0x17, 0x5a, 0xa9, 0x5e, 0xc2, 0xe4, 0xff, 0xf9, 0xe7, 0x4b, 0x66, 0xd8, 0x81, 0x43, - 0x9b, 0xa3, 0x15, 0x4a, 0x4f, 0x28, 0x1c, 0x89, 0xb1, 0xe4, 0x89, 0x6f, 0x97, 0x75, 0xa7, 0x2d, - 0x49, 0x52, 0x10, 0x44, 0x59, 0x55, 0x5e, 0xe7, 0x48, 0x12, 0xc9, 0x39, 0x0a, 0x30, 0x4a, 0x80, - 0xd6, 0xe4, 0xc1, 0x2b, 0xd2, 0xae, 0x76, 0x2f, 0x66, 0x97, 0x2e, 0x51, 0x54, 0xba, 0x19, 0xa4, - 0x53, 0xa5, 0xd1, 0xbe, 0x08, 0x33, 0x93, 0xa5, 0xe0, 0x44, 0x86, 0x1e, 0x44, 0xde, 0x13, 0x12, - 0x35, 0x5a, 0xf0, 0x38, 0xae, 0x53, 0x37, 0x52, 0xf9, 0xe9, 0x62, 0x94, 0xa4, 0x94, 0x09, 0xb0, - 0x01, 0xfa, 0x14, 0x8a, 0x55, 0x74, 0x49, 0x76, 0x36, 0x99, 0xd3, 0x52, 0xe4, 0x3d, 0x98, 0x9b, - 0x29, 0x6c, 0x36, 0x89, 0x57, 0x68, 0x91, 0x92, 0xc5, 0x3f, 0x40, 0x71, 0x8b, 0x35, 0x6f, 0xd1, - 0x0f, 0xf4, 0x84, 0x86, 0xf8, 0xbc, 0x40, 0xe7, 0xe3, 0x2b, 0xd6, 0xa8, 0xae, 0xce, 0x90, 0x76, - 0xc8, 0xcf, 0x58, 0x2b, 0x03, 0x0d, 0x12, 0xc7, 0x77, 0x90, 0xa1, 0x33, 0x90, 0xe2, 0x61, 0x74, - 0x1c, 0x9d, 0xee, 0x0d, 0x37, 0xf4, 0xfe, 0x03, 0xdb, 0x2f, 0xb3, 0xf7, 0x68, 0x73, 0x95, 0x22, - 0x1f, 0xb0, 0xdd, 0xba, 0x39, 0x6f, 0x27, 0x61, 0x9a, 0xbf, 0x59, 0x1d, 0x5e, 0xa9, 0xeb, 0xbc, - 0xb8, 0xfd, 0xfa, 0xf9, 0xfd, 0xb6, 0xd5, 0xe4, 0x8d, 0xf0, 0xee, 0xbc, 0x17, 0xd6, 0x70, 0xdd, - 0x7f, 0x2f, 0xba, 0xd1, 0x47, 0xd1, 0x8d, 0xbe, 0x8a, 0x6e, 0xf4, 0x78, 0xf2, 0xef, 0x78, 0xd6, - 0xf6, 0x37, 0xda, 0x09, 0x5f, 0x3c, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xdc, 0xbc, 0xc6, - 0xd5, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// InfoServiceClient is the client API for InfoService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type InfoServiceClient interface { - GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) -} - -type infoServiceClient struct { - cc *grpc.ClientConn -} - -func NewInfoServiceClient(cc *grpc.ClientConn) InfoServiceClient { - return &infoServiceClient{cc} -} - -func (c *infoServiceClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) { - out := new(InfoResponse) - err := c.cc.Invoke(ctx, "/info.InfoService/GetInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// InfoServiceServer is the server API for InfoService service. -type InfoServiceServer interface { - GetInfo(context.Context, *GetInfoRequest) (*InfoResponse, error) -} - -// UnimplementedInfoServiceServer can be embedded to have forward compatible implementations. -type UnimplementedInfoServiceServer struct { -} - -func (*UnimplementedInfoServiceServer) GetInfo(ctx context.Context, req *GetInfoRequest) (*InfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") -} - -func RegisterInfoServiceServer(s *grpc.Server, srv InfoServiceServer) { - s.RegisterService(&_InfoService_serviceDesc, srv) -} - -func _InfoService_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(InfoServiceServer).GetInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/info.InfoService/GetInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(InfoServiceServer).GetInfo(ctx, req.(*GetInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _InfoService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "info.InfoService", - HandlerType: (*InfoServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetInfo", - Handler: _InfoService_GetInfo_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "server/info/info.proto", -} - -func (m *GetInfoRequest) 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 *GetInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetInfoRequest) 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) - } - return len(dAtA) - i, nil -} - -func (m *InfoResponse) 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 *InfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InfoResponse) 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.ManagedNamespace) > 0 { - i -= len(m.ManagedNamespace) - copy(dAtA[i:], m.ManagedNamespace) - i = encodeVarintInfo(dAtA, i, uint64(len(m.ManagedNamespace))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintInfo(dAtA []byte, offset int, v uint64) int { - offset -= sovInfo(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GetInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ManagedNamespace) - if l > 0 { - n += 1 + l + sovInfo(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovInfo(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozInfo(x uint64) (n int) { - return sovInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GetInfoRequest) 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 ErrIntOverflowInfo - } - 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: GetInfoRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipInfo(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthInfo - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthInfo - } - 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 *InfoResponse) 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 ErrIntOverflowInfo - } - 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: InfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedNamespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowInfo - } - 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 ErrInvalidLengthInfo - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthInfo - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ManagedNamespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipInfo(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthInfo - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthInfo - } - 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 skipInfo(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowInfo - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowInfo - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowInfo - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthInfo - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupInfo - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthInfo - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthInfo = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowInfo = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupInfo = fmt.Errorf("proto: unexpected end of group") -) diff --git a/server/info/info.pb.gw.go b/server/info/info.pb.gw.go deleted file mode 100644 index 3f7eb316976f..000000000000 --- a/server/info/info.pb.gw.go +++ /dev/null @@ -1,147 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: server/info/info.proto - -/* -Package info is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package info - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage - -func request_InfoService_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, client InfoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetInfoRequest - var metadata runtime.ServerMetadata - - msg, err := client.GetInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_InfoService_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, server InfoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq GetInfoRequest - var metadata runtime.ServerMetadata - - msg, err := server.GetInfo(ctx, &protoReq) - return msg, metadata, err - -} - -// RegisterInfoServiceHandlerServer registers the http handlers for service InfoService to "mux". -// UnaryRPC :call InfoServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -func RegisterInfoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InfoServiceServer) error { - - mux.Handle("GET", pattern_InfoService_GetInfo_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.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_InfoService_GetInfo_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_InfoService_GetInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterInfoServiceHandlerFromEndpoint is same as RegisterInfoServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterInfoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterInfoServiceHandler(ctx, mux, conn) -} - -// RegisterInfoServiceHandler registers the http handlers for service InfoService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterInfoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterInfoServiceHandlerClient(ctx, mux, NewInfoServiceClient(conn)) -} - -// RegisterInfoServiceHandlerClient registers the http handlers for service InfoService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InfoServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InfoServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "InfoServiceClient" to call the correct interceptors. -func RegisterInfoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InfoServiceClient) error { - - mux.Handle("GET", pattern_InfoService_GetInfo_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_InfoService_GetInfo_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_InfoService_GetInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_InfoService_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "info"}, "", runtime.AssumeColonVerbOpt(true))) -) - -var ( - forward_InfoService_GetInfo_0 = runtime.ForwardResponseMessage -) diff --git a/server/info/info.proto b/server/info/info.proto deleted file mode 100644 index d2c4afb3f0e0..000000000000 --- a/server/info/info.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; -option go_package = "github.com/argoproj/argo/pkg/apiclient/info"; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; -import "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1/generated.proto"; -import "k8s.io/api/core/v1/generated.proto"; - -package info; - -message GetInfoRequest { -} -message InfoResponse { - string managedNamespace = 1; -} - -service InfoService { - rpc GetInfo (GetInfoRequest) returns (InfoResponse) { - option (google.api.http).get = "/api/v1/info"; - } -} \ No newline at end of file diff --git a/server/info/info.swagger.json b/server/info/info.swagger.json deleted file mode 100644 index d9739808f9d1..000000000000 --- a/server/info/info.swagger.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "server/info/info.proto", - "version": "version not set" - }, - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/api/v1/info": { - "get": { - "operationId": "GetInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/infoInfoResponse" - } - } - }, - "tags": [ - "InfoService" - ] - } - } - }, - "definitions": { - "infoInfoResponse": { - "type": "object", - "properties": { - "managedNamespace": { - "type": "string" - } - } - } - } -} diff --git a/server/info/info_server.go b/server/info/info_server.go index c2ee8c416550..1a4537f99c82 100644 --- a/server/info/info_server.go +++ b/server/info/info_server.go @@ -1,15 +1,19 @@ package info -import "context" +import ( + "context" + + infopkg "github.com/argoproj/argo/pkg/apiclient/info" +) type infoServer struct { managedNamespace string } -func (i *infoServer) GetInfo(context.Context, *GetInfoRequest) (*InfoResponse, error) { - return &InfoResponse{ManagedNamespace: i.managedNamespace}, nil +func (i *infoServer) GetInfo(context.Context, *infopkg.GetInfoRequest) (*infopkg.InfoResponse, error) { + return &infopkg.InfoResponse{ManagedNamespace: i.managedNamespace}, nil } -func NewInfoServer(managedNamespace string) InfoServiceServer { +func NewInfoServer(managedNamespace string) infopkg.InfoServiceServer { return &infoServer{managedNamespace} } From 0b4fb3e231e14d952c0ae3be69605328651e649a Mon Sep 17 00:00:00 2001 From: Alex Collins Date: Fri, 7 Feb 2020 11:11:11 -0800 Subject: [PATCH 2/2] rm info2 --- pkg/apiclient/info/info.pb.go | 560 +++++++++++++++++++++++++++ pkg/apiclient/info/info.pb.gw.go | 147 +++++++ pkg/apiclient/info/info.proto | 22 ++ pkg/apiclient/info/info.swagger.json | 41 ++ server/apiserver/argoserver.go | 6 +- 5 files changed, 773 insertions(+), 3 deletions(-) create mode 100644 pkg/apiclient/info/info.pb.go create mode 100644 pkg/apiclient/info/info.pb.gw.go create mode 100644 pkg/apiclient/info/info.proto create mode 100644 pkg/apiclient/info/info.swagger.json diff --git a/pkg/apiclient/info/info.pb.go b/pkg/apiclient/info/info.pb.go new file mode 100644 index 000000000000..a489eca04b2c --- /dev/null +++ b/pkg/apiclient/info/info.pb.go @@ -0,0 +1,560 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/apiclient/info/info.proto + +package info + +import ( + context "context" + fmt "fmt" + _ "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + _ "k8s.io/api/core/v1" + _ "k8s.io/apimachinery/pkg/apis/meta/v1" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type GetInfoRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetInfoRequest) Reset() { *m = GetInfoRequest{} } +func (m *GetInfoRequest) String() string { return proto.CompactTextString(m) } +func (*GetInfoRequest) ProtoMessage() {} +func (*GetInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_96940c93018255fa, []int{0} +} +func (m *GetInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetInfoRequest.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 *GetInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetInfoRequest.Merge(m, src) +} +func (m *GetInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *GetInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetInfoRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetInfoRequest proto.InternalMessageInfo + +type InfoResponse struct { + ManagedNamespace string `protobuf:"bytes,1,opt,name=managedNamespace,proto3" json:"managedNamespace,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *InfoResponse) Reset() { *m = InfoResponse{} } +func (m *InfoResponse) String() string { return proto.CompactTextString(m) } +func (*InfoResponse) ProtoMessage() {} +func (*InfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_96940c93018255fa, []int{1} +} +func (m *InfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InfoResponse.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 *InfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_InfoResponse.Merge(m, src) +} +func (m *InfoResponse) XXX_Size() int { + return m.Size() +} +func (m *InfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_InfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_InfoResponse proto.InternalMessageInfo + +func (m *InfoResponse) GetManagedNamespace() string { + if m != nil { + return m.ManagedNamespace + } + return "" +} + +func init() { + proto.RegisterType((*GetInfoRequest)(nil), "info.GetInfoRequest") + proto.RegisterType((*InfoResponse)(nil), "info.InfoResponse") +} + +func init() { proto.RegisterFile("pkg/apiclient/info/info.proto", fileDescriptor_96940c93018255fa) } + +var fileDescriptor_96940c93018255fa = []byte{ + // 310 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xc1, 0x4a, 0x03, 0x31, + 0x10, 0x86, 0x59, 0x11, 0xc5, 0xb5, 0x94, 0x12, 0x7a, 0x90, 0xa2, 0x45, 0xf6, 0x24, 0x0a, 0x1b, + 0xaa, 0x1e, 0xd4, 0xa3, 0x1e, 0xa4, 0x17, 0x0f, 0xf5, 0x22, 0xde, 0xa6, 0xe9, 0x34, 0x8d, 0xdd, + 0xcd, 0xc4, 0x24, 0xdd, 0xe2, 0xd5, 0x57, 0xf0, 0xa5, 0x3c, 0x0a, 0xbe, 0x80, 0x14, 0x1f, 0x44, + 0x36, 0xbb, 0xd0, 0x4a, 0x05, 0x2f, 0x61, 0xf2, 0xff, 0xfc, 0xf3, 0x25, 0x33, 0xf1, 0x81, 0x99, + 0x4a, 0x0e, 0x46, 0x89, 0x4c, 0xa1, 0xf6, 0x5c, 0xe9, 0x31, 0x85, 0x23, 0x35, 0x96, 0x3c, 0xb1, + 0xcd, 0xb2, 0xee, 0xb4, 0x25, 0x49, 0x0a, 0x02, 0x2f, 0xab, 0xca, 0xeb, 0xec, 0x4b, 0x22, 0x99, + 0x61, 0x99, 0xe6, 0xa0, 0x35, 0x79, 0xf0, 0x8a, 0xb4, 0xab, 0xdd, 0xf3, 0xe9, 0x85, 0x4b, 0x15, + 0x95, 0x6e, 0x0e, 0x62, 0xa2, 0x34, 0xda, 0x17, 0x5e, 0xc3, 0x1c, 0xcf, 0xd1, 0x03, 0x2f, 0x7a, + 0x5c, 0xa2, 0x46, 0x0b, 0x1e, 0x47, 0x75, 0xea, 0x46, 0x2a, 0x3f, 0x99, 0x0d, 0x53, 0x41, 0x39, + 0x07, 0x1b, 0xa0, 0x4f, 0xa1, 0x58, 0x46, 0xe7, 0x64, 0xa7, 0xe3, 0x8c, 0xe6, 0xbc, 0xe8, 0x41, + 0x66, 0x26, 0xb0, 0xde, 0x24, 0x59, 0xa2, 0xb9, 0x20, 0x8b, 0x7f, 0x80, 0x92, 0x56, 0xdc, 0xbc, + 0x45, 0xdf, 0xd7, 0x63, 0x1a, 0xe0, 0xf3, 0x0c, 0x9d, 0x4f, 0xae, 0xe2, 0x46, 0x75, 0x75, 0x86, + 0xb4, 0x43, 0x76, 0x1c, 0xb7, 0x72, 0xd0, 0x20, 0x71, 0x74, 0x07, 0x39, 0x3a, 0x03, 0x02, 0xf7, + 0xa2, 0xc3, 0xe8, 0x68, 0x67, 0xb0, 0xa6, 0x9f, 0x3e, 0xc4, 0xbb, 0x65, 0xf6, 0x1e, 0x6d, 0xa1, + 0x04, 0xb2, 0x7e, 0xbc, 0x5d, 0x37, 0x67, 0xed, 0x34, 0x4c, 0xf3, 0x37, 0xab, 0xc3, 0x2a, 0x75, + 0x95, 0x97, 0xb4, 0x5f, 0x3f, 0xbf, 0xdf, 0x36, 0x9a, 0xac, 0x11, 0xde, 0x5d, 0xf4, 0xc2, 0x1a, + 0xae, 0x2f, 0xdf, 0x17, 0xdd, 0xe8, 0x63, 0xd1, 0x8d, 0xbe, 0x16, 0xdd, 0xe8, 0xf1, 0xe4, 0xbf, + 0xf1, 0xac, 0xac, 0x71, 0xb8, 0x15, 0x7e, 0x7a, 0xf6, 0x13, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xd8, + 0x9b, 0x1d, 0xe3, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// InfoServiceClient is the client API for InfoService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type InfoServiceClient interface { + GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) +} + +type infoServiceClient struct { + cc *grpc.ClientConn +} + +func NewInfoServiceClient(cc *grpc.ClientConn) InfoServiceClient { + return &infoServiceClient{cc} +} + +func (c *infoServiceClient) GetInfo(ctx context.Context, in *GetInfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) { + out := new(InfoResponse) + err := c.cc.Invoke(ctx, "/info.InfoService/GetInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// InfoServiceServer is the server API for InfoService service. +type InfoServiceServer interface { + GetInfo(context.Context, *GetInfoRequest) (*InfoResponse, error) +} + +// UnimplementedInfoServiceServer can be embedded to have forward compatible implementations. +type UnimplementedInfoServiceServer struct { +} + +func (*UnimplementedInfoServiceServer) GetInfo(ctx context.Context, req *GetInfoRequest) (*InfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInfo not implemented") +} + +func RegisterInfoServiceServer(s *grpc.Server, srv InfoServiceServer) { + s.RegisterService(&_InfoService_serviceDesc, srv) +} + +func _InfoService_GetInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(InfoServiceServer).GetInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/info.InfoService/GetInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(InfoServiceServer).GetInfo(ctx, req.(*GetInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _InfoService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "info.InfoService", + HandlerType: (*InfoServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetInfo", + Handler: _InfoService_GetInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "pkg/apiclient/info/info.proto", +} + +func (m *GetInfoRequest) 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 *GetInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetInfoRequest) 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) + } + return len(dAtA) - i, nil +} + +func (m *InfoResponse) 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 *InfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InfoResponse) 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.ManagedNamespace) > 0 { + i -= len(m.ManagedNamespace) + copy(dAtA[i:], m.ManagedNamespace) + i = encodeVarintInfo(dAtA, i, uint64(len(m.ManagedNamespace))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GetInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *InfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ManagedNamespace) + if l > 0 { + n += 1 + l + sovInfo(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozInfo(x uint64) (n int) { + return sovInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GetInfoRequest) 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 ErrIntOverflowInfo + } + 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: GetInfoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthInfo + } + 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 *InfoResponse) 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 ErrIntOverflowInfo + } + 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: InfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ManagedNamespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowInfo + } + 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 ErrInvalidLengthInfo + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ManagedNamespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthInfo + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthInfo + } + 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 skipInfo(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowInfo + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/apiclient/info/info.pb.gw.go b/pkg/apiclient/info/info.pb.gw.go new file mode 100644 index 000000000000..2ad02e751f98 --- /dev/null +++ b/pkg/apiclient/info/info.pb.gw.go @@ -0,0 +1,147 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: pkg/apiclient/info/info.proto + +/* +Package info is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package info + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +func request_InfoService_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, client InfoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetInfoRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_InfoService_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, server InfoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetInfoRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetInfo(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterInfoServiceHandlerServer registers the http handlers for service InfoService to "mux". +// UnaryRPC :call InfoServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterInfoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InfoServiceServer) error { + + mux.Handle("GET", pattern_InfoService_GetInfo_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_InfoService_GetInfo_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_InfoService_GetInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterInfoServiceHandlerFromEndpoint is same as RegisterInfoServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterInfoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterInfoServiceHandler(ctx, mux, conn) +} + +// RegisterInfoServiceHandler registers the http handlers for service InfoService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterInfoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterInfoServiceHandlerClient(ctx, mux, NewInfoServiceClient(conn)) +} + +// RegisterInfoServiceHandlerClient registers the http handlers for service InfoService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InfoServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InfoServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "InfoServiceClient" to call the correct interceptors. +func RegisterInfoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InfoServiceClient) error { + + mux.Handle("GET", pattern_InfoService_GetInfo_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_InfoService_GetInfo_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_InfoService_GetInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_InfoService_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "info"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_InfoService_GetInfo_0 = runtime.ForwardResponseMessage +) diff --git a/pkg/apiclient/info/info.proto b/pkg/apiclient/info/info.proto new file mode 100644 index 000000000000..d2c4afb3f0e0 --- /dev/null +++ b/pkg/apiclient/info/info.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +option go_package = "github.com/argoproj/argo/pkg/apiclient/info"; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; +import "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1/generated.proto"; +import "k8s.io/api/core/v1/generated.proto"; + +package info; + +message GetInfoRequest { +} +message InfoResponse { + string managedNamespace = 1; +} + +service InfoService { + rpc GetInfo (GetInfoRequest) returns (InfoResponse) { + option (google.api.http).get = "/api/v1/info"; + } +} \ No newline at end of file diff --git a/pkg/apiclient/info/info.swagger.json b/pkg/apiclient/info/info.swagger.json new file mode 100644 index 000000000000..204e463b16e7 --- /dev/null +++ b/pkg/apiclient/info/info.swagger.json @@ -0,0 +1,41 @@ +{ + "swagger": "2.0", + "info": { + "title": "pkg/apiclient/info/info.proto", + "version": "version not set" + }, + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/api/v1/info": { + "get": { + "operationId": "GetInfo", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/infoInfoResponse" + } + } + }, + "tags": [ + "InfoService" + ] + } + } + }, + "definitions": { + "infoInfoResponse": { + "type": "object", + "properties": { + "managedNamespace": { + "type": "string" + } + } + } + } +} diff --git a/server/apiserver/argoserver.go b/server/apiserver/argoserver.go index 1dc0635ed107..540e288a2840 100644 --- a/server/apiserver/argoserver.go +++ b/server/apiserver/argoserver.go @@ -24,7 +24,7 @@ import ( "github.com/argoproj/argo/errors" "github.com/argoproj/argo/persist/sqldb" cronworkflowpkg "github.com/argoproj/argo/pkg/apiclient/cronworkflow" - info2 "github.com/argoproj/argo/pkg/apiclient/info" + infopkg "github.com/argoproj/argo/pkg/apiclient/info" workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow" workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive" workflowtemplatepkg "github.com/argoproj/argo/pkg/apiclient/workflowtemplate" @@ -193,7 +193,7 @@ func (as *argoServer) newGRPCServer(offloadNodeStatusRepo sqldb.OffloadNodeStatu grpcServer := grpc.NewServer(sOpts...) - info2.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace)) + infopkg.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace)) workflowpkg.RegisterWorkflowServiceServer(grpcServer, workflow.NewWorkflowServer(offloadNodeStatusRepo)) workflowtemplatepkg.RegisterWorkflowTemplateServiceServer(grpcServer, workflowtemplate.NewWorkflowTemplateServer()) cronworkflowpkg.RegisterCronWorkflowServiceServer(grpcServer, cronworkflow.NewCronWorkflowServer()) @@ -227,7 +227,7 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe // we use our own Marshaler gwMuxOpts := runtime.WithMarshalerOption(runtime.MIMEWildcard, new(json.JSONMarshaler)) gwmux := runtime.NewServeMux(gwMuxOpts) - mustRegisterGWHandler(info2.RegisterInfoServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) + mustRegisterGWHandler(infopkg.RegisterInfoServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(workflowpkg.RegisterWorkflowServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(workflowtemplatepkg.RegisterWorkflowTemplateServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts) mustRegisterGWHandler(cronworkflowpkg.RegisterCronWorkflowServiceHandlerFromEndpoint, ctx, gwmux, endpoint, dialOpts)