From 17b32f9cbbbfe6794ed045e0207498fcaa1c6249 Mon Sep 17 00:00:00 2001 From: John Cai Date: Mon, 14 Oct 2019 11:30:15 -0700 Subject: Add Hook rpc and methods --- changelogs/unreleased/jc-add-hook-rpc-methods.yml | 5 + proto/go/gitalypb/hook.pb.go | 572 ++++++++++++++++++++++ proto/go/gitalypb/protolist.go | 1 + proto/hook.proto | 67 +++ ruby/proto/gitaly.rb | 2 + ruby/proto/gitaly/hook_pb.rb | 50 ++ ruby/proto/gitaly/hook_services_pb.rb | 24 + 7 files changed, 721 insertions(+) create mode 100644 changelogs/unreleased/jc-add-hook-rpc-methods.yml create mode 100644 proto/go/gitalypb/hook.pb.go create mode 100644 proto/hook.proto create mode 100644 ruby/proto/gitaly/hook_pb.rb create mode 100644 ruby/proto/gitaly/hook_services_pb.rb diff --git a/changelogs/unreleased/jc-add-hook-rpc-methods.yml b/changelogs/unreleased/jc-add-hook-rpc-methods.yml new file mode 100644 index 000000000..e9723daf2 --- /dev/null +++ b/changelogs/unreleased/jc-add-hook-rpc-methods.yml @@ -0,0 +1,5 @@ +--- +title: Add HookService RPCs and methods +merge_request: 1553 +author: +type: other diff --git a/proto/go/gitalypb/hook.pb.go b/proto/go/gitalypb/hook.pb.go new file mode 100644 index 000000000..d0ce04f17 --- /dev/null +++ b/proto/go/gitalypb/hook.pb.go @@ -0,0 +1,572 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: hook.proto + +package gitalypb + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// 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.ProtoPackageIsVersion3 // please upgrade the proto package + +type PreReceiveHookRequest struct { + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + KeyId string `protobuf:"bytes,2,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + Protocol string `protobuf:"bytes,3,opt,name=protocol,proto3" json:"protocol,omitempty"` + Stdin []byte `protobuf:"bytes,4,opt,name=stdin,proto3" json:"stdin,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PreReceiveHookRequest) Reset() { *m = PreReceiveHookRequest{} } +func (m *PreReceiveHookRequest) String() string { return proto.CompactTextString(m) } +func (*PreReceiveHookRequest) ProtoMessage() {} +func (*PreReceiveHookRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{0} +} + +func (m *PreReceiveHookRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PreReceiveHookRequest.Unmarshal(m, b) +} +func (m *PreReceiveHookRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PreReceiveHookRequest.Marshal(b, m, deterministic) +} +func (m *PreReceiveHookRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PreReceiveHookRequest.Merge(m, src) +} +func (m *PreReceiveHookRequest) XXX_Size() int { + return xxx_messageInfo_PreReceiveHookRequest.Size(m) +} +func (m *PreReceiveHookRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PreReceiveHookRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PreReceiveHookRequest proto.InternalMessageInfo + +func (m *PreReceiveHookRequest) GetRepository() *Repository { + if m != nil { + return m.Repository + } + return nil +} + +func (m *PreReceiveHookRequest) GetKeyId() string { + if m != nil { + return m.KeyId + } + return "" +} + +func (m *PreReceiveHookRequest) GetProtocol() string { + if m != nil { + return m.Protocol + } + return "" +} + +func (m *PreReceiveHookRequest) GetStdin() []byte { + if m != nil { + return m.Stdin + } + return nil +} + +type PreReceiveHookResponse struct { + Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` + Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PreReceiveHookResponse) Reset() { *m = PreReceiveHookResponse{} } +func (m *PreReceiveHookResponse) String() string { return proto.CompactTextString(m) } +func (*PreReceiveHookResponse) ProtoMessage() {} +func (*PreReceiveHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{1} +} + +func (m *PreReceiveHookResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PreReceiveHookResponse.Unmarshal(m, b) +} +func (m *PreReceiveHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PreReceiveHookResponse.Marshal(b, m, deterministic) +} +func (m *PreReceiveHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PreReceiveHookResponse.Merge(m, src) +} +func (m *PreReceiveHookResponse) XXX_Size() int { + return xxx_messageInfo_PreReceiveHookResponse.Size(m) +} +func (m *PreReceiveHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PreReceiveHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PreReceiveHookResponse proto.InternalMessageInfo + +func (m *PreReceiveHookResponse) GetStdout() []byte { + if m != nil { + return m.Stdout + } + return nil +} + +func (m *PreReceiveHookResponse) GetStderr() []byte { + if m != nil { + return m.Stderr + } + return nil +} + +func (m *PreReceiveHookResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +type PostReceiveHookRequest struct { + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + KeyId string `protobuf:"bytes,2,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + Stdin []byte `protobuf:"bytes,3,opt,name=stdin,proto3" json:"stdin,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PostReceiveHookRequest) Reset() { *m = PostReceiveHookRequest{} } +func (m *PostReceiveHookRequest) String() string { return proto.CompactTextString(m) } +func (*PostReceiveHookRequest) ProtoMessage() {} +func (*PostReceiveHookRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{2} +} + +func (m *PostReceiveHookRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PostReceiveHookRequest.Unmarshal(m, b) +} +func (m *PostReceiveHookRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PostReceiveHookRequest.Marshal(b, m, deterministic) +} +func (m *PostReceiveHookRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostReceiveHookRequest.Merge(m, src) +} +func (m *PostReceiveHookRequest) XXX_Size() int { + return xxx_messageInfo_PostReceiveHookRequest.Size(m) +} +func (m *PostReceiveHookRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PostReceiveHookRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PostReceiveHookRequest proto.InternalMessageInfo + +func (m *PostReceiveHookRequest) GetRepository() *Repository { + if m != nil { + return m.Repository + } + return nil +} + +func (m *PostReceiveHookRequest) GetKeyId() string { + if m != nil { + return m.KeyId + } + return "" +} + +func (m *PostReceiveHookRequest) GetStdin() []byte { + if m != nil { + return m.Stdin + } + return nil +} + +type PostReceiveHookResponse struct { + Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` + Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PostReceiveHookResponse) Reset() { *m = PostReceiveHookResponse{} } +func (m *PostReceiveHookResponse) String() string { return proto.CompactTextString(m) } +func (*PostReceiveHookResponse) ProtoMessage() {} +func (*PostReceiveHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{3} +} + +func (m *PostReceiveHookResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PostReceiveHookResponse.Unmarshal(m, b) +} +func (m *PostReceiveHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PostReceiveHookResponse.Marshal(b, m, deterministic) +} +func (m *PostReceiveHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PostReceiveHookResponse.Merge(m, src) +} +func (m *PostReceiveHookResponse) XXX_Size() int { + return xxx_messageInfo_PostReceiveHookResponse.Size(m) +} +func (m *PostReceiveHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PostReceiveHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PostReceiveHookResponse proto.InternalMessageInfo + +func (m *PostReceiveHookResponse) GetStdout() []byte { + if m != nil { + return m.Stdout + } + return nil +} + +func (m *PostReceiveHookResponse) GetStderr() []byte { + if m != nil { + return m.Stderr + } + return nil +} + +func (m *PostReceiveHookResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +type UpdateHookRequest struct { + Repository *Repository `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` + KeyId string `protobuf:"bytes,2,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + Ref []byte `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` + OldValue string `protobuf:"bytes,4,opt,name=old_value,json=oldValue,proto3" json:"old_value,omitempty"` + NewValue string `protobuf:"bytes,5,opt,name=new_value,json=newValue,proto3" json:"new_value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateHookRequest) Reset() { *m = UpdateHookRequest{} } +func (m *UpdateHookRequest) String() string { return proto.CompactTextString(m) } +func (*UpdateHookRequest) ProtoMessage() {} +func (*UpdateHookRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{4} +} + +func (m *UpdateHookRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateHookRequest.Unmarshal(m, b) +} +func (m *UpdateHookRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateHookRequest.Marshal(b, m, deterministic) +} +func (m *UpdateHookRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateHookRequest.Merge(m, src) +} +func (m *UpdateHookRequest) XXX_Size() int { + return xxx_messageInfo_UpdateHookRequest.Size(m) +} +func (m *UpdateHookRequest) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateHookRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateHookRequest proto.InternalMessageInfo + +func (m *UpdateHookRequest) GetRepository() *Repository { + if m != nil { + return m.Repository + } + return nil +} + +func (m *UpdateHookRequest) GetKeyId() string { + if m != nil { + return m.KeyId + } + return "" +} + +func (m *UpdateHookRequest) GetRef() []byte { + if m != nil { + return m.Ref + } + return nil +} + +func (m *UpdateHookRequest) GetOldValue() string { + if m != nil { + return m.OldValue + } + return "" +} + +func (m *UpdateHookRequest) GetNewValue() string { + if m != nil { + return m.NewValue + } + return "" +} + +type UpdateHookResponse struct { + Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` + Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateHookResponse) Reset() { *m = UpdateHookResponse{} } +func (m *UpdateHookResponse) String() string { return proto.CompactTextString(m) } +func (*UpdateHookResponse) ProtoMessage() {} +func (*UpdateHookResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3eef30da1c11ee1b, []int{5} +} + +func (m *UpdateHookResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateHookResponse.Unmarshal(m, b) +} +func (m *UpdateHookResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateHookResponse.Marshal(b, m, deterministic) +} +func (m *UpdateHookResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateHookResponse.Merge(m, src) +} +func (m *UpdateHookResponse) XXX_Size() int { + return xxx_messageInfo_UpdateHookResponse.Size(m) +} +func (m *UpdateHookResponse) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateHookResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateHookResponse proto.InternalMessageInfo + +func (m *UpdateHookResponse) GetStdout() []byte { + if m != nil { + return m.Stdout + } + return nil +} + +func (m *UpdateHookResponse) GetStderr() []byte { + if m != nil { + return m.Stderr + } + return nil +} + +func (m *UpdateHookResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +func init() { + proto.RegisterType((*PreReceiveHookRequest)(nil), "gitaly.PreReceiveHookRequest") + proto.RegisterType((*PreReceiveHookResponse)(nil), "gitaly.PreReceiveHookResponse") + proto.RegisterType((*PostReceiveHookRequest)(nil), "gitaly.PostReceiveHookRequest") + proto.RegisterType((*PostReceiveHookResponse)(nil), "gitaly.PostReceiveHookResponse") + proto.RegisterType((*UpdateHookRequest)(nil), "gitaly.UpdateHookRequest") + proto.RegisterType((*UpdateHookResponse)(nil), "gitaly.UpdateHookResponse") +} + +func init() { proto.RegisterFile("hook.proto", fileDescriptor_3eef30da1c11ee1b) } + +var fileDescriptor_3eef30da1c11ee1b = []byte{ + // 415 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,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 0xef, 0xed, 0xab, 0xd3, 0xee, 0x5e, 0x99, 0xa4, 0x51, 0x46, 0xdf, 0x63, 0x7b, 0x7c, + 0x49, 0x72, 0x1d, 0xdb, 0xec, 0xd8, 0x7c, 0xd5, 0x78, 0x4d, 0x3d, 0xae, 0xd3, 0x74, 0x6a, 0x42, + 0x6f, 0xfe, 0x05, 0x00, 0x00, 0xff, 0xff, 0x74, 0x46, 0x6b, 0x70, 0x5f, 0x04, 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 + +// HookServiceClient is the client API for HookService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type HookServiceClient interface { + PreReceiveHook(ctx context.Context, in *PreReceiveHookRequest, opts ...grpc.CallOption) (*PreReceiveHookResponse, error) + PostReceiveHook(ctx context.Context, in *PostReceiveHookRequest, opts ...grpc.CallOption) (*PostReceiveHookResponse, error) + UpdateHook(ctx context.Context, in *UpdateHookRequest, opts ...grpc.CallOption) (*UpdateHookResponse, error) +} + +type hookServiceClient struct { + cc *grpc.ClientConn +} + +func NewHookServiceClient(cc *grpc.ClientConn) HookServiceClient { + return &hookServiceClient{cc} +} + +func (c *hookServiceClient) PreReceiveHook(ctx context.Context, in *PreReceiveHookRequest, opts ...grpc.CallOption) (*PreReceiveHookResponse, error) { + out := new(PreReceiveHookResponse) + err := c.cc.Invoke(ctx, "/gitaly.HookService/PreReceiveHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hookServiceClient) PostReceiveHook(ctx context.Context, in *PostReceiveHookRequest, opts ...grpc.CallOption) (*PostReceiveHookResponse, error) { + out := new(PostReceiveHookResponse) + err := c.cc.Invoke(ctx, "/gitaly.HookService/PostReceiveHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hookServiceClient) UpdateHook(ctx context.Context, in *UpdateHookRequest, opts ...grpc.CallOption) (*UpdateHookResponse, error) { + out := new(UpdateHookResponse) + err := c.cc.Invoke(ctx, "/gitaly.HookService/UpdateHook", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// HookServiceServer is the server API for HookService service. +type HookServiceServer interface { + PreReceiveHook(context.Context, *PreReceiveHookRequest) (*PreReceiveHookResponse, error) + PostReceiveHook(context.Context, *PostReceiveHookRequest) (*PostReceiveHookResponse, error) + UpdateHook(context.Context, *UpdateHookRequest) (*UpdateHookResponse, error) +} + +// UnimplementedHookServiceServer can be embedded to have forward compatible implementations. +type UnimplementedHookServiceServer struct { +} + +func (*UnimplementedHookServiceServer) PreReceiveHook(ctx context.Context, req *PreReceiveHookRequest) (*PreReceiveHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PreReceiveHook not implemented") +} +func (*UnimplementedHookServiceServer) PostReceiveHook(ctx context.Context, req *PostReceiveHookRequest) (*PostReceiveHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PostReceiveHook not implemented") +} +func (*UnimplementedHookServiceServer) UpdateHook(ctx context.Context, req *UpdateHookRequest) (*UpdateHookResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateHook not implemented") +} + +func RegisterHookServiceServer(s *grpc.Server, srv HookServiceServer) { + s.RegisterService(&_HookService_serviceDesc, srv) +} + +func _HookService_PreReceiveHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PreReceiveHookRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HookServiceServer).PreReceiveHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitaly.HookService/PreReceiveHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HookServiceServer).PreReceiveHook(ctx, req.(*PreReceiveHookRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HookService_PostReceiveHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PostReceiveHookRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HookServiceServer).PostReceiveHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitaly.HookService/PostReceiveHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HookServiceServer).PostReceiveHook(ctx, req.(*PostReceiveHookRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HookService_UpdateHook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateHookRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HookServiceServer).UpdateHook(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/gitaly.HookService/UpdateHook", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HookServiceServer).UpdateHook(ctx, req.(*UpdateHookRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _HookService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "gitaly.HookService", + HandlerType: (*HookServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PreReceiveHook", + Handler: _HookService_PreReceiveHook_Handler, + }, + { + MethodName: "PostReceiveHook", + Handler: _HookService_PostReceiveHook_Handler, + }, + { + MethodName: "UpdateHook", + Handler: _HookService_UpdateHook_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "hook.proto", +} diff --git a/proto/go/gitalypb/protolist.go b/proto/go/gitalypb/protolist.go index c85049d62..041d84511 100644 --- a/proto/go/gitalypb/protolist.go +++ b/proto/go/gitalypb/protolist.go @@ -9,6 +9,7 @@ var GitalyProtos = []string{ "commit.proto", "conflicts.proto", "diff.proto", + "hook.proto", "namespace.proto", "objectpool.proto", "operations.proto", diff --git a/proto/hook.proto b/proto/hook.proto new file mode 100644 index 000000000..2410d3b28 --- /dev/null +++ b/proto/hook.proto @@ -0,0 +1,67 @@ +syntax = "proto3"; + +package gitaly; + +option go_package = "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"; + +import "shared.proto"; + +service HookService { + rpc PreReceiveHook(PreReceiveHookRequest) returns (PreReceiveHookResponse) { + option (op_type) = { + op: ACCESSOR + target_repository_field: "1" + }; + } + rpc PostReceiveHook(PostReceiveHookRequest) returns (PostReceiveHookResponse) { + option (op_type) = { + op: ACCESSOR + target_repository_field: "1" + }; + } + rpc UpdateHook(UpdateHookRequest) returns (UpdateHookResponse) { + option (op_type) = { + op: ACCESSOR + target_repository_field: "1" + }; + } +} + +message PreReceiveHookRequest { + Repository repository = 1; + string key_id = 2; + string protocol = 3; + bytes stdin = 4; +} + +message PreReceiveHookResponse{ + bytes stdout = 1; + bytes stderr = 2; + bool success = 3; +} + +message PostReceiveHookRequest { + Repository repository = 1; + string key_id = 2; + bytes stdin = 3; +} + +message PostReceiveHookResponse{ + bytes stdout = 1; + bytes stderr = 2; + bool success = 3; +} + +message UpdateHookRequest { + Repository repository = 1; + string key_id = 2; + bytes ref = 3; + string old_value = 4; + string new_value = 5; +} + +message UpdateHookResponse{ + bytes stdout = 1; + bytes stderr = 2; + bool success = 3; +} diff --git a/ruby/proto/gitaly.rb b/ruby/proto/gitaly.rb index c35bc6e06..d0a179470 100644 --- a/ruby/proto/gitaly.rb +++ b/ruby/proto/gitaly.rb @@ -13,6 +13,8 @@ require 'gitaly/conflicts_services_pb' require 'gitaly/diff_services_pb' +require 'gitaly/hook_services_pb' + require 'gitaly/namespace_services_pb' require 'gitaly/objectpool_services_pb' diff --git a/ruby/proto/gitaly/hook_pb.rb b/ruby/proto/gitaly/hook_pb.rb new file mode 100644 index 000000000..b354bbf98 --- /dev/null +++ b/ruby/proto/gitaly/hook_pb.rb @@ -0,0 +1,50 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: hook.proto + +require 'google/protobuf' + +require 'shared_pb' +Google::Protobuf::DescriptorPool.generated_pool.build do + add_message "gitaly.PreReceiveHookRequest" do + optional :repository, :message, 1, "gitaly.Repository" + optional :key_id, :string, 2 + optional :protocol, :string, 3 + optional :stdin, :bytes, 4 + end + add_message "gitaly.PreReceiveHookResponse" do + optional :stdout, :bytes, 1 + optional :stderr, :bytes, 2 + optional :success, :bool, 3 + end + add_message "gitaly.PostReceiveHookRequest" do + optional :repository, :message, 1, "gitaly.Repository" + optional :key_id, :string, 2 + optional :stdin, :bytes, 3 + end + add_message "gitaly.PostReceiveHookResponse" do + optional :stdout, :bytes, 1 + optional :stderr, :bytes, 2 + optional :success, :bool, 3 + end + add_message "gitaly.UpdateHookRequest" do + optional :repository, :message, 1, "gitaly.Repository" + optional :key_id, :string, 2 + optional :ref, :bytes, 3 + optional :old_value, :string, 4 + optional :new_value, :string, 5 + end + add_message "gitaly.UpdateHookResponse" do + optional :stdout, :bytes, 1 + optional :stderr, :bytes, 2 + optional :success, :bool, 3 + end +end + +module Gitaly + PreReceiveHookRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PreReceiveHookRequest").msgclass + PreReceiveHookResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PreReceiveHookResponse").msgclass + PostReceiveHookRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceiveHookRequest").msgclass + PostReceiveHookResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.PostReceiveHookResponse").msgclass + UpdateHookRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.UpdateHookRequest").msgclass + UpdateHookResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.UpdateHookResponse").msgclass +end diff --git a/ruby/proto/gitaly/hook_services_pb.rb b/ruby/proto/gitaly/hook_services_pb.rb new file mode 100644 index 000000000..a57be1c36 --- /dev/null +++ b/ruby/proto/gitaly/hook_services_pb.rb @@ -0,0 +1,24 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: hook.proto for package 'gitaly' + +require 'grpc' +require 'hook_pb' + +module Gitaly + module HookService + class Service + + include GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'gitaly.HookService' + + rpc :PreReceiveHook, PreReceiveHookRequest, PreReceiveHookResponse + rpc :PostReceiveHook, PostReceiveHookRequest, PostReceiveHookResponse + rpc :UpdateHook, UpdateHookRequest, UpdateHookResponse + end + + Stub = Service.rpc_stub_class + end +end -- cgit v1.2.3