From d139bbcc8cfba6c10d3b147ba4d5ac2daca391cb Mon Sep 17 00:00:00 2001 From: Randy George Date: Fri, 30 Aug 2024 13:29:19 -0500 Subject: [PATCH 1/3] change to include metadata in resource-relationships --- .../v1beta1/relationships/metadata.pb.go | 228 ++++++++++++++++ .../relationships/metadata.pb.validate.go | 201 ++++++++++++++ .../metadata.pb.validate_test.go | 25 ++ .../v1beta1/relationships/metadata.proto | 36 +++ .../relationships/policy_relationship.pb.go | 184 ++++--------- .../policy_relationship.pb.validate.go | 71 ++++- .../relationships/policy_relationship.proto | 30 +-- .../policy_relationship_detail.pb.go | 251 ++++++++++++++++++ .../policy_relationship_detail.pb.validate.go | 144 ++++++++++ .../policy_relationship_detail.proto | 31 +++ go.mod | 5 + go.sum | 10 + openapi.yaml | 39 ++- 13 files changed, 1100 insertions(+), 155 deletions(-) create mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.pb.go create mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go create mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go create mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.proto create mode 100644 api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.go create mode 100644 api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.validate.go create mode 100644 api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.go new file mode 100644 index 00000000..7fc4e7fd --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/metadata.pb.go @@ -0,0 +1,228 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: kessel/inventory/v1beta1/relationships/metadata.proto + +package relationships + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Metadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Kessel Asset Inventory generated identifier. + Id int64 `protobuf:"varint,3356,opt,name=id,proto3" json:"id,omitempty"` + // The type of Resource relationship + RelationshipType string `protobuf:"bytes,251000036,opt,name=relationship_type,json=relationshipType,proto3" json:"relationship_type,omitempty"` + // Date and time when the inventory item was first reported. + FirstReported *timestamppb.Timestamp `protobuf:"bytes,13874817,opt,name=first_reported,json=firstReported,proto3" json:"first_reported,omitempty"` + // Date and time when the inventory item was last updated. + LastReported *timestamppb.Timestamp `protobuf:"bytes,436473484,opt,name=last_reported,json=lastReported,proto3" json:"last_reported,omitempty"` + // Identifier of the reporter that first reported on this item. + FirstReportedBy string `protobuf:"bytes,46112821,opt,name=first_reported_by,json=firstReportedBy,proto3" json:"first_reported_by,omitempty"` + // Identifier of the reporter that last reported on this item. + LastReportedBy string `protobuf:"bytes,505008783,opt,name=last_reported_by,json=lastReportedBy,proto3" json:"last_reported_by,omitempty"` +} + +func (x *Metadata) Reset() { + *x = Metadata{} + if protoimpl.UnsafeEnabled { + mi := &file_kessel_inventory_v1beta1_relationships_metadata_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Metadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Metadata) ProtoMessage() {} + +func (x *Metadata) ProtoReflect() protoreflect.Message { + mi := &file_kessel_inventory_v1beta1_relationships_metadata_proto_msgTypes[0] + 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 Metadata.ProtoReflect.Descriptor instead. +func (*Metadata) Descriptor() ([]byte, []int) { + return file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescGZIP(), []int{0} +} + +func (x *Metadata) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Metadata) GetRelationshipType() string { + if x != nil { + return x.RelationshipType + } + return "" +} + +func (x *Metadata) GetFirstReported() *timestamppb.Timestamp { + if x != nil { + return x.FirstReported + } + return nil +} + +func (x *Metadata) GetLastReported() *timestamppb.Timestamp { + if x != nil { + return x.LastReported + } + return nil +} + +func (x *Metadata) GetFirstReportedBy() string { + if x != nil { + return x.FirstReportedBy + } + return "" +} + +func (x *Metadata) GetLastReportedBy() string { + if x != nil { + return x.LastReportedBy + } + return "" +} + +var File_kessel_inventory_v1beta1_relationships_metadata_proto protoreflect.FileDescriptor + +var file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x26, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, + 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x1a, + 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xd1, 0x02, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x9c, 0x1a, 0x20, 0x01, 0x28, 0x03, 0x42, 0x03, 0xe0, 0x41, 0x03, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x33, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x68, 0x69, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0xe4, 0xe9, 0xd7, 0x77, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x68, 0x69, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x49, 0x0a, 0x0e, 0x66, 0x69, 0x72, + 0x73, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x18, 0x81, 0xed, 0xce, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0d, 0x66, 0x69, 0x72, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x64, 0x12, 0x48, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x65, 0x64, 0x18, 0x8c, 0x9d, 0x90, 0xd0, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x03, 0xe0, 0x41, 0x03, + 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x12, 0x32, + 0x0a, 0x11, 0x66, 0x69, 0x72, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, + 0x5f, 0x62, 0x79, 0x18, 0xb5, 0xc0, 0xfe, 0x15, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, + 0x03, 0x52, 0x0f, 0x66, 0x69, 0x72, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, + 0x42, 0x79, 0x12, 0x31, 0x0a, 0x10, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x18, 0x8f, 0xa5, 0xe7, 0xf0, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x64, 0x42, 0x79, 0x42, 0x8e, 0x01, 0x0a, 0x36, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, + 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, + 0x50, 0x01, 0x5a, 0x52, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, + 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2d, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, + 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescOnce sync.Once + file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescData = file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDesc +) + +func file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescGZIP() []byte { + file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescOnce.Do(func() { + file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescData) + }) + return file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDescData +} + +var file_kessel_inventory_v1beta1_relationships_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_kessel_inventory_v1beta1_relationships_metadata_proto_goTypes = []any{ + (*Metadata)(nil), // 0: kessel.inventory.v1beta1.relationships.Metadata + (*timestamppb.Timestamp)(nil), // 1: google.protobuf.Timestamp +} +var file_kessel_inventory_v1beta1_relationships_metadata_proto_depIdxs = []int32{ + 1, // 0: kessel.inventory.v1beta1.relationships.Metadata.first_reported:type_name -> google.protobuf.Timestamp + 1, // 1: kessel.inventory.v1beta1.relationships.Metadata.last_reported:type_name -> google.protobuf.Timestamp + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_kessel_inventory_v1beta1_relationships_metadata_proto_init() } +func file_kessel_inventory_v1beta1_relationships_metadata_proto_init() { + if File_kessel_inventory_v1beta1_relationships_metadata_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_kessel_inventory_v1beta1_relationships_metadata_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Metadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_kessel_inventory_v1beta1_relationships_metadata_proto_goTypes, + DependencyIndexes: file_kessel_inventory_v1beta1_relationships_metadata_proto_depIdxs, + MessageInfos: file_kessel_inventory_v1beta1_relationships_metadata_proto_msgTypes, + }.Build() + File_kessel_inventory_v1beta1_relationships_metadata_proto = out.File + file_kessel_inventory_v1beta1_relationships_metadata_proto_rawDesc = nil + file_kessel_inventory_v1beta1_relationships_metadata_proto_goTypes = nil + file_kessel_inventory_v1beta1_relationships_metadata_proto_depIdxs = nil +} diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go new file mode 100644 index 00000000..1a36feb0 --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go @@ -0,0 +1,201 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: kessel/inventory/v1beta1/relationships/metadata.proto + +package relationships + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// 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. +func (m *Metadata) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Metadata 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 MetadataMultiError, or nil +// if none found. +func (m *Metadata) ValidateAll() error { + return m.validate(true) +} + +func (m *Metadata) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for RelationshipType + + if all { + switch v := interface{}(m.GetFirstReported()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "FirstReported", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "FirstReported", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetFirstReported()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MetadataValidationError{ + field: "FirstReported", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetLastReported()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "LastReported", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MetadataValidationError{ + field: "LastReported", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLastReported()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MetadataValidationError{ + field: "LastReported", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for FirstReportedBy + + // no validation rules for LastReportedBy + + if len(errors) > 0 { + return MetadataMultiError(errors) + } + + return nil +} + +// MetadataMultiError is an error wrapping multiple validation errors returned +// by Metadata.ValidateAll() if the designated constraints aren't met. +type MetadataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MetadataMultiError) 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 MetadataMultiError) AllErrors() []error { return m } + +// MetadataValidationError is the validation error returned by +// Metadata.Validate if the designated constraints aren't met. +type MetadataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MetadataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MetadataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MetadataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MetadataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MetadataValidationError) ErrorName() string { return "MetadataValidationError" } + +// Error satisfies the builtin error interface +func (e MetadataValidationError) 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 %sMetadata.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MetadataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MetadataValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go new file mode 100644 index 00000000..f1546b77 --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go @@ -0,0 +1,25 @@ +package relationships + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMetadataValid(t *testing.T) { + meta := Metadata{} + err := meta.ValidateAll() + + assert.NoError(t, err) +} + +func TestMetadataInvalidLabels(t *testing.T) { + meta := Metadata{ + Labels: []*ResourceLabel{ + {}, + }, + } + + err := meta.ValidateAll() + assert.ErrorContains(t, err, "invalid Metadata.Labels[0]") +} diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.proto b/api/kessel/inventory/v1beta1/relationships/metadata.proto new file mode 100644 index 00000000..cd5a6888 --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/metadata.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package kessel.inventory.v1beta1.relationships; + +import "google/api/field_behavior.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships"; +option java_multiple_files = true; +option java_package = "org.project_kessel.api.inventory.v1beta1.relationships"; + +message Metadata { + // Kessel Asset Inventory generated identifier. + int64 id = 3356 [ (google.api.field_behavior) = OUTPUT_ONLY ]; + + // The type of Resource relationship + string relationship_type = 251000036 + [ (google.api.field_behavior) = OUTPUT_ONLY ]; + + // Date and time when the inventory item was first reported. + google.protobuf.Timestamp first_reported = 13874817 + [ (google.api.field_behavior) = OUTPUT_ONLY ]; + + // Date and time when the inventory item was last updated. + google.protobuf.Timestamp last_reported = 436473484 + [ (google.api.field_behavior) = OUTPUT_ONLY ]; + + // Identifier of the reporter that first reported on this item. + string first_reported_by = 46112821 + [ (google.api.field_behavior) = OUTPUT_ONLY ]; + + // Identifier of the reporter that last reported on this item. + string last_reported_by = 505008783 + [ (google.api.field_behavior) = OUTPUT_ONLY ]; + +} diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.go b/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.go index de747afe..db404cfb 100644 --- a/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.go +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.go @@ -7,6 +7,7 @@ package relationships import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,75 +21,14 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// the aggregate status of the cluster -type PolicyRelationship_Status int32 - -const ( - PolicyRelationship_STATUS_UNSPECIFIED PolicyRelationship_Status = 0 - PolicyRelationship_STATUS_OTHER PolicyRelationship_Status = 1 - PolicyRelationship_NON_COMPLIANT PolicyRelationship_Status = 2 - PolicyRelationship_COMPLIANT PolicyRelationship_Status = 3 -) - -// Enum value maps for PolicyRelationship_Status. -var ( - PolicyRelationship_Status_name = map[int32]string{ - 0: "STATUS_UNSPECIFIED", - 1: "STATUS_OTHER", - 2: "NON_COMPLIANT", - 3: "COMPLIANT", - } - PolicyRelationship_Status_value = map[string]int32{ - "STATUS_UNSPECIFIED": 0, - "STATUS_OTHER": 1, - "NON_COMPLIANT": 2, - "COMPLIANT": 3, - } -) - -func (x PolicyRelationship_Status) Enum() *PolicyRelationship_Status { - p := new(PolicyRelationship_Status) - *p = x - return p -} - -func (x PolicyRelationship_Status) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (PolicyRelationship_Status) Descriptor() protoreflect.EnumDescriptor { - return file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_enumTypes[0].Descriptor() -} - -func (PolicyRelationship_Status) Type() protoreflect.EnumType { - return &file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_enumTypes[0] -} - -func (x PolicyRelationship_Status) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use PolicyRelationship_Status.Descriptor instead. -func (PolicyRelationship_Status) EnumDescriptor() ([]byte, []int) { - return file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDescGZIP(), []int{0, 0} -} - type PolicyRelationship struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // The type of Resource relationship - RelationshipType string `protobuf:"bytes,251000036,opt,name=relationship_type,json=relationshipType,proto3" json:"relationship_type,omitempty"` - // The resource ID assigned to the resource by Kessel Asset Inventory. A - // reporter alias may also be used as a resource ID using the format: - // \"hcrn::::\" - PolicyId int64 `protobuf:"varint,225679544,opt,name=policy_id,json=policyId,proto3" json:"policy_id,omitempty"` - // The resource ID assigned to the resource by Kessel Asset Inventory. A - // reporter alias may also be used as a resource ID using the format: - // \"hcrn::::\" - K8SClusterId int64 `protobuf:"varint,240280960,opt,name=k8s_cluster_id,json=k8sClusterId,proto3" json:"k8s_cluster_id,omitempty"` - Status PolicyRelationship_Status `protobuf:"varint,355610639,opt,name=status,proto3,enum=kessel.inventory.v1beta1.relationships.PolicyRelationship_Status" json:"status,omitempty"` + // Metadata about this resource + Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + RelationshipData *PolicyRelationshipDetail `protobuf:"bytes,2122699,opt,name=relationship_data,json=relationshipData,proto3" json:"relationship_data,omitempty"` } func (x *PolicyRelationship) Reset() { @@ -123,32 +63,18 @@ func (*PolicyRelationship) Descriptor() ([]byte, []int) { return file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDescGZIP(), []int{0} } -func (x *PolicyRelationship) GetRelationshipType() string { +func (x *PolicyRelationship) GetMetadata() *Metadata { if x != nil { - return x.RelationshipType + return x.Metadata } - return "" + return nil } -func (x *PolicyRelationship) GetPolicyId() int64 { +func (x *PolicyRelationship) GetRelationshipData() *PolicyRelationshipDetail { if x != nil { - return x.PolicyId + return x.RelationshipData } - return 0 -} - -func (x *PolicyRelationship) GetK8SClusterId() int64 { - if x != nil { - return x.K8SClusterId - } - return 0 -} - -func (x *PolicyRelationship) GetStatus() PolicyRelationship_Status { - if x != nil { - return x.Status - } - return PolicyRelationship_STATUS_UNSPECIFIED + return nil } var File_kessel_inventory_v1beta1_relationships_policy_relationship_proto protoreflect.FileDescriptor @@ -160,37 +86,41 @@ var file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDes 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x26, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x22, 0xc2, 0x02, 0x0a, 0x12, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, - 0x70, 0x12, 0x2e, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, - 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0xe4, 0xe9, 0xd7, 0x77, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x10, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x1e, 0x0a, 0x09, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x69, 0x64, 0x18, 0xb8, - 0xb1, 0xce, 0x6b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, - 0x64, 0x12, 0x27, 0x0a, 0x0e, 0x6b, 0x38, 0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x80, 0xcb, 0xc9, 0x72, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6b, 0x38, - 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x5d, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x8f, 0xe0, 0xc8, 0xa9, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x41, - 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x54, 0x0a, 0x06, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, 0x11, 0x0a, - 0x0d, 0x4e, 0x4f, 0x4e, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x49, 0x41, 0x4e, 0x54, 0x10, 0x02, - 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x49, 0x41, 0x4e, 0x54, 0x10, 0x03, 0x42, - 0x8e, 0x01, 0x0a, 0x36, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, - 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x50, 0x01, 0x5a, 0x52, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, - 0x2d, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, - 0x79, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, - 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x1a, 0x35, 0x6b, 0x65, 0x73, 0x73, + 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, + 0x70, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x47, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, + 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x5f, 0x64, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xea, 0x01, 0x0a, 0x12, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x12, 0x58, 0x0a, 0x08, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x6b, + 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x68, 0x69, 0x70, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x0a, + 0xfa, 0x42, 0x07, 0x8a, 0x01, 0x04, 0x08, 0x00, 0x10, 0x00, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x7a, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x68, 0x69, 0x70, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xcb, 0xc7, 0x81, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, + 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2e, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x10, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x44, 0x61, 0x74, 0x61, + 0x42, 0x8e, 0x01, 0x0a, 0x36, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x76, 0x65, + 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x50, 0x01, 0x5a, 0x52, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x2d, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, + 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -205,19 +135,20 @@ func file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDe return file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDescData } -var file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_goTypes = []any{ - (PolicyRelationship_Status)(0), // 0: kessel.inventory.v1beta1.relationships.PolicyRelationship.Status - (*PolicyRelationship)(nil), // 1: kessel.inventory.v1beta1.relationships.PolicyRelationship + (*PolicyRelationship)(nil), // 0: kessel.inventory.v1beta1.relationships.PolicyRelationship + (*Metadata)(nil), // 1: kessel.inventory.v1beta1.relationships.Metadata + (*PolicyRelationshipDetail)(nil), // 2: kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail } var file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_depIdxs = []int32{ - 0, // 0: kessel.inventory.v1beta1.relationships.PolicyRelationship.status:type_name -> kessel.inventory.v1beta1.relationships.PolicyRelationship.Status - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 1, // 0: kessel.inventory.v1beta1.relationships.PolicyRelationship.metadata:type_name -> kessel.inventory.v1beta1.relationships.Metadata + 2, // 1: kessel.inventory.v1beta1.relationships.PolicyRelationship.relationship_data:type_name -> kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_init() } @@ -225,6 +156,8 @@ func file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_init( if File_kessel_inventory_v1beta1_relationships_policy_relationship_proto != nil { return } + file_kessel_inventory_v1beta1_relationships_metadata_proto_init() + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_init() if !protoimpl.UnsafeEnabled { file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*PolicyRelationship); i { @@ -244,14 +177,13 @@ func file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_init( File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_rawDesc, - NumEnums: 1, + NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_goTypes, DependencyIndexes: file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_depIdxs, - EnumInfos: file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_enumTypes, MessageInfos: file_kessel_inventory_v1beta1_relationships_policy_relationship_proto_msgTypes, }.Build() File_kessel_inventory_v1beta1_relationships_policy_relationship_proto = out.File diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.validate.go index 1153acfa..99944d5e 100644 --- a/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.validate.go +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship.pb.validate.go @@ -57,13 +57,74 @@ func (m *PolicyRelationship) validate(all bool) error { var errors []error - // no validation rules for RelationshipType - - // no validation rules for PolicyId + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyRelationshipValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyRelationshipValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PolicyRelationshipValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } - // no validation rules for K8SClusterId + if m.GetRelationshipData() == nil { + err := PolicyRelationshipValidationError{ + field: "RelationshipData", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } - // no validation rules for Status + if all { + switch v := interface{}(m.GetRelationshipData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyRelationshipValidationError{ + field: "RelationshipData", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyRelationshipValidationError{ + field: "RelationshipData", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRelationshipData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PolicyRelationshipValidationError{ + field: "RelationshipData", + reason: "embedded message failed validation", + cause: err, + } + } + } if len(errors) > 0 { return PolicyRelationshipMultiError(errors) diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship.proto b/api/kessel/inventory/v1beta1/relationships/policy_relationship.proto index 24572463..e4f28d71 100644 --- a/api/kessel/inventory/v1beta1/relationships/policy_relationship.proto +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship.proto @@ -2,32 +2,18 @@ syntax = "proto3"; package kessel.inventory.v1beta1.relationships; +import "kessel/inventory/v1beta1/relationships/metadata.proto"; +import "kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto"; +import "validate/validate.proto"; + option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships"; option java_multiple_files = true; option java_package = "org.project_kessel.api.inventory.v1beta1.relationships"; message PolicyRelationship { - - // the aggregate status of the cluster - enum Status { - STATUS_UNSPECIFIED = 0; - STATUS_OTHER = 1; - NON_COMPLIANT = 2; - COMPLIANT = 3; - } - - // The type of Resource relationship - string relationship_type = 251000036; - // The resource ID assigned to the resource by Kessel Asset Inventory. A - // reporter alias may also be used as a resource ID using the format: - // \"hcrn::::\" - int64 policy_id = 225679544; - - // The resource ID assigned to the resource by Kessel Asset Inventory. A - // reporter alias may also be used as a resource ID using the format: - // \"hcrn::::\" - int64 k8s_cluster_id = 240280960; - - Status status = 355610639; + // Metadata about this resource + Metadata metadata = 1 [ (validate.rules).message = {required: false, skip: false} ]; + + PolicyRelationshipDetail relationship_data = 2122699 [ (validate.rules).message.required = true ]; } diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.go b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.go new file mode 100644 index 00000000..1d085ea4 --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.go @@ -0,0 +1,251 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto + +package relationships + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// the aggregate status of the cluster +type PolicyRelationshipDetail_Status int32 + +const ( + PolicyRelationshipDetail_STATUS_UNSPECIFIED PolicyRelationshipDetail_Status = 0 + PolicyRelationshipDetail_STATUS_OTHER PolicyRelationshipDetail_Status = 1 + PolicyRelationshipDetail_NON_COMPLIANT PolicyRelationshipDetail_Status = 2 + PolicyRelationshipDetail_COMPLIANT PolicyRelationshipDetail_Status = 3 +) + +// Enum value maps for PolicyRelationshipDetail_Status. +var ( + PolicyRelationshipDetail_Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_OTHER", + 2: "NON_COMPLIANT", + 3: "COMPLIANT", + } + PolicyRelationshipDetail_Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_OTHER": 1, + "NON_COMPLIANT": 2, + "COMPLIANT": 3, + } +) + +func (x PolicyRelationshipDetail_Status) Enum() *PolicyRelationshipDetail_Status { + p := new(PolicyRelationshipDetail_Status) + *p = x + return p +} + +func (x PolicyRelationshipDetail_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PolicyRelationshipDetail_Status) Descriptor() protoreflect.EnumDescriptor { + return file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_enumTypes[0].Descriptor() +} + +func (PolicyRelationshipDetail_Status) Type() protoreflect.EnumType { + return &file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_enumTypes[0] +} + +func (x PolicyRelationshipDetail_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PolicyRelationshipDetail_Status.Descriptor instead. +func (PolicyRelationshipDetail_Status) EnumDescriptor() ([]byte, []int) { + return file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescGZIP(), []int{0, 0} +} + +type PolicyRelationshipDetail struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The resource ID assigned to the resource by Kessel Asset Inventory. A + // reporter alias may also be used as a resource ID using the format: + // \"hcrn::::\" + K8SPolicyId int64 `protobuf:"varint,225679544,opt,name=k8s_policy_id,json=k8sPolicyId,proto3" json:"k8s_policy_id,omitempty"` + // The resource ID assigned to the resource by Kessel Asset Inventory. A + // reporter alias may also be used as a resource ID using the format: + // \"hcrn::::\" + K8SClusterId int64 `protobuf:"varint,240280960,opt,name=k8s_cluster_id,json=k8sClusterId,proto3" json:"k8s_cluster_id,omitempty"` + Status PolicyRelationshipDetail_Status `protobuf:"varint,355610639,opt,name=status,proto3,enum=kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail_Status" json:"status,omitempty"` +} + +func (x *PolicyRelationshipDetail) Reset() { + *x = PolicyRelationshipDetail{} + if protoimpl.UnsafeEnabled { + mi := &file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PolicyRelationshipDetail) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PolicyRelationshipDetail) ProtoMessage() {} + +func (x *PolicyRelationshipDetail) ProtoReflect() protoreflect.Message { + mi := &file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_msgTypes[0] + 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 PolicyRelationshipDetail.ProtoReflect.Descriptor instead. +func (*PolicyRelationshipDetail) Descriptor() ([]byte, []int) { + return file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescGZIP(), []int{0} +} + +func (x *PolicyRelationshipDetail) GetK8SPolicyId() int64 { + if x != nil { + return x.K8SPolicyId + } + return 0 +} + +func (x *PolicyRelationshipDetail) GetK8SClusterId() int64 { + if x != nil { + return x.K8SClusterId + } + return 0 +} + +func (x *PolicyRelationshipDetail) GetStatus() PolicyRelationshipDetail_Status { + if x != nil { + return x.Status + } + return PolicyRelationshipDetail_STATUS_UNSPECIFIED +} + +var File_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto protoreflect.FileDescriptor + +var file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDesc = []byte{ + 0x0a, 0x47, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x5f, 0x64, 0x65, 0x74, + 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x26, 0x6b, 0x65, 0x73, 0x73, 0x65, + 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, + 0x73, 0x22, 0xa5, 0x02, 0x0a, 0x18, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x25, + 0x0a, 0x0d, 0x6b, 0x38, 0x73, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x69, 0x64, 0x18, + 0xb8, 0xb1, 0xce, 0x6b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6b, 0x38, 0x73, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0e, 0x6b, 0x38, 0x73, 0x5f, 0x63, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x80, 0xcb, 0xc9, 0x72, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0c, 0x6b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x63, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x8f, 0xe0, 0xc8, 0xa9, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x47, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, + 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x2e, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x22, 0x54, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, + 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, + 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x4e, 0x5f, 0x43, + 0x4f, 0x4d, 0x50, 0x4c, 0x49, 0x41, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, + 0x4d, 0x50, 0x4c, 0x49, 0x41, 0x4e, 0x54, 0x10, 0x03, 0x42, 0x8e, 0x01, 0x0a, 0x36, 0x6f, 0x72, + 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x68, 0x69, 0x70, 0x73, 0x50, 0x01, 0x5a, 0x52, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x2d, 0x6b, 0x65, 0x73, 0x73, 0x65, + 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2d, 0x61, 0x70, 0x69, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, + 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescOnce sync.Once + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescData = file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDesc +) + +func file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescGZIP() []byte { + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescOnce.Do(func() { + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescData = protoimpl.X.CompressGZIP(file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescData) + }) + return file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDescData +} + +var file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_goTypes = []any{ + (PolicyRelationshipDetail_Status)(0), // 0: kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail.Status + (*PolicyRelationshipDetail)(nil), // 1: kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail +} +var file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_depIdxs = []int32{ + 0, // 0: kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail.status:type_name -> kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail.Status + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_init() } +func file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_init() { + if File_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*PolicyRelationshipDetail); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_goTypes, + DependencyIndexes: file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_depIdxs, + EnumInfos: file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_enumTypes, + MessageInfos: file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_msgTypes, + }.Build() + File_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto = out.File + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_rawDesc = nil + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_goTypes = nil + file_kessel_inventory_v1beta1_relationships_policy_relationship_detail_proto_depIdxs = nil +} diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.validate.go new file mode 100644 index 00000000..1577ba9c --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.pb.validate.go @@ -0,0 +1,144 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto + +package relationships + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on PolicyRelationshipDetail 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 *PolicyRelationshipDetail) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PolicyRelationshipDetail 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 +// PolicyRelationshipDetailMultiError, or nil if none found. +func (m *PolicyRelationshipDetail) ValidateAll() error { + return m.validate(true) +} + +func (m *PolicyRelationshipDetail) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for K8SPolicyId + + // no validation rules for K8SClusterId + + // no validation rules for Status + + if len(errors) > 0 { + return PolicyRelationshipDetailMultiError(errors) + } + + return nil +} + +// PolicyRelationshipDetailMultiError is an error wrapping multiple validation +// errors returned by PolicyRelationshipDetail.ValidateAll() if the designated +// constraints aren't met. +type PolicyRelationshipDetailMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PolicyRelationshipDetailMultiError) 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 PolicyRelationshipDetailMultiError) AllErrors() []error { return m } + +// PolicyRelationshipDetailValidationError is the validation error returned by +// PolicyRelationshipDetail.Validate if the designated constraints aren't met. +type PolicyRelationshipDetailValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PolicyRelationshipDetailValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PolicyRelationshipDetailValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PolicyRelationshipDetailValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PolicyRelationshipDetailValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PolicyRelationshipDetailValidationError) ErrorName() string { + return "PolicyRelationshipDetailValidationError" +} + +// Error satisfies the builtin error interface +func (e PolicyRelationshipDetailValidationError) 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 %sPolicyRelationshipDetail.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PolicyRelationshipDetailValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PolicyRelationshipDetailValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto new file mode 100644 index 00000000..cf6f0ff3 --- /dev/null +++ b/api/kessel/inventory/v1beta1/relationships/policy_relationship_detail.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package kessel.inventory.v1beta1.relationships; + +option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships"; +option java_multiple_files = true; +option java_package = "org.project_kessel.api.inventory.v1beta1.relationships"; + +message PolicyRelationshipDetail { + + + // the aggregate status of the cluster + enum Status { + STATUS_UNSPECIFIED = 0; + STATUS_OTHER = 1; + NON_COMPLIANT = 2; + COMPLIANT = 3; + } + + // The resource ID assigned to the resource by Kessel Asset Inventory. A + // reporter alias may also be used as a resource ID using the format: + // \"hcrn::::\" + int64 k8s_policy_id = 225679544; + + // The resource ID assigned to the resource by Kessel Asset Inventory. A + // reporter alias may also be used as a resource ID using the format: + // \"hcrn::::\" + int64 k8s_cluster_id = 240280960; + + Status status = 355610639; +} diff --git a/go.mod b/go.mod index 8541bd95..d78b92d0 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( github.com/gorilla/mux v1.8.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect @@ -48,6 +49,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -71,11 +73,14 @@ require ( go.uber.org/zap v1.21.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect + golang.org/x/mod v0.18.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index fb51a8cd..f05e4cf8 100644 --- a/go.sum +++ b/go.sum @@ -218,6 +218,8 @@ github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mO github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/in-toto/in-toto-golang v0.5.0 h1:hb8bgwr0M2hGdDsLjkJ3ZqJ8JFLL/tgYdAxF/XEFBbY= @@ -258,6 +260,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a h1:N9zuLhTvBSRt0gWSiJswwQ2HqDmtX/ZCDJURnKUt1Ik= github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE= +github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4 h1:sIXJOMrYnQZJu7OB7ANSF4MYri2fTEGIsRLz6LwI4xE= +github.com/lyft/protoc-gen-star/v2 v2.0.4-0.20230330145011-496ad1ac90a4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -500,6 +504,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= +golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -583,6 +589,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= +golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -605,6 +613,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= diff --git a/openapi.yaml b/openapi.yaml index a6dc3c67..aee91a81 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -506,13 +506,48 @@ components: kessel.inventory.v1beta1.relationships.DeleteResourceRelationshipByUrnResponse: type: object properties: {} - kessel.inventory.v1beta1.relationships.PolicyRelationship: + kessel.inventory.v1beta1.relationships.Metadata: type: object properties: + id: + readOnly: true + type: string + description: Kessel Asset Inventory generated identifier. relationship_type: + readOnly: true type: string description: The type of Resource relationship - policy_id: + first_reported: + readOnly: true + type: string + description: Date and time when the inventory item was first reported. + format: date-time + last_reported: + readOnly: true + type: string + description: Date and time when the inventory item was last updated. + format: date-time + first_reported_by: + readOnly: true + type: string + description: Identifier of the reporter that first reported on this item. + last_reported_by: + readOnly: true + type: string + description: Identifier of the reporter that last reported on this item. + kessel.inventory.v1beta1.relationships.PolicyRelationship: + type: object + properties: + metadata: + allOf: + - $ref: '#/components/schemas/kessel.inventory.v1beta1.relationships.Metadata' + description: Metadata about this resource + relationship_data: + $ref: '#/components/schemas/kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail' + kessel.inventory.v1beta1.relationships.PolicyRelationshipDetail: + type: object + properties: + k8s_policy_id: type: string description: |- The resource ID assigned to the resource by Kessel Asset Inventory. A From 182c25eca1aaa95b1b999de80d3fd1b3eb220690 Mon Sep 17 00:00:00 2001 From: Randy George Date: Fri, 30 Aug 2024 13:32:34 -0500 Subject: [PATCH 2/3] Update metadata.pb.validate_test.go --- .../v1beta1/relationships/metadata.pb.validate_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go index f1546b77..4bcb635c 100644 --- a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go +++ b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go @@ -13,12 +13,6 @@ func TestMetadataValid(t *testing.T) { assert.NoError(t, err) } -func TestMetadataInvalidLabels(t *testing.T) { - meta := Metadata{ - Labels: []*ResourceLabel{ - {}, - }, - } err := meta.ValidateAll() assert.ErrorContains(t, err, "invalid Metadata.Labels[0]") From 372d1d95250565c54326442c55b33851ee34240c Mon Sep 17 00:00:00 2001 From: Randy George Date: Fri, 30 Aug 2024 13:36:25 -0500 Subject: [PATCH 3/3] Delete metadata.pb.validate_test.go --- .../metadata.pb.validate_test.go | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go deleted file mode 100644 index 4bcb635c..00000000 --- a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package relationships - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestMetadataValid(t *testing.T) { - meta := Metadata{} - err := meta.ValidateAll() - - assert.NoError(t, err) -} - - - err := meta.ValidateAll() - assert.ErrorContains(t, err, "invalid Metadata.Labels[0]") -}