diff --git a/gen/go/v1/config.pb.go b/gen/go/v1/config.pb.go index 2851999c..45952542 100644 --- a/gen/go/v1/config.pb.go +++ b/gen/go/v1/config.pb.go @@ -526,6 +526,7 @@ type Hook struct { // *Hook_ActionWebhook // *Hook_ActionDiscord // *Hook_ActionGotify + // *Hook_ActionSlack Action isHook_Action `protobuf_oneof:"action"` } @@ -603,6 +604,13 @@ func (x *Hook) GetActionGotify() *Hook_Gotify { return nil } +func (x *Hook) GetActionSlack() *Hook_Slack { + if x, ok := x.GetAction().(*Hook_ActionSlack); ok { + return x.ActionSlack + } + return nil +} + type isHook_Action interface { isHook_Action() } @@ -623,6 +631,10 @@ type Hook_ActionGotify struct { ActionGotify *Hook_Gotify `protobuf:"bytes,103,opt,name=action_gotify,json=actionGotify,proto3,oneof"` } +type Hook_ActionSlack struct { + ActionSlack *Hook_Slack `protobuf:"bytes,104,opt,name=action_slack,json=actionSlack,proto3,oneof"` +} + func (*Hook_ActionCommand) isHook_Action() {} func (*Hook_ActionWebhook) isHook_Action() {} @@ -631,6 +643,8 @@ func (*Hook_ActionDiscord) isHook_Action() {} func (*Hook_ActionGotify) isHook_Action() {} +func (*Hook_ActionSlack) isHook_Action() {} + type Auth struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -973,6 +987,61 @@ func (x *Hook_Gotify) GetTitleTemplate() string { return "" } +type Hook_Slack struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + WebhookUrl string `protobuf:"bytes,1,opt,name=webhook_url,json=webhookUrl,proto3" json:"webhook_url,omitempty"` + Template string `protobuf:"bytes,2,opt,name=template,proto3" json:"template,omitempty"` // template for the webhook payload. +} + +func (x *Hook_Slack) Reset() { + *x = Hook_Slack{} + if protoimpl.UnsafeEnabled { + mi := &file_v1_config_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Hook_Slack) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Hook_Slack) ProtoMessage() {} + +func (x *Hook_Slack) ProtoReflect() protoreflect.Message { + mi := &file_v1_config_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Hook_Slack.ProtoReflect.Descriptor instead. +func (*Hook_Slack) Descriptor() ([]byte, []int) { + return file_v1_config_proto_rawDescGZIP(), []int{5, 4} +} + +func (x *Hook_Slack) GetWebhookUrl() string { + if x != nil { + return x.WebhookUrl + } + return "" +} + +func (x *Hook_Slack) GetTemplate() string { + if x != nil { + return x.Template + } + return "" +} + var File_v1_config_proto protoreflect.FileDescriptor var file_v1_config_proto_rawDesc = []byte{ @@ -1039,7 +1108,7 @@ var file_v1_config_proto_rawDesc = []byte{ 0x52, 0x10, 0x6d, 0x61, 0x78, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x5f, 0x75, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x65, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x6d, 0x61, - 0x78, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0xda, 0x05, 0x0a, + 0x78, 0x55, 0x6e, 0x75, 0x73, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0xd5, 0x06, 0x0a, 0x04, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x32, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x6f, 0x6f, 0x6b, 0x2e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, @@ -1058,45 +1127,53 @@ var file_v1_config_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x67, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x6f, 0x6f, 0x6b, 0x2e, 0x47, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x48, 0x00, 0x52, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x6f, 0x74, 0x69, - 0x66, 0x79, 0x1a, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x2a, 0x0a, 0x07, 0x57, 0x65, 0x62, 0x68, 0x6f, - 0x6f, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x75, 0x72, - 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, - 0x55, 0x72, 0x6c, 0x1a, 0x46, 0x0a, 0x07, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x1f, - 0x0a, 0x0b, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x72, 0x6c, 0x12, - 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x1a, 0x7c, 0x0a, 0x06, 0x47, - 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x75, 0x72, - 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x61, 0x73, 0x65, 0x55, 0x72, 0x6c, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x5f, 0x74, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x18, 0x65, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x69, 0x74, 0x6c, - 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x43, 0x6f, - 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4e, 0x44, 0x49, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x17, - 0x0a, 0x13, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x4e, 0x59, 0x5f, - 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x4e, 0x44, 0x49, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x53, 0x54, - 0x41, 0x52, 0x54, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x45, 0x4e, 0x44, 0x10, - 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, - 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, 0x42, - 0x08, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x26, 0x0a, 0x04, 0x41, 0x75, 0x74, - 0x68, 0x12, 0x1e, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x08, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, - 0x73, 0x22, 0x51, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, - 0x0f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x62, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x42, 0x63, 0x72, 0x79, 0x70, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x72, 0x65, 0x74, 0x68, 0x67, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x2f, - 0x62, 0x61, 0x63, 0x6b, 0x72, 0x65, 0x73, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, - 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x66, 0x79, 0x12, 0x33, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6c, 0x61, + 0x63, 0x6b, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x6f, + 0x6f, 0x6b, 0x2e, 0x53, 0x6c, 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x53, 0x6c, 0x61, 0x63, 0x6b, 0x1a, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x2a, 0x0a, 0x07, + 0x57, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x65, 0x62, 0x68, 0x6f, + 0x6f, 0x6b, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, + 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x72, 0x6c, 0x1a, 0x46, 0x0a, 0x07, 0x44, 0x69, 0x73, 0x63, + 0x6f, 0x72, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x75, + 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, + 0x6b, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, + 0x1a, 0x7c, 0x0a, 0x06, 0x47, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, + 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x61, + 0x73, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x74, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x18, 0x65, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x1a, 0x44, + 0x0a, 0x05, 0x53, 0x6c, 0x61, 0x63, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x77, 0x65, 0x62, 0x68, 0x6f, + 0x6f, 0x6b, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, + 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, + 0x6c, 0x61, 0x74, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x43, 0x4f, 0x4e, + 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x4e, 0x59, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, + 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x02, + 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4e, + 0x41, 0x50, 0x53, 0x48, 0x4f, 0x54, 0x5f, 0x45, 0x4e, 0x44, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, + 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x53, 0x4e, 0x41, 0x50, 0x53, 0x48, + 0x4f, 0x54, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, 0x42, 0x08, 0x0a, 0x06, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x26, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x05, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x76, 0x31, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x51, 0x0a, 0x04, + 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x0f, 0x70, 0x61, 0x73, 0x73, + 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x62, 0x63, 0x72, 0x79, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x00, 0x52, 0x0e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x63, 0x72, + 0x79, 0x70, 0x74, 0x42, 0x0a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, + 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, + 0x72, 0x65, 0x74, 0x68, 0x67, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x2f, 0x62, 0x61, 0x63, 0x6b, 0x72, + 0x65, 0x73, 0x74, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1112,7 +1189,7 @@ func file_v1_config_proto_rawDescGZIP() []byte { } var file_v1_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_v1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_v1_config_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_v1_config_proto_goTypes = []interface{}{ (Hook_Condition)(0), // 0: v1.Hook.Condition (*Config)(nil), // 1: v1.Config @@ -1127,6 +1204,7 @@ var file_v1_config_proto_goTypes = []interface{}{ (*Hook_Webhook)(nil), // 10: v1.Hook.Webhook (*Hook_Discord)(nil), // 11: v1.Hook.Discord (*Hook_Gotify)(nil), // 12: v1.Hook.Gotify + (*Hook_Slack)(nil), // 13: v1.Hook.Slack } var file_v1_config_proto_depIdxs = []int32{ 2, // 0: v1.Config.repos:type_name -> v1.Repo @@ -1141,12 +1219,13 @@ var file_v1_config_proto_depIdxs = []int32{ 10, // 9: v1.Hook.action_webhook:type_name -> v1.Hook.Webhook 11, // 10: v1.Hook.action_discord:type_name -> v1.Hook.Discord 12, // 11: v1.Hook.action_gotify:type_name -> v1.Hook.Gotify - 8, // 12: v1.Auth.users:type_name -> v1.User - 13, // [13:13] is the sub-list for method output_type - 13, // [13:13] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 13, // 12: v1.Hook.action_slack:type_name -> v1.Hook.Slack + 8, // 13: v1.Auth.users:type_name -> v1.User + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_v1_config_proto_init() } @@ -1299,12 +1378,25 @@ func file_v1_config_proto_init() { return nil } } + file_v1_config_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Hook_Slack); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_v1_config_proto_msgTypes[5].OneofWrappers = []interface{}{ (*Hook_ActionCommand)(nil), (*Hook_ActionWebhook)(nil), (*Hook_ActionDiscord)(nil), (*Hook_ActionGotify)(nil), + (*Hook_ActionSlack)(nil), } file_v1_config_proto_msgTypes[7].OneofWrappers = []interface{}{ (*User_PasswordBcrypt)(nil), @@ -1315,7 +1407,7 @@ func file_v1_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_v1_config_proto_rawDesc, NumEnums: 1, - NumMessages: 12, + NumMessages: 13, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/hook/discordhook.go b/internal/hook/discordhook.go index 280f13e1..871c0a38 100644 --- a/internal/hook/discordhook.go +++ b/internal/hook/discordhook.go @@ -25,7 +25,7 @@ func (h *Hook) doDiscord(cmd *v1.Hook_ActionDiscord, vars HookVars, output io.Wr requestBytes, _ := json.Marshal(request) - fmt.Fprintf(output, "Sending Discord message to %s\n---- payload ----", cmd.ActionDiscord.GetWebhookUrl()) + fmt.Fprintf(output, "Sending Discord message to %s\n---- payload ----\n", cmd.ActionDiscord.GetWebhookUrl()) output.Write(requestBytes) _, err = post(cmd.ActionDiscord.GetWebhookUrl(), "application/json", bytes.NewReader(requestBytes)) diff --git a/internal/hook/hook.go b/internal/hook/hook.go index cd9f8427..3aa4271f 100644 --- a/internal/hook/hook.go +++ b/internal/hook/hook.go @@ -155,6 +155,8 @@ func (h *Hook) Do(event v1.Hook_Condition, vars HookVars, output io.Writer) erro return h.doDiscord(action, vars, output) case *v1.Hook_ActionGotify: return h.doGotify(action, vars, output) + case *v1.Hook_ActionSlack: + return h.doSlack(action, vars, output) default: return fmt.Errorf("unknown hook action: %v", action) } diff --git a/internal/hook/slackhook.go b/internal/hook/slackhook.go new file mode 100644 index 00000000..075115f0 --- /dev/null +++ b/internal/hook/slackhook.go @@ -0,0 +1,33 @@ +package hook + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + + v1 "github.com/garethgeorge/backrest/gen/go/v1" +) + +func (h *Hook) doSlack(cmd *v1.Hook_ActionSlack, vars HookVars, output io.Writer) error { + payload, err := h.renderTemplateOrDefault(cmd.ActionSlack.GetTemplate(), defaultTemplate, vars) + if err != nil { + return fmt.Errorf("template rendering: %w", err) + } + + type Message struct { + Text string `json:"text"` + } + + request := Message{ + Text: "Backrest Notification\n" + payload, // leading newline looks better in discord. + } + + requestBytes, _ := json.Marshal(request) + + fmt.Fprintf(output, "Sending Slack message to %s\n---- payload ----\n", cmd.ActionSlack.GetWebhookUrl()) + output.Write(requestBytes) + + _, err = post(cmd.ActionSlack.GetWebhookUrl(), "application/json", bytes.NewReader(requestBytes)) + return err +} diff --git a/proto/v1/config.proto b/proto/v1/config.proto index ca3faabf..ac824e6e 100644 --- a/proto/v1/config.proto +++ b/proto/v1/config.proto @@ -72,6 +72,7 @@ message Hook { Webhook action_webhook = 101 [json_name="actionWebhook"]; Discord action_discord = 102 [json_name="actionDiscord"]; Gotify action_gotify = 103 [json_name="actionGotify"]; + Slack action_slack = 104 [json_name="actionSlack"]; } message Command { @@ -93,6 +94,11 @@ message Hook { string template = 100 [json_name="template"]; // template for the webhook payload. string title_template = 101 [json_name="titleTemplate"]; // template for the webhook title. } + + message Slack { + string webhook_url = 1 [json_name="webhookUrl"]; + string template = 2 [json_name="template"]; // template for the webhook payload. + } } message Auth { diff --git a/webui/gen/ts/v1/config_pb.ts b/webui/gen/ts/v1/config_pb.ts index 12e3cc10..d42626aa 100644 --- a/webui/gen/ts/v1/config_pb.ts +++ b/webui/gen/ts/v1/config_pb.ts @@ -435,6 +435,12 @@ export class Hook extends Message { */ value: Hook_Gotify; case: "actionGotify"; + } | { + /** + * @generated from field: v1.Hook.Slack action_slack = 104; + */ + value: Hook_Slack; + case: "actionSlack"; } | { case: undefined; value?: undefined } = { case: undefined }; constructor(data?: PartialMessage) { @@ -450,6 +456,7 @@ export class Hook extends Message { { no: 101, name: "action_webhook", kind: "message", T: Hook_Webhook, oneof: "action" }, { no: 102, name: "action_discord", kind: "message", T: Hook_Discord, oneof: "action" }, { no: 103, name: "action_gotify", kind: "message", T: Hook_Gotify, oneof: "action" }, + { no: 104, name: "action_slack", kind: "message", T: Hook_Slack, oneof: "action" }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): Hook { @@ -693,6 +700,51 @@ export class Hook_Gotify extends Message { } } +/** + * @generated from message v1.Hook.Slack + */ +export class Hook_Slack extends Message { + /** + * @generated from field: string webhook_url = 1; + */ + webhookUrl = ""; + + /** + * template for the webhook payload. + * + * @generated from field: string template = 2; + */ + template = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "v1.Hook.Slack"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "webhook_url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "template", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Hook_Slack { + return new Hook_Slack().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Hook_Slack { + return new Hook_Slack().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Hook_Slack { + return new Hook_Slack().fromJsonString(jsonString, options); + } + + static equals(a: Hook_Slack | PlainMessage | undefined, b: Hook_Slack | PlainMessage | undefined): boolean { + return proto3.util.equals(Hook_Slack, a, b); + } +} + /** * @generated from message v1.Auth */ diff --git a/webui/src/components/HooksFormList.tsx b/webui/src/components/HooksFormList.tsx index a0e45768..d8ef0a88 100644 --- a/webui/src/components/HooksFormList.tsx +++ b/webui/src/components/HooksFormList.tsx @@ -16,6 +16,7 @@ export interface HookFields { actionGotify?: any; actionDiscord?: any; actionWebhook?: any; + actionSlack?: any; } export const hooksListTooltipText = <> @@ -143,6 +144,15 @@ const hookTypes: { }, conditions: [], } + }, + { + name: "Slack", template: { + actionSlack: { + webhookUrl: "", + template: "{{ .Summary }}", + }, + conditions: [], + } } ]; @@ -152,7 +162,7 @@ const HookBuilder = ({ field }: { field: FormListFieldData }) => { if (hookData.actionDiscord) { return <> - + Discord Webhook} /> Text Template: @@ -185,6 +195,16 @@ const HookBuilder = ({ field }: { field: FormListFieldData }) => { + } else if (hookData.actionSlack) { + return <> + + Slack Webhook} /> + + Text Template: + + + + } else { return

Unknown hook

} diff --git a/webui/src/views/AddPlanModal.tsx b/webui/src/views/AddPlanModal.tsx index c6680f6b..1d7bec73 100644 --- a/webui/src/views/AddPlanModal.tsx +++ b/webui/src/views/AddPlanModal.tsx @@ -358,7 +358,7 @@ export const AddPlanModal = ({ label: "Plan Config as JSON", children: ( -
{new Plan(form.getFieldsValue()).toJsonString({ prettySpaces: 2 })}
+
{JSON.stringify(form.getFieldsValue(), null, 2)}
), },