From 3c4a152e6ea8d66ae866494206c8da4bfe59d2fd Mon Sep 17 00:00:00 2001 From: Miccah Date: Tue, 5 Apr 2022 18:38:48 -0500 Subject: [PATCH] Add JFrog Artifactory protobuf source and metadata (#293) * Add JFrog Artifactory protobuf source and metadata * Add generated protobuf code * Update metadata to include an email * Generate protobuf code --- .../source_metadatapb/source_metadata.pb.go | 339 ++++++++++++------ .../source_metadata.pb.validate.go | 141 ++++++++ pkg/pb/sourcespb/sources.pb.go | 239 +++++++++--- pkg/pb/sourcespb/sources.pb.validate.go | 176 +++++++++ proto/source_metadata.proto | 11 + proto/sources.proto | 11 + 6 files changed, 761 insertions(+), 156 deletions(-) diff --git a/pkg/pb/source_metadatapb/source_metadata.pb.go b/pkg/pb/source_metadatapb/source_metadata.pb.go index b457ebea..3f727f10 100644 --- a/pkg/pb/source_metadatapb/source_metadata.pb.go +++ b/pkg/pb/source_metadatapb/source_metadata.pb.go @@ -1807,6 +1807,94 @@ func (x *Teams) GetEmail() string { return "" } +// https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-FileInfo +type Artifactory struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Repo string `protobuf:"bytes,1,opt,name=repo,proto3" json:"repo,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Link string `protobuf:"bytes,3,opt,name=link,proto3" json:"link,omitempty"` + Timestamp string `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"` + Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *Artifactory) Reset() { + *x = Artifactory{} + if protoimpl.UnsafeEnabled { + mi := &file_source_metadata_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Artifactory) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Artifactory) ProtoMessage() {} + +func (x *Artifactory) ProtoReflect() protoreflect.Message { + mi := &file_source_metadata_proto_msgTypes[21] + 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 Artifactory.ProtoReflect.Descriptor instead. +func (*Artifactory) Descriptor() ([]byte, []int) { + return file_source_metadata_proto_rawDescGZIP(), []int{21} +} + +func (x *Artifactory) GetRepo() string { + if x != nil { + return x.Repo + } + return "" +} + +func (x *Artifactory) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Artifactory) GetLink() string { + if x != nil { + return x.Link + } + return "" +} + +func (x *Artifactory) GetTimestamp() string { + if x != nil { + return x.Timestamp + } + return "" +} + +func (x *Artifactory) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *Artifactory) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + type MetaData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1834,13 +1922,14 @@ type MetaData struct { // *MetaData_Gerrit // *MetaData_Jenkins // *MetaData_Teams + // *MetaData_Artifactory Data isMetaData_Data `protobuf_oneof:"data"` } func (x *MetaData) Reset() { *x = MetaData{} if protoimpl.UnsafeEnabled { - mi := &file_source_metadata_proto_msgTypes[21] + mi := &file_source_metadata_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1853,7 +1942,7 @@ func (x *MetaData) String() string { func (*MetaData) ProtoMessage() {} func (x *MetaData) ProtoReflect() protoreflect.Message { - mi := &file_source_metadata_proto_msgTypes[21] + mi := &file_source_metadata_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1866,7 +1955,7 @@ func (x *MetaData) ProtoReflect() protoreflect.Message { // Deprecated: Use MetaData.ProtoReflect.Descriptor instead. func (*MetaData) Descriptor() ([]byte, []int) { - return file_source_metadata_proto_rawDescGZIP(), []int{21} + return file_source_metadata_proto_rawDescGZIP(), []int{22} } func (m *MetaData) GetData() isMetaData_Data { @@ -2023,6 +2112,13 @@ func (x *MetaData) GetTeams() *Teams { return nil } +func (x *MetaData) GetArtifactory() *Artifactory { + if x, ok := x.GetData().(*MetaData_Artifactory); ok { + return x.Artifactory + } + return nil +} + type isMetaData_Data interface { isMetaData_Data() } @@ -2111,6 +2207,10 @@ type MetaData_Teams struct { Teams *Teams `protobuf:"bytes,21,opt,name=teams,proto3,oneof"` } +type MetaData_Artifactory struct { + Artifactory *Artifactory `protobuf:"bytes,22,opt,name=artifactory,proto3,oneof"` +} + func (*MetaData_Azure) isMetaData_Data() {} func (*MetaData_Bitbucket) isMetaData_Data() {} @@ -2153,6 +2253,8 @@ func (*MetaData_Jenkins) isMetaData_Data() {} func (*MetaData_Teams) isMetaData_Data() {} +func (*MetaData_Artifactory) isMetaData_Data() {} + var File_source_metadata_proto protoreflect.FileDescriptor var file_source_metadata_proto_rawDesc = []byte{ @@ -2355,79 +2457,93 @@ var file_source_metadata_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, - 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0xb2, - 0x08, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x61, - 0x7a, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x41, 0x7a, 0x75, - 0x72, 0x65, 0x48, 0x00, 0x52, 0x05, 0x61, 0x7a, 0x75, 0x72, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x62, - 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x99, + 0x01, 0x0a, 0x0b, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, + 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, + 0x70, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0xf4, 0x08, 0x0a, 0x08, 0x4d, + 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x7a, 0x75, 0x72, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x41, 0x7a, 0x75, 0x72, 0x65, 0x48, 0x00, + 0x52, 0x05, 0x61, 0x7a, 0x75, 0x72, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x62, 0x69, 0x74, 0x62, 0x75, + 0x63, 0x6b, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x42, 0x69, 0x74, + 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x48, 0x00, 0x52, 0x09, 0x62, 0x69, 0x74, 0x62, 0x75, 0x63, + 0x6b, 0x65, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x63, 0x69, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x43, 0x49, + 0x48, 0x00, 0x52, 0x08, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x63, 0x69, 0x12, 0x3d, 0x0a, 0x0a, + 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x48, 0x00, 0x52, + 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x64, + 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x2e, 0x42, 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x48, 0x00, 0x52, 0x09, 0x62, 0x69, - 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x37, 0x0a, 0x08, 0x63, 0x69, 0x72, 0x63, 0x6c, - 0x65, 0x63, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x69, 0x72, 0x63, - 0x6c, 0x65, 0x43, 0x49, 0x48, 0x00, 0x52, 0x08, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x63, 0x69, - 0x12, 0x3d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x48, 0x00, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, - 0x3a, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x48, 0x00, - 0x52, 0x09, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x12, 0x28, 0x0a, 0x03, 0x65, - 0x63, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x45, 0x43, 0x52, 0x48, 0x00, - 0x52, 0x03, 0x65, 0x63, 0x72, 0x12, 0x28, 0x0a, 0x03, 0x67, 0x63, 0x73, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x43, 0x53, 0x48, 0x00, 0x52, 0x03, 0x67, 0x63, 0x73, 0x12, - 0x31, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x17, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x47, 0x69, 0x74, 0x68, 0x75, 0x62, 0x48, 0x00, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x12, 0x31, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x48, 0x00, 0x52, 0x06, 0x67, - 0x69, 0x74, 0x6c, 0x61, 0x62, 0x12, 0x2b, 0x0a, 0x04, 0x6a, 0x69, 0x72, 0x61, 0x18, 0x0a, 0x20, + 0x2e, 0x44, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x48, 0x00, 0x52, 0x09, 0x64, 0x6f, + 0x63, 0x6b, 0x65, 0x72, 0x68, 0x75, 0x62, 0x12, 0x28, 0x0a, 0x03, 0x65, 0x63, 0x72, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x45, 0x43, 0x52, 0x48, 0x00, 0x52, 0x03, 0x65, 0x63, + 0x72, 0x12, 0x28, 0x0a, 0x03, 0x67, 0x63, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, + 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x47, 0x43, 0x53, 0x48, 0x00, 0x52, 0x03, 0x67, 0x63, 0x73, 0x12, 0x31, 0x0a, 0x06, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x48, 0x00, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x12, 0x31, + 0x0a, 0x06, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x47, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x48, 0x00, 0x52, 0x06, 0x67, 0x69, 0x74, 0x6c, 0x61, + 0x62, 0x12, 0x2b, 0x0a, 0x04, 0x6a, 0x69, 0x72, 0x61, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x4a, 0x69, 0x72, 0x61, 0x48, 0x00, 0x52, 0x04, 0x6a, 0x69, 0x72, 0x61, 0x12, 0x28, + 0x0a, 0x03, 0x6e, 0x70, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4e, 0x50, + 0x4d, 0x48, 0x00, 0x52, 0x03, 0x6e, 0x70, 0x6d, 0x12, 0x2b, 0x0a, 0x04, 0x70, 0x79, 0x70, 0x69, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x79, 0x50, 0x69, 0x48, 0x00, 0x52, + 0x04, 0x70, 0x79, 0x70, 0x69, 0x12, 0x25, 0x0a, 0x02, 0x73, 0x33, 0x18, 0x0d, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2e, 0x53, 0x33, 0x48, 0x00, 0x52, 0x02, 0x73, 0x33, 0x12, 0x2e, 0x0a, 0x05, + 0x73, 0x6c, 0x61, 0x63, 0x6b, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x6c, + 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x73, 0x6c, 0x61, 0x63, 0x6b, 0x12, 0x3d, 0x0a, 0x0a, + 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x48, 0x00, 0x52, + 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x28, 0x0a, 0x03, 0x67, + 0x69, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x69, 0x74, 0x48, 0x00, + 0x52, 0x03, 0x67, 0x69, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4a, 0x69, 0x72, 0x61, 0x48, 0x00, 0x52, 0x04, 0x6a, 0x69, - 0x72, 0x61, 0x12, 0x28, 0x0a, 0x03, 0x6e, 0x70, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x4e, 0x50, 0x4d, 0x48, 0x00, 0x52, 0x03, 0x6e, 0x70, 0x6d, 0x12, 0x2b, 0x0a, 0x04, - 0x70, 0x79, 0x70, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x79, 0x50, - 0x69, 0x48, 0x00, 0x52, 0x04, 0x70, 0x79, 0x70, 0x69, 0x12, 0x25, 0x0a, 0x02, 0x73, 0x33, 0x18, - 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x33, 0x48, 0x00, 0x52, 0x02, 0x73, 0x33, - 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x6c, 0x61, 0x63, 0x6b, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x53, 0x6c, 0x61, 0x63, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x73, 0x6c, 0x61, 0x63, 0x6b, - 0x12, 0x3d, 0x0a, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x0f, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x48, 0x00, 0x52, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, - 0x28, 0x0a, 0x03, 0x67, 0x69, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, - 0x69, 0x74, 0x48, 0x00, 0x52, 0x03, 0x67, 0x69, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x74, 0x65, 0x73, - 0x74, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x48, 0x00, - 0x52, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x6b, - 0x69, 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x42, 0x75, 0x69, 0x6c, - 0x64, 0x6b, 0x69, 0x74, 0x65, 0x48, 0x00, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x6b, 0x69, - 0x74, 0x65, 0x12, 0x31, 0x0a, 0x06, 0x67, 0x65, 0x72, 0x72, 0x69, 0x74, 0x18, 0x13, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x72, 0x72, 0x69, 0x74, 0x48, 0x00, 0x52, 0x06, 0x67, - 0x65, 0x72, 0x72, 0x69, 0x74, 0x12, 0x34, 0x0a, 0x07, 0x6a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, - 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, - 0x48, 0x00, 0x52, 0x07, 0x6a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x05, 0x74, - 0x65, 0x61, 0x6d, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x61, - 0x6d, 0x73, 0x48, 0x00, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, - 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, - 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x04, 0x74, 0x65, + 0x73, 0x74, 0x12, 0x3a, 0x0a, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x6b, 0x69, 0x74, 0x65, 0x18, + 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x6b, 0x69, 0x74, + 0x65, 0x48, 0x00, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x6b, 0x69, 0x74, 0x65, 0x12, 0x31, + 0x0a, 0x06, 0x67, 0x65, 0x72, 0x72, 0x69, 0x74, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x47, 0x65, 0x72, 0x72, 0x69, 0x74, 0x48, 0x00, 0x52, 0x06, 0x67, 0x65, 0x72, 0x72, 0x69, + 0x74, 0x12, 0x34, 0x0a, 0x07, 0x6a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, 0x18, 0x14, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x2e, 0x4a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x07, + 0x6a, 0x65, 0x6e, 0x6b, 0x69, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, + 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x48, 0x00, + 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x40, 0x0a, 0x0b, 0x61, 0x72, 0x74, 0x69, 0x66, + 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x41, + 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x72, + 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, + 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, + 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2442,30 +2558,31 @@ func file_source_metadata_proto_rawDescGZIP() []byte { return file_source_metadata_proto_rawDescData } -var file_source_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 22) +var file_source_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 23) var file_source_metadata_proto_goTypes = []interface{}{ - (*Azure)(nil), // 0: source_metadata.Azure - (*Bitbucket)(nil), // 1: source_metadata.Bitbucket - (*Buildkite)(nil), // 2: source_metadata.Buildkite - (*CircleCI)(nil), // 3: source_metadata.CircleCI - (*Confluence)(nil), // 4: source_metadata.Confluence - (*Dockerhub)(nil), // 5: source_metadata.Dockerhub - (*ECR)(nil), // 6: source_metadata.ECR - (*Filesystem)(nil), // 7: source_metadata.Filesystem - (*Git)(nil), // 8: source_metadata.Git - (*Github)(nil), // 9: source_metadata.Github - (*Gitlab)(nil), // 10: source_metadata.Gitlab - (*GCS)(nil), // 11: source_metadata.GCS - (*Jira)(nil), // 12: source_metadata.Jira - (*NPM)(nil), // 13: source_metadata.NPM - (*PyPi)(nil), // 14: source_metadata.PyPi - (*S3)(nil), // 15: source_metadata.S3 - (*Slack)(nil), // 16: source_metadata.Slack - (*Gerrit)(nil), // 17: source_metadata.Gerrit - (*Test)(nil), // 18: source_metadata.Test - (*Jenkins)(nil), // 19: source_metadata.Jenkins - (*Teams)(nil), // 20: source_metadata.Teams - (*MetaData)(nil), // 21: source_metadata.MetaData + (*Azure)(nil), // 0: source_metadata.Azure + (*Bitbucket)(nil), // 1: source_metadata.Bitbucket + (*Buildkite)(nil), // 2: source_metadata.Buildkite + (*CircleCI)(nil), // 3: source_metadata.CircleCI + (*Confluence)(nil), // 4: source_metadata.Confluence + (*Dockerhub)(nil), // 5: source_metadata.Dockerhub + (*ECR)(nil), // 6: source_metadata.ECR + (*Filesystem)(nil), // 7: source_metadata.Filesystem + (*Git)(nil), // 8: source_metadata.Git + (*Github)(nil), // 9: source_metadata.Github + (*Gitlab)(nil), // 10: source_metadata.Gitlab + (*GCS)(nil), // 11: source_metadata.GCS + (*Jira)(nil), // 12: source_metadata.Jira + (*NPM)(nil), // 13: source_metadata.NPM + (*PyPi)(nil), // 14: source_metadata.PyPi + (*S3)(nil), // 15: source_metadata.S3 + (*Slack)(nil), // 16: source_metadata.Slack + (*Gerrit)(nil), // 17: source_metadata.Gerrit + (*Test)(nil), // 18: source_metadata.Test + (*Jenkins)(nil), // 19: source_metadata.Jenkins + (*Teams)(nil), // 20: source_metadata.Teams + (*Artifactory)(nil), // 21: source_metadata.Artifactory + (*MetaData)(nil), // 22: source_metadata.MetaData } var file_source_metadata_proto_depIdxs = []int32{ 0, // 0: source_metadata.MetaData.azure:type_name -> source_metadata.Azure @@ -2489,11 +2606,12 @@ var file_source_metadata_proto_depIdxs = []int32{ 17, // 18: source_metadata.MetaData.gerrit:type_name -> source_metadata.Gerrit 19, // 19: source_metadata.MetaData.jenkins:type_name -> source_metadata.Jenkins 20, // 20: source_metadata.MetaData.teams:type_name -> source_metadata.Teams - 21, // [21:21] is the sub-list for method output_type - 21, // [21:21] is the sub-list for method input_type - 21, // [21:21] is the sub-list for extension type_name - 21, // [21:21] is the sub-list for extension extendee - 0, // [0:21] is the sub-list for field type_name + 21, // 21: source_metadata.MetaData.artifactory:type_name -> source_metadata.Artifactory + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_source_metadata_proto_init() } @@ -2755,6 +2873,18 @@ func file_source_metadata_proto_init() { } } file_source_metadata_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Artifactory); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_source_metadata_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*MetaData); i { case 0: return &v.state @@ -2767,7 +2897,7 @@ func file_source_metadata_proto_init() { } } } - file_source_metadata_proto_msgTypes[21].OneofWrappers = []interface{}{ + file_source_metadata_proto_msgTypes[22].OneofWrappers = []interface{}{ (*MetaData_Azure)(nil), (*MetaData_Bitbucket)(nil), (*MetaData_Circleci)(nil), @@ -2789,6 +2919,7 @@ func file_source_metadata_proto_init() { (*MetaData_Gerrit)(nil), (*MetaData_Jenkins)(nil), (*MetaData_Teams)(nil), + (*MetaData_Artifactory)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -2796,7 +2927,7 @@ func file_source_metadata_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_source_metadata_proto_rawDesc, NumEnums: 0, - NumMessages: 22, + NumMessages: 23, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/pb/source_metadatapb/source_metadata.pb.validate.go b/pkg/pb/source_metadatapb/source_metadata.pb.validate.go index a2fdf3a1..3e87d607 100644 --- a/pkg/pb/source_metadatapb/source_metadata.pb.validate.go +++ b/pkg/pb/source_metadatapb/source_metadata.pb.validate.go @@ -2320,6 +2320,116 @@ var _ interface { ErrorName() string } = TeamsValidationError{} +// Validate checks the field values on Artifactory with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Artifactory) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Artifactory with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ArtifactoryMultiError, or +// nil if none found. +func (m *Artifactory) ValidateAll() error { + return m.validate(true) +} + +func (m *Artifactory) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Repo + + // no validation rules for Path + + // no validation rules for Link + + // no validation rules for Timestamp + + // no validation rules for Username + + // no validation rules for Email + + if len(errors) > 0 { + return ArtifactoryMultiError(errors) + } + return nil +} + +// ArtifactoryMultiError is an error wrapping multiple validation errors +// returned by Artifactory.ValidateAll() if the designated constraints aren't met. +type ArtifactoryMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ArtifactoryMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ArtifactoryMultiError) AllErrors() []error { return m } + +// ArtifactoryValidationError is the validation error returned by +// Artifactory.Validate if the designated constraints aren't met. +type ArtifactoryValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ArtifactoryValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ArtifactoryValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ArtifactoryValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ArtifactoryValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ArtifactoryValidationError) ErrorName() string { return "ArtifactoryValidationError" } + +// Error satisfies the builtin error interface +func (e ArtifactoryValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sArtifactory.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ArtifactoryValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ArtifactoryValidationError{} + // Validate checks the field values on MetaData with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. @@ -2995,6 +3105,37 @@ func (m *MetaData) validate(all bool) error { } } + case *MetaData_Artifactory: + + if all { + switch v := interface{}(m.GetArtifactory()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MetaDataValidationError{ + field: "Artifactory", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MetaDataValidationError{ + field: "Artifactory", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetArtifactory()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MetaDataValidationError{ + field: "Artifactory", + reason: "embedded message failed validation", + cause: err, + } + } + } + } if len(errors) > 0 { diff --git a/pkg/pb/sourcespb/sources.pb.go b/pkg/pb/sourcespb/sources.pb.go index d5829f4e..5ce08619 100644 --- a/pkg/pb/sourcespb/sources.pb.go +++ b/pkg/pb/sourcespb/sources.pb.go @@ -51,6 +51,7 @@ const ( SourceType_SOURCE_TYPE_GERRIT SourceType = 21 SourceType_SOURCE_TYPE_JENKINS SourceType = 22 SourceType_SOURCE_TYPE_TEAMS SourceType = 23 + SourceType_SOURCE_TYPE_JFROG_ARTIFACTORY SourceType = 24 ) // Enum value maps for SourceType. @@ -80,6 +81,7 @@ var ( 21: "SOURCE_TYPE_GERRIT", 22: "SOURCE_TYPE_JENKINS", 23: "SOURCE_TYPE_TEAMS", + 24: "SOURCE_TYPE_JFROG_ARTIFACTORY", } SourceType_value = map[string]int32{ "SOURCE_TYPE_AZURE_STORAGE": 0, @@ -106,6 +108,7 @@ var ( "SOURCE_TYPE_GERRIT": 21, "SOURCE_TYPE_JENKINS": 22, "SOURCE_TYPE_TEAMS": 23, + "SOURCE_TYPE_JFROG_ARTIFACTORY": 24, } ) @@ -2095,6 +2098,103 @@ type Teams_Authenticated struct { func (*Teams_Authenticated) isTeams_Credential() {} +// https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-RetrieveFolderorRepositoryArchive +type Artifactory struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` + // Types that are assignable to Credential: + // *Artifactory_BasicAuth + // *Artifactory_Header + Credential isArtifactory_Credential `protobuf_oneof:"credential"` + Repositories []string `protobuf:"bytes,4,rep,name=repositories,proto3" json:"repositories,omitempty"` +} + +func (x *Artifactory) Reset() { + *x = Artifactory{} + if protoimpl.UnsafeEnabled { + mi := &file_sources_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Artifactory) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Artifactory) ProtoMessage() {} + +func (x *Artifactory) ProtoReflect() protoreflect.Message { + mi := &file_sources_proto_msgTypes[22] + 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 Artifactory.ProtoReflect.Descriptor instead. +func (*Artifactory) Descriptor() ([]byte, []int) { + return file_sources_proto_rawDescGZIP(), []int{22} +} + +func (x *Artifactory) GetEndpoint() string { + if x != nil { + return x.Endpoint + } + return "" +} + +func (m *Artifactory) GetCredential() isArtifactory_Credential { + if m != nil { + return m.Credential + } + return nil +} + +func (x *Artifactory) GetBasicAuth() *credentialspb.BasicAuth { + if x, ok := x.GetCredential().(*Artifactory_BasicAuth); ok { + return x.BasicAuth + } + return nil +} + +func (x *Artifactory) GetHeader() *credentialspb.Header { + if x, ok := x.GetCredential().(*Artifactory_Header); ok { + return x.Header + } + return nil +} + +func (x *Artifactory) GetRepositories() []string { + if x != nil { + return x.Repositories + } + return nil +} + +type isArtifactory_Credential interface { + isArtifactory_Credential() +} + +type Artifactory_BasicAuth struct { + BasicAuth *credentialspb.BasicAuth `protobuf:"bytes,2,opt,name=basic_auth,json=basicAuth,proto3,oneof"` +} + +type Artifactory_Header struct { + Header *credentialspb.Header `protobuf:"bytes,3,opt,name=header,proto3,oneof"` +} + +func (*Artifactory_BasicAuth) isArtifactory_Credential() {} + +func (*Artifactory_Header) isArtifactory_Credential() {} + var File_sources_proto protoreflect.FileDescriptor var file_sources_proto_rawDesc = []byte{ @@ -2349,7 +2449,20 @@ var file_sources_proto_rawDesc = []byte{ 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x0c, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x61, 0x6c, 0x2a, 0x95, 0x05, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, + 0x69, 0x61, 0x6c, 0x22, 0xcd, 0x01, 0x0a, 0x0b, 0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x24, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x72, 0x03, 0x90, 0x01, 0x01, 0x52, + 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x37, 0x0a, 0x0a, 0x62, 0x61, 0x73, + 0x69, 0x63, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x69, + 0x63, 0x41, 0x75, 0x74, 0x68, 0x48, 0x00, 0x52, 0x09, 0x62, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, + 0x74, 0x68, 0x12, 0x2d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, + 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x69, 0x65, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x61, 0x6c, 0x2a, 0xb8, 0x05, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47, 0x45, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, @@ -2390,11 +2503,14 @@ var file_sources_proto_rawDesc = []byte{ 0x50, 0x45, 0x5f, 0x47, 0x45, 0x52, 0x52, 0x49, 0x54, 0x10, 0x15, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x45, 0x4e, 0x4b, 0x49, 0x4e, 0x53, 0x10, 0x16, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, - 0x59, 0x50, 0x45, 0x5f, 0x54, 0x45, 0x41, 0x4d, 0x53, 0x10, 0x17, 0x42, 0x3b, 0x5a, 0x39, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, - 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, - 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x59, 0x50, 0x45, 0x5f, 0x54, 0x45, 0x41, 0x4d, 0x53, 0x10, 0x17, 0x12, 0x21, 0x0a, 0x1d, 0x53, + 0x4f, 0x55, 0x52, 0x43, 0x45, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4a, 0x46, 0x52, 0x4f, 0x47, + 0x5f, 0x41, 0x52, 0x54, 0x49, 0x46, 0x41, 0x43, 0x54, 0x4f, 0x52, 0x59, 0x10, 0x18, 0x42, 0x3b, + 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, + 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, + 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, + 0x62, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -2410,7 +2526,7 @@ func file_sources_proto_rawDescGZIP() []byte { } var file_sources_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_sources_proto_msgTypes = make([]protoimpl.MessageInfo, 22) +var file_sources_proto_msgTypes = make([]protoimpl.MessageInfo, 23) var file_sources_proto_goTypes = []interface{}{ (SourceType)(0), // 0: sources.SourceType (Confluence_GetAllSpacesScope)(0), // 1: sources.Confluence.GetAllSpacesScope @@ -2436,53 +2552,56 @@ var file_sources_proto_goTypes = []interface{}{ (*Gerrit)(nil), // 21: sources.Gerrit (*Jenkins)(nil), // 22: sources.Jenkins (*Teams)(nil), // 23: sources.Teams - (*durationpb.Duration)(nil), // 24: google.protobuf.Duration - (*anypb.Any)(nil), // 25: google.protobuf.Any - (*credentialspb.BasicAuth)(nil), // 26: credentials.BasicAuth - (*credentialspb.Unauthenticated)(nil), // 27: credentials.Unauthenticated - (*credentialspb.Oauth2)(nil), // 28: credentials.Oauth2 - (*credentialspb.KeySecret)(nil), // 29: credentials.KeySecret - (*credentialspb.GitHubApp)(nil), // 30: credentials.GitHubApp - (*credentialspb.CloudEnvironment)(nil), // 31: credentials.CloudEnvironment - (*credentialspb.Header)(nil), // 32: credentials.Header - (*credentialspb.ClientCredentials)(nil), // 33: credentials.ClientCredentials + (*Artifactory)(nil), // 24: sources.Artifactory + (*durationpb.Duration)(nil), // 25: google.protobuf.Duration + (*anypb.Any)(nil), // 26: google.protobuf.Any + (*credentialspb.BasicAuth)(nil), // 27: credentials.BasicAuth + (*credentialspb.Unauthenticated)(nil), // 28: credentials.Unauthenticated + (*credentialspb.Oauth2)(nil), // 29: credentials.Oauth2 + (*credentialspb.KeySecret)(nil), // 30: credentials.KeySecret + (*credentialspb.GitHubApp)(nil), // 31: credentials.GitHubApp + (*credentialspb.CloudEnvironment)(nil), // 32: credentials.CloudEnvironment + (*credentialspb.Header)(nil), // 33: credentials.Header + (*credentialspb.ClientCredentials)(nil), // 34: credentials.ClientCredentials } var file_sources_proto_depIdxs = []int32{ - 24, // 0: sources.LocalSource.scan_interval:type_name -> google.protobuf.Duration - 25, // 1: sources.LocalSource.connection:type_name -> google.protobuf.Any - 26, // 2: sources.AzureStorage.basic_auth:type_name -> credentials.BasicAuth - 27, // 3: sources.AzureStorage.unauthenticated:type_name -> credentials.Unauthenticated - 28, // 4: sources.Bitbucket.oauth:type_name -> credentials.Oauth2 - 26, // 5: sources.Bitbucket.basic_auth:type_name -> credentials.BasicAuth - 27, // 6: sources.Confluence.unauthenticated:type_name -> credentials.Unauthenticated - 26, // 7: sources.Confluence.basic_auth:type_name -> credentials.BasicAuth + 25, // 0: sources.LocalSource.scan_interval:type_name -> google.protobuf.Duration + 26, // 1: sources.LocalSource.connection:type_name -> google.protobuf.Any + 27, // 2: sources.AzureStorage.basic_auth:type_name -> credentials.BasicAuth + 28, // 3: sources.AzureStorage.unauthenticated:type_name -> credentials.Unauthenticated + 29, // 4: sources.Bitbucket.oauth:type_name -> credentials.Oauth2 + 27, // 5: sources.Bitbucket.basic_auth:type_name -> credentials.BasicAuth + 28, // 6: sources.Confluence.unauthenticated:type_name -> credentials.Unauthenticated + 27, // 7: sources.Confluence.basic_auth:type_name -> credentials.BasicAuth 1, // 8: sources.Confluence.spaces_scope:type_name -> sources.Confluence.GetAllSpacesScope - 27, // 9: sources.DockerHub.unauthenticated:type_name -> credentials.Unauthenticated - 29, // 10: sources.ECR.access_key:type_name -> credentials.KeySecret - 26, // 11: sources.Git.basic_auth:type_name -> credentials.BasicAuth - 27, // 12: sources.Git.unauthenticated:type_name -> credentials.Unauthenticated - 28, // 13: sources.GitLab.oauth:type_name -> credentials.Oauth2 - 26, // 14: sources.GitLab.basic_auth:type_name -> credentials.BasicAuth - 30, // 15: sources.GitHub.github_app:type_name -> credentials.GitHubApp - 27, // 16: sources.GitHub.unauthenticated:type_name -> credentials.Unauthenticated - 26, // 17: sources.JIRA.basic_auth:type_name -> credentials.BasicAuth - 27, // 18: sources.JIRA.unauthenticated:type_name -> credentials.Unauthenticated - 28, // 19: sources.JIRA.oauth:type_name -> credentials.Oauth2 - 27, // 20: sources.NPMUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated - 27, // 21: sources.PyPIUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated - 29, // 22: sources.S3.access_key:type_name -> credentials.KeySecret - 27, // 23: sources.S3.unauthenticated:type_name -> credentials.Unauthenticated - 31, // 24: sources.S3.cloud_environment:type_name -> credentials.CloudEnvironment - 26, // 25: sources.Gerrit.basic_auth:type_name -> credentials.BasicAuth - 27, // 26: sources.Gerrit.unauthenticated:type_name -> credentials.Unauthenticated - 26, // 27: sources.Jenkins.basic_auth:type_name -> credentials.BasicAuth - 32, // 28: sources.Jenkins.header:type_name -> credentials.Header - 33, // 29: sources.Teams.authenticated:type_name -> credentials.ClientCredentials - 30, // [30:30] is the sub-list for method output_type - 30, // [30:30] is the sub-list for method input_type - 30, // [30:30] is the sub-list for extension type_name - 30, // [30:30] is the sub-list for extension extendee - 0, // [0:30] is the sub-list for field type_name + 28, // 9: sources.DockerHub.unauthenticated:type_name -> credentials.Unauthenticated + 30, // 10: sources.ECR.access_key:type_name -> credentials.KeySecret + 27, // 11: sources.Git.basic_auth:type_name -> credentials.BasicAuth + 28, // 12: sources.Git.unauthenticated:type_name -> credentials.Unauthenticated + 29, // 13: sources.GitLab.oauth:type_name -> credentials.Oauth2 + 27, // 14: sources.GitLab.basic_auth:type_name -> credentials.BasicAuth + 31, // 15: sources.GitHub.github_app:type_name -> credentials.GitHubApp + 28, // 16: sources.GitHub.unauthenticated:type_name -> credentials.Unauthenticated + 27, // 17: sources.JIRA.basic_auth:type_name -> credentials.BasicAuth + 28, // 18: sources.JIRA.unauthenticated:type_name -> credentials.Unauthenticated + 29, // 19: sources.JIRA.oauth:type_name -> credentials.Oauth2 + 28, // 20: sources.NPMUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated + 28, // 21: sources.PyPIUnauthenticatedPackage.unauthenticated:type_name -> credentials.Unauthenticated + 30, // 22: sources.S3.access_key:type_name -> credentials.KeySecret + 28, // 23: sources.S3.unauthenticated:type_name -> credentials.Unauthenticated + 32, // 24: sources.S3.cloud_environment:type_name -> credentials.CloudEnvironment + 27, // 25: sources.Gerrit.basic_auth:type_name -> credentials.BasicAuth + 28, // 26: sources.Gerrit.unauthenticated:type_name -> credentials.Unauthenticated + 27, // 27: sources.Jenkins.basic_auth:type_name -> credentials.BasicAuth + 33, // 28: sources.Jenkins.header:type_name -> credentials.Header + 34, // 29: sources.Teams.authenticated:type_name -> credentials.ClientCredentials + 27, // 30: sources.Artifactory.basic_auth:type_name -> credentials.BasicAuth + 33, // 31: sources.Artifactory.header:type_name -> credentials.Header + 32, // [32:32] is the sub-list for method output_type + 32, // [32:32] is the sub-list for method input_type + 32, // [32:32] is the sub-list for extension type_name + 32, // [32:32] is the sub-list for extension extendee + 0, // [0:32] is the sub-list for field type_name } func init() { file_sources_proto_init() } @@ -2755,6 +2874,18 @@ func file_sources_proto_init() { return nil } } + file_sources_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Artifactory); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_sources_proto_msgTypes[1].OneofWrappers = []interface{}{ (*AzureStorage_ConnectionString)(nil), @@ -2831,13 +2962,17 @@ func file_sources_proto_init() { file_sources_proto_msgTypes[21].OneofWrappers = []interface{}{ (*Teams_Authenticated)(nil), } + file_sources_proto_msgTypes[22].OneofWrappers = []interface{}{ + (*Artifactory_BasicAuth)(nil), + (*Artifactory_Header)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_sources_proto_rawDesc, NumEnums: 2, - NumMessages: 22, + NumMessages: 23, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/pb/sourcespb/sources.pb.validate.go b/pkg/pb/sourcespb/sources.pb.validate.go index d775edf4..10de3544 100644 --- a/pkg/pb/sourcespb/sources.pb.validate.go +++ b/pkg/pb/sourcespb/sources.pb.validate.go @@ -3317,3 +3317,179 @@ var _ interface { Cause() error ErrorName() string } = TeamsValidationError{} + +// Validate checks the field values on Artifactory with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Artifactory) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Artifactory with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ArtifactoryMultiError, or +// nil if none found. +func (m *Artifactory) ValidateAll() error { + return m.validate(true) +} + +func (m *Artifactory) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if _, err := url.Parse(m.GetEndpoint()); err != nil { + err = ArtifactoryValidationError{ + field: "Endpoint", + reason: "value must be a valid URI", + cause: err, + } + if !all { + return err + } + errors = append(errors, err) + } + + switch m.Credential.(type) { + + case *Artifactory_BasicAuth: + + if all { + switch v := interface{}(m.GetBasicAuth()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ArtifactoryValidationError{ + field: "BasicAuth", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ArtifactoryValidationError{ + field: "BasicAuth", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBasicAuth()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ArtifactoryValidationError{ + field: "BasicAuth", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Artifactory_Header: + + if all { + switch v := interface{}(m.GetHeader()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ArtifactoryValidationError{ + field: "Header", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ArtifactoryValidationError{ + field: "Header", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ArtifactoryValidationError{ + field: "Header", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ArtifactoryMultiError(errors) + } + return nil +} + +// ArtifactoryMultiError is an error wrapping multiple validation errors +// returned by Artifactory.ValidateAll() if the designated constraints aren't met. +type ArtifactoryMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ArtifactoryMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ArtifactoryMultiError) AllErrors() []error { return m } + +// ArtifactoryValidationError is the validation error returned by +// Artifactory.Validate if the designated constraints aren't met. +type ArtifactoryValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ArtifactoryValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ArtifactoryValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ArtifactoryValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ArtifactoryValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ArtifactoryValidationError) ErrorName() string { return "ArtifactoryValidationError" } + +// Error satisfies the builtin error interface +func (e ArtifactoryValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sArtifactory.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ArtifactoryValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ArtifactoryValidationError{} diff --git a/proto/source_metadata.proto b/proto/source_metadata.proto index ae07c030..b147cd5f 100644 --- a/proto/source_metadata.proto +++ b/proto/source_metadata.proto @@ -188,6 +188,16 @@ message Teams { string email = 7; } +// https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-FileInfo +message Artifactory { + string repo = 1; + string path = 2; + string link = 3; + string timestamp = 4; + string username = 5; + string email = 6; +} + message MetaData { oneof data { Azure azure = 1; @@ -211,5 +221,6 @@ message MetaData { Gerrit gerrit = 19; Jenkins jenkins = 20; Teams teams = 21; + Artifactory artifactory = 22; } } diff --git a/proto/sources.proto b/proto/sources.proto index d4e1400e..ef967ec2 100644 --- a/proto/sources.proto +++ b/proto/sources.proto @@ -35,6 +35,7 @@ enum SourceType { SOURCE_TYPE_GERRIT = 21; SOURCE_TYPE_JENKINS = 22; SOURCE_TYPE_TEAMS = 23; + SOURCE_TYPE_JFROG_ARTIFACTORY = 24; } message LocalSource { @@ -221,3 +222,13 @@ message Teams { repeated string channels = 3; repeated string ignoreList = 4; } + +// https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-RetrieveFolderorRepositoryArchive +message Artifactory { + string endpoint = 1 [(validate.rules).string.uri_ref = true]; + oneof credential { + credentials.BasicAuth basic_auth = 2; + credentials.Header header = 3; + } + repeated string repositories = 4; +}