From c6f6d495cbd635c310c613e1976fa5e37ac731d8 Mon Sep 17 00:00:00 2001 From: Jonathan Marcantonio Date: Tue, 3 Sep 2024 09:57:58 -0400 Subject: [PATCH] RHCLOUD-34798 - Upgrade to protovalidate to handle message validation (#57) * Update validation around proto files Signed-off-by: Jonathan Marcantonio * Add validation middleware & remove validateAll calls from services Signed-off-by: Jonathan Marcantonio * Update cluster & policy validation Signed-off-by: Jonathan Marcantonio * Rebase & update validation test Signed-off-by: Jonathan Marcantonio * Rebase Signed-off-by: Jonathan Marcantonio * Rebase & update few protos Signed-off-by: Jonathan Marcantonio * Rebase again :( Signed-off-by: Jonathan Marcantonio * Rebase Signed-off-by: Jonathan Marcantonio --------- Signed-off-by: Jonathan Marcantonio --- api/Dockerfile | 2 - api/buf.gen.yaml | 5 - api/buf.lock | 6 +- api/buf.yaml | 2 +- api/kessel/inventory/v1/health.pb.validate.go | 446 ---------- .../k8spolicy_ispropagatedto_k8scluster.pb.go | 64 +- ...y_ispropagatedto_k8scluster.pb.validate.go | 250 ------ .../k8spolicy_ispropagatedto_k8scluster.proto | 8 +- ...pagatedto_k8scluster_detail.pb.validate.go | 148 ---- ...agatedto_k8scluster_service.pb.validate.go | 796 ------------------ .../relationships/metadata.pb.validate.go | 201 ----- .../v1beta1/relationships/reporter_data.pb.go | 106 +-- .../reporter_data.pb.validate.go | 245 ------ .../v1beta1/relationships/reporter_data.proto | 8 +- ...ip_by_urnhs_hcrns_parameter.pb.validate.go | 151 ---- ...y_urnhs_resources_parameter.pb.validate.go | 154 ---- .../v1beta1/resources/k8s_cluster.pb.go | 62 +- .../resources/k8s_cluster.pb.validate.go | 244 ------ .../resources/k8s_cluster.pb.validate_test.go | 86 -- .../v1beta1/resources/k8s_cluster.proto | 6 +- .../resources/k8s_cluster_detail.pb.go | 179 ++-- .../k8s_cluster_detail.pb.validate.go | 294 ------- .../resources/k8s_cluster_detail.proto | 14 +- .../k8s_cluster_detail_nodes_inner.pb.go | 64 +- ..._cluster_detail_nodes_inner.pb.validate.go | 216 ----- ...ter_detail_nodes_inner.pb.validate_test.go | 118 --- .../k8s_cluster_detail_nodes_inner.proto | 10 +- .../k8s_clusters_service.pb.validate.go | 768 ----------------- .../k8s_policies_service.pb.validate.go | 739 ---------------- .../v1beta1/resources/k8s_policy.pb.go | 60 +- .../resources/k8s_policy.pb.validate.go | 244 ------ .../resources/k8s_policy.pb.validate_test.go | 58 -- .../v1beta1/resources/k8s_policy.proto | 6 +- .../v1beta1/resources/k8s_policy_detail.pb.go | 57 +- .../k8s_policy_detail.pb.validate.go | 149 ---- .../v1beta1/resources/k8s_policy_detail.proto | 4 +- .../v1beta1/resources/metadata.pb.validate.go | 237 ------ .../resources/metadata.pb.validate_test.go | 34 - .../resources/notifications_integration.pb.go | 62 +- .../notifications_integration.pb.validate.go | 207 ----- ...ifications_integration.pb.validate_test.go | 44 - .../resources/notifications_integration.proto | 4 +- ...ations_integrations_service.pb.validate.go | 760 ----------------- .../v1beta1/resources/reporter_data.pb.go | 101 +-- .../resources/reporter_data.pb.validate.go | 238 ------ .../reporter_data.pb.validate_test.go | 48 -- .../v1beta1/resources/reporter_data.proto | 6 +- .../v1beta1/resources/resource_label.pb.go | 36 +- .../resources/resource_label.pb.validate.go | 158 ---- .../resource_label.pb.validate_test.go | 49 -- .../v1beta1/resources/resource_label.proto | 6 +- .../v1beta1/resources/rhel_host.pb.go | 58 +- .../resources/rhel_host.pb.validate.go | 204 ----- .../resources/rhel_host.pb.validate_test.go | 44 - .../v1beta1/resources/rhel_host.proto | 6 +- .../resources/rhel_hosts_service.pb.go | 44 +- .../rhel_hosts_service.pb.validate.go | 750 ----------------- .../resources/rhel_hosts_service.proto | 10 +- go.mod | 10 +- go.sum | 16 + internal/middleware/validation.go | 23 + internal/middleware/validation_test.go | 52 ++ internal/server/grpc/grpc.go | 8 +- internal/server/http/http.go | 7 + internal/service/hosts/hosts.go | 11 - internal/service/hosts/hosts_test.go | 23 - internal/service/k8sclusters/k8scluster.go | 4 - internal/service/k8spolicies/k8spolicies.go | 5 - .../notificationsintegrations.go | 11 - .../notificationsintegrations_test.go | 24 - 70 files changed, 610 insertions(+), 8660 deletions(-) delete mode 100644 api/kessel/inventory/v1/health.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_detail.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_service.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/reporter_data.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_hcrns_parameter.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_resources_parameter.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_clusters_service.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_policies_service.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/metadata.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/metadata.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/notifications_integrations_service.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/resource_label.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/resource_label.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate.go delete mode 100644 api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate_test.go delete mode 100644 api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.validate.go create mode 100644 internal/middleware/validation.go create mode 100644 internal/middleware/validation_test.go diff --git a/api/Dockerfile b/api/Dockerfile index 4b874309..6f59c149 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -14,7 +14,6 @@ RUN ln -s /usr/local/go/bin/go /usr/local/bin/go RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 RUN go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@v2.0.0-20240725023016-d6fca5e3e984 -RUN go install github.com/envoyproxy/protoc-gen-validate@v1.1.0 RUN go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 # Install Buf @@ -27,6 +26,5 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10-1052.1724178568 COPY --from=builder /root/go/bin/protoc-gen-go /usr/local/bin/protoc-gen-go COPY --from=builder /root/go/bin/protoc-gen-go-grpc /usr/local/bin/protoc-gen-go-grpc COPY --from=builder /root/go/bin/protoc-gen-go-http /usr/local/bin/protoc-gen-go-http -COPY --from=builder /root/go/bin/protoc-gen-validate /usr/local/bin/protoc-gen-validate COPY --from=builder /root/go/bin/protoc-gen-openapi /usr/local/bin/protoc-gen-openapi COPY --from=builder /root/go/bin/buf /usr/local/bin/buf diff --git a/api/buf.gen.yaml b/api/buf.gen.yaml index 7e3fb23b..91ab5e7b 100644 --- a/api/buf.gen.yaml +++ b/api/buf.gen.yaml @@ -15,8 +15,3 @@ plugins: - fq_schema_naming=true - default_response=true - naming=proto - - local: protoc-gen-validate - opt: - - paths=source_relative - - lang=go - out: . diff --git a/api/buf.lock b/api/buf.lock index 41ca05cd..0b2cbf63 100644 --- a/api/buf.lock +++ b/api/buf.lock @@ -1,9 +1,9 @@ # Generated by buf. DO NOT EDIT. version: v2 deps: - - name: buf.build/envoyproxy/protoc-gen-validate - commit: daf171c6cdb54629b5f51e345a79e4dd - digest: b5:c745e1521879f43740230b1df673d0729f55704efefdcfc489d4a0a2d40c92a26cacfeab62813403040a8b180142d53b398c7ca784a065e43823605ee49681de + - name: buf.build/bufbuild/protovalidate + commit: a6c49f84cc0f4e038680d390392e2ab0 + digest: b5:e968392e88ff7915adcbd1635d670b45bff8836ec2415d81fc559ca5470a695dbdc30030bad8bc5764647c731079e9e7bba0023ea25c4e4a1672a7d2561d4a19 - name: buf.build/googleapis/googleapis commit: 8bc2c51e08c447cd8886cdea48a73e14 digest: b5:b7e0ac9d192bd0eae88160101269550281448c51f25121cd0d51957661a350aab07001bc145fe9029a8da10b99ff000ae5b284ecaca9c75f2a99604a04d9b4ab diff --git a/api/buf.yaml b/api/buf.yaml index fda3b38a..698e8398 100644 --- a/api/buf.yaml +++ b/api/buf.yaml @@ -13,4 +13,4 @@ breaking: - kessel/inventory/v1beta1 deps: - buf.build/googleapis/googleapis - - buf.build/envoyproxy/protoc-gen-validate + - buf.build/bufbuild/protovalidate diff --git a/api/kessel/inventory/v1/health.pb.validate.go b/api/kessel/inventory/v1/health.pb.validate.go deleted file mode 100644 index 7aa11171..00000000 --- a/api/kessel/inventory/v1/health.pb.validate.go +++ /dev/null @@ -1,446 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1/health.proto - -package v1 - -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 GetLivezRequest 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 *GetLivezRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetLivezRequest 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 -// GetLivezRequestMultiError, or nil if none found. -func (m *GetLivezRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetLivezRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetLivezRequestMultiError(errors) - } - - return nil -} - -// GetLivezRequestMultiError is an error wrapping multiple validation errors -// returned by GetLivezRequest.ValidateAll() if the designated constraints -// aren't met. -type GetLivezRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetLivezRequestMultiError) 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 GetLivezRequestMultiError) AllErrors() []error { return m } - -// GetLivezRequestValidationError is the validation error returned by -// GetLivezRequest.Validate if the designated constraints aren't met. -type GetLivezRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetLivezRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetLivezRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetLivezRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetLivezRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetLivezRequestValidationError) ErrorName() string { return "GetLivezRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetLivezRequestValidationError) 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 %sGetLivezRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetLivezRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetLivezRequestValidationError{} - -// Validate checks the field values on GetLivezResponse 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 *GetLivezResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetLivezResponse 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 -// GetLivezResponseMultiError, or nil if none found. -func (m *GetLivezResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetLivezResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Status - - // no validation rules for Code - - if len(errors) > 0 { - return GetLivezResponseMultiError(errors) - } - - return nil -} - -// GetLivezResponseMultiError is an error wrapping multiple validation errors -// returned by GetLivezResponse.ValidateAll() if the designated constraints -// aren't met. -type GetLivezResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetLivezResponseMultiError) 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 GetLivezResponseMultiError) AllErrors() []error { return m } - -// GetLivezResponseValidationError is the validation error returned by -// GetLivezResponse.Validate if the designated constraints aren't met. -type GetLivezResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetLivezResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetLivezResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetLivezResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetLivezResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetLivezResponseValidationError) ErrorName() string { return "GetLivezResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetLivezResponseValidationError) 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 %sGetLivezResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetLivezResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetLivezResponseValidationError{} - -// Validate checks the field values on GetReadyzRequest 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 *GetReadyzRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetReadyzRequest 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 -// GetReadyzRequestMultiError, or nil if none found. -func (m *GetReadyzRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetReadyzRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetReadyzRequestMultiError(errors) - } - - return nil -} - -// GetReadyzRequestMultiError is an error wrapping multiple validation errors -// returned by GetReadyzRequest.ValidateAll() if the designated constraints -// aren't met. -type GetReadyzRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetReadyzRequestMultiError) 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 GetReadyzRequestMultiError) AllErrors() []error { return m } - -// GetReadyzRequestValidationError is the validation error returned by -// GetReadyzRequest.Validate if the designated constraints aren't met. -type GetReadyzRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetReadyzRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetReadyzRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetReadyzRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetReadyzRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetReadyzRequestValidationError) ErrorName() string { return "GetReadyzRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetReadyzRequestValidationError) 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 %sGetReadyzRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetReadyzRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetReadyzRequestValidationError{} - -// Validate checks the field values on GetReadyzResponse 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 *GetReadyzResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetReadyzResponse 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 -// GetReadyzResponseMultiError, or nil if none found. -func (m *GetReadyzResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetReadyzResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Status - - // no validation rules for Code - - if len(errors) > 0 { - return GetReadyzResponseMultiError(errors) - } - - return nil -} - -// GetReadyzResponseMultiError is an error wrapping multiple validation errors -// returned by GetReadyzResponse.ValidateAll() if the designated constraints -// aren't met. -type GetReadyzResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetReadyzResponseMultiError) 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 GetReadyzResponseMultiError) AllErrors() []error { return m } - -// GetReadyzResponseValidationError is the validation error returned by -// GetReadyzResponse.Validate if the designated constraints aren't met. -type GetReadyzResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetReadyzResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetReadyzResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetReadyzResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetReadyzResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetReadyzResponseValidationError) ErrorName() string { - return "GetReadyzResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetReadyzResponseValidationError) 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 %sGetReadyzResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetReadyzResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetReadyzResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.go b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.go index 7a1225fb..0769affa 100644 --- a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.go +++ b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.go @@ -7,7 +7,7 @@ package relationships import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -109,41 +109,41 @@ var file_kessel_inventory_v1beta1_relationships_k8spolicy_ispropagatedto_k8sclus 0x73, 0x68, 0x69, 0x70, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x69, 0x73, 0x70, 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61, 0x74, 0x65, 0x64, 0x74, 0x6f, 0x5f, 0x6b, 0x38, 0x73, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 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, - 0xf1, 0x02, 0x0a, 0x21, 0x4b, 0x38, 0x53, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x73, 0x50, - 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x4b, 0x38, 0x53, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 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, - 0x66, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xe9, 0x02, 0x0a, 0x21, 0x4b, 0x38, 0x53, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x49, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x4b, + 0x38, 0x53, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x54, 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, 0x06, 0xba, + 0x48, 0x03, 0xd8, 0x01, 0x03, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, + 0x64, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc9, 0xd0, 0xfa, 0x74, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 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, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, - 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x89, 0x01, 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, 0x4f, 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, - 0x4b, 0x38, 0x53, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x61, - 0x67, 0x61, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x4b, 0x38, 0x53, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 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, + 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x87, 0x01, 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, 0x4f, 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, 0x4b, 0x38, + 0x53, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61, + 0x74, 0x65, 0x64, 0x54, 0x6f, 0x4b, 0x38, 0x53, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 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 ( diff --git a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.validate.go deleted file mode 100644 index 4f845db0..00000000 --- a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.pb.validate.go +++ /dev/null @@ -1,250 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.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 K8SPolicyIsPropagatedToK8SCluster 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 *K8SPolicyIsPropagatedToK8SCluster) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SPolicyIsPropagatedToK8SCluster -// 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 -// K8SPolicyIsPropagatedToK8SClusterMultiError, or nil if none found. -func (m *K8SPolicyIsPropagatedToK8SCluster) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SPolicyIsPropagatedToK8SCluster) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMetadata()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - 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 K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetReporterData() == nil { - err := K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "ReporterData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetReporterData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetReporterData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetRelationshipData() == nil { - err := K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "RelationshipData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetRelationshipData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "RelationshipData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyIsPropagatedToK8SClusterValidationError{ - 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 K8SPolicyIsPropagatedToK8SClusterValidationError{ - field: "RelationshipData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return K8SPolicyIsPropagatedToK8SClusterMultiError(errors) - } - - return nil -} - -// K8SPolicyIsPropagatedToK8SClusterMultiError is an error wrapping multiple -// validation errors returned by -// K8SPolicyIsPropagatedToK8SCluster.ValidateAll() if the designated -// constraints aren't met. -type K8SPolicyIsPropagatedToK8SClusterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SPolicyIsPropagatedToK8SClusterMultiError) 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 K8SPolicyIsPropagatedToK8SClusterMultiError) AllErrors() []error { return m } - -// K8SPolicyIsPropagatedToK8SClusterValidationError is the validation error -// returned by K8SPolicyIsPropagatedToK8SCluster.Validate if the designated -// constraints aren't met. -type K8SPolicyIsPropagatedToK8SClusterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) ErrorName() string { - return "K8SPolicyIsPropagatedToK8SClusterValidationError" -} - -// Error satisfies the builtin error interface -func (e K8SPolicyIsPropagatedToK8SClusterValidationError) 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 %sK8SPolicyIsPropagatedToK8SCluster.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SPolicyIsPropagatedToK8SClusterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SPolicyIsPropagatedToK8SClusterValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.proto b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.proto index f8af3a92..720d1435 100644 --- a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.proto +++ b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster.proto @@ -5,7 +5,7 @@ package kessel.inventory.v1beta1.relationships; import "kessel/inventory/v1beta1/relationships/metadata.proto"; import "kessel/inventory/v1beta1/relationships/reporter_data.proto"; import "kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_detail.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships"; option java_multiple_files = true; @@ -14,10 +14,10 @@ option java_package = "org.project_kessel.api.inventory.v1beta1.relationships"; message K8SPolicyIsPropagatedToK8SCluster { // Metadata about this resource - Metadata metadata = 1 [ (validate.rules).message = {required: false, skip: false} ]; + Metadata metadata = 1 [ (buf.validate.field) = {required: false, ignore: IGNORE_ALWAYS} ]; // Write only reporter specific data - ReporterData reporter_data = 245278793 [ (validate.rules).message.required = true ]; + ReporterData reporter_data = 245278793 [ (buf.validate.field).required = true ]; - K8SPolicyIsPropagatedToK8SClusterDetail relationship_data = 2122699 [ (validate.rules).message.required = true ]; + K8SPolicyIsPropagatedToK8SClusterDetail relationship_data = 2122699 [ (buf.validate.field).required = true ]; } diff --git a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_detail.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_detail.pb.validate.go deleted file mode 100644 index 877ac856..00000000 --- a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_detail.pb.validate.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_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 K8SPolicyIsPropagatedToK8SClusterDetail -// 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 *K8SPolicyIsPropagatedToK8SClusterDetail) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// K8SPolicyIsPropagatedToK8SClusterDetail 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 -// K8SPolicyIsPropagatedToK8SClusterDetailMultiError, or nil if none found. -func (m *K8SPolicyIsPropagatedToK8SClusterDetail) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SPolicyIsPropagatedToK8SClusterDetail) 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 K8SPolicyIsPropagatedToK8SClusterDetailMultiError(errors) - } - - return nil -} - -// K8SPolicyIsPropagatedToK8SClusterDetailMultiError is an error wrapping -// multiple validation errors returned by -// K8SPolicyIsPropagatedToK8SClusterDetail.ValidateAll() if the designated -// constraints aren't met. -type K8SPolicyIsPropagatedToK8SClusterDetailMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SPolicyIsPropagatedToK8SClusterDetailMultiError) 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 K8SPolicyIsPropagatedToK8SClusterDetailMultiError) AllErrors() []error { return m } - -// K8SPolicyIsPropagatedToK8SClusterDetailValidationError is the validation -// error returned by K8SPolicyIsPropagatedToK8SClusterDetail.Validate if the -// designated constraints aren't met. -type K8SPolicyIsPropagatedToK8SClusterDetailValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) ErrorName() string { - return "K8SPolicyIsPropagatedToK8SClusterDetailValidationError" -} - -// Error satisfies the builtin error interface -func (e K8SPolicyIsPropagatedToK8SClusterDetailValidationError) 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 %sK8SPolicyIsPropagatedToK8SClusterDetail.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SPolicyIsPropagatedToK8SClusterDetailValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SPolicyIsPropagatedToK8SClusterDetailValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_service.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_service.pb.validate.go deleted file mode 100644 index 5096ba17..00000000 --- a/api/kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_service.pb.validate.go +++ /dev/null @@ -1,796 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/k8spolicy_ispropagatedto_k8scluster_service.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 -// CreateK8SPolicyIsPropagatedToK8SClusterRequest 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 *CreateK8SPolicyIsPropagatedToK8SClusterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// CreateK8SPolicyIsPropagatedToK8SClusterRequest 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 -// CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError, or nil if none found. -func (m *CreateK8SPolicyIsPropagatedToK8SClusterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SPolicyIsPropagatedToK8SClusterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPolicyRelationship()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError{ - field: "PolicyRelationship", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError{ - field: "PolicyRelationship", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPolicyRelationship()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError{ - field: "PolicyRelationship", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError(errors) - } - - return nil -} - -// CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError is an error -// wrapping multiple validation errors returned by -// CreateK8SPolicyIsPropagatedToK8SClusterRequest.ValidateAll() if the -// designated constraints aren't met. -type CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError) 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 CreateK8SPolicyIsPropagatedToK8SClusterRequestMultiError) AllErrors() []error { return m } - -// CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError is the -// validation error returned by -// CreateK8SPolicyIsPropagatedToK8SClusterRequest.Validate if the designated -// constraints aren't met. -type CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) Reason() string { - return e.reason -} - -// Cause function returns cause value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) ErrorName() string { - return "CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError) 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 %sCreateK8SPolicyIsPropagatedToK8SClusterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SPolicyIsPropagatedToK8SClusterRequestValidationError{} - -// Validate checks the field values on -// CreateK8SPolicyIsPropagatedToK8SClusterResponse 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 *CreateK8SPolicyIsPropagatedToK8SClusterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// CreateK8SPolicyIsPropagatedToK8SClusterResponse 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 -// CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError, or nil if none found. -func (m *CreateK8SPolicyIsPropagatedToK8SClusterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SPolicyIsPropagatedToK8SClusterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError(errors) - } - - return nil -} - -// CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError is an error -// wrapping multiple validation errors returned by -// CreateK8SPolicyIsPropagatedToK8SClusterResponse.ValidateAll() if the -// designated constraints aren't met. -type CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError) 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 CreateK8SPolicyIsPropagatedToK8SClusterResponseMultiError) AllErrors() []error { return m } - -// CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError is the -// validation error returned by -// CreateK8SPolicyIsPropagatedToK8SClusterResponse.Validate if the designated -// constraints aren't met. -type CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) Field() string { - return e.field -} - -// Reason function returns reason value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) Reason() string { - return e.reason -} - -// Cause function returns cause value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) ErrorName() string { - return "CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError) 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 %sCreateK8SPolicyIsPropagatedToK8SClusterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SPolicyIsPropagatedToK8SClusterResponseValidationError{} - -// Validate checks the field values on UpdateResourceRelationshipByUrnHsRequest -// 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 *UpdateResourceRelationshipByUrnHsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// UpdateResourceRelationshipByUrnHsRequest 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 -// UpdateResourceRelationshipByUrnHsRequestMultiError, or nil if none found. -func (m *UpdateResourceRelationshipByUrnHsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRelationshipByUrnHsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResources()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResources()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetK8SpolicyIspropagatedtoK8Scluster()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "K8SpolicyIspropagatedtoK8Scluster", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "K8SpolicyIspropagatedtoK8Scluster", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SpolicyIspropagatedtoK8Scluster()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateResourceRelationshipByUrnHsRequestValidationError{ - field: "K8SpolicyIspropagatedtoK8Scluster", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateResourceRelationshipByUrnHsRequestMultiError(errors) - } - - return nil -} - -// UpdateResourceRelationshipByUrnHsRequestMultiError is an error wrapping -// multiple validation errors returned by -// UpdateResourceRelationshipByUrnHsRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceRelationshipByUrnHsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRelationshipByUrnHsRequestMultiError) 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 UpdateResourceRelationshipByUrnHsRequestMultiError) AllErrors() []error { return m } - -// UpdateResourceRelationshipByUrnHsRequestValidationError is the validation -// error returned by UpdateResourceRelationshipByUrnHsRequest.Validate if the -// designated constraints aren't met. -type UpdateResourceRelationshipByUrnHsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) ErrorName() string { - return "UpdateResourceRelationshipByUrnHsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRelationshipByUrnHsRequestValidationError) 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 %sUpdateResourceRelationshipByUrnHsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRelationshipByUrnHsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRelationshipByUrnHsRequestValidationError{} - -// Validate checks the field values on -// UpdateResourceRelationshipByUrnHsResponse 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 *UpdateResourceRelationshipByUrnHsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// UpdateResourceRelationshipByUrnHsResponse 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 -// UpdateResourceRelationshipByUrnHsResponseMultiError, or nil if none found. -func (m *UpdateResourceRelationshipByUrnHsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRelationshipByUrnHsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdateResourceRelationshipByUrnHsResponseMultiError(errors) - } - - return nil -} - -// UpdateResourceRelationshipByUrnHsResponseMultiError is an error wrapping -// multiple validation errors returned by -// UpdateResourceRelationshipByUrnHsResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceRelationshipByUrnHsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRelationshipByUrnHsResponseMultiError) 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 UpdateResourceRelationshipByUrnHsResponseMultiError) AllErrors() []error { return m } - -// UpdateResourceRelationshipByUrnHsResponseValidationError is the validation -// error returned by UpdateResourceRelationshipByUrnHsResponse.Validate if the -// designated constraints aren't met. -type UpdateResourceRelationshipByUrnHsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) ErrorName() string { - return "UpdateResourceRelationshipByUrnHsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRelationshipByUrnHsResponseValidationError) 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 %sUpdateResourceRelationshipByUrnHsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRelationshipByUrnHsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRelationshipByUrnHsResponseValidationError{} - -// Validate checks the field values on DeleteResourceRelationshipByUrnRequest -// 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 *DeleteResourceRelationshipByUrnRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// DeleteResourceRelationshipByUrnRequest 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 -// DeleteResourceRelationshipByUrnRequestMultiError, or nil if none found. -func (m *DeleteResourceRelationshipByUrnRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceRelationshipByUrnRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResources()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteResourceRelationshipByUrnRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteResourceRelationshipByUrnRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResources()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteResourceRelationshipByUrnRequestValidationError{ - field: "Resources", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteResourceRelationshipByUrnRequestMultiError(errors) - } - - return nil -} - -// DeleteResourceRelationshipByUrnRequestMultiError is an error wrapping -// multiple validation errors returned by -// DeleteResourceRelationshipByUrnRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceRelationshipByUrnRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceRelationshipByUrnRequestMultiError) 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 DeleteResourceRelationshipByUrnRequestMultiError) AllErrors() []error { return m } - -// DeleteResourceRelationshipByUrnRequestValidationError is the validation -// error returned by DeleteResourceRelationshipByUrnRequest.Validate if the -// designated constraints aren't met. -type DeleteResourceRelationshipByUrnRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceRelationshipByUrnRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceRelationshipByUrnRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceRelationshipByUrnRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceRelationshipByUrnRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceRelationshipByUrnRequestValidationError) ErrorName() string { - return "DeleteResourceRelationshipByUrnRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceRelationshipByUrnRequestValidationError) 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 %sDeleteResourceRelationshipByUrnRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceRelationshipByUrnRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceRelationshipByUrnRequestValidationError{} - -// Validate checks the field values on DeleteResourceRelationshipByUrnResponse -// 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 *DeleteResourceRelationshipByUrnResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// DeleteResourceRelationshipByUrnResponse 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 -// DeleteResourceRelationshipByUrnResponseMultiError, or nil if none found. -func (m *DeleteResourceRelationshipByUrnResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceRelationshipByUrnResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteResourceRelationshipByUrnResponseMultiError(errors) - } - - return nil -} - -// DeleteResourceRelationshipByUrnResponseMultiError is an error wrapping -// multiple validation errors returned by -// DeleteResourceRelationshipByUrnResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceRelationshipByUrnResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceRelationshipByUrnResponseMultiError) 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 DeleteResourceRelationshipByUrnResponseMultiError) AllErrors() []error { return m } - -// DeleteResourceRelationshipByUrnResponseValidationError is the validation -// error returned by DeleteResourceRelationshipByUrnResponse.Validate if the -// designated constraints aren't met. -type DeleteResourceRelationshipByUrnResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceRelationshipByUrnResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceRelationshipByUrnResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceRelationshipByUrnResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceRelationshipByUrnResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceRelationshipByUrnResponseValidationError) ErrorName() string { - return "DeleteResourceRelationshipByUrnResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceRelationshipByUrnResponseValidationError) 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 %sDeleteResourceRelationshipByUrnResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceRelationshipByUrnResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceRelationshipByUrnResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go deleted file mode 100644 index 1a36feb0..00000000 --- a/api/kessel/inventory/v1beta1/relationships/metadata.pb.validate.go +++ /dev/null @@ -1,201 +0,0 @@ -// 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/reporter_data.pb.go b/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.go index 8d3ad0e7..ddfa5e28 100644 --- a/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.go +++ b/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.go @@ -7,7 +7,7 @@ package relationships import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -198,59 +198,59 @@ var file_kessel_inventory_v1beta1_relationships_reporter_data_proto_rawDesc = [] 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, 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, - 0x87, 0x05, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x75, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0xd9, 0x8f, 0x99, 0x75, 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, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x42, 0x0a, 0xfa, - 0x42, 0x07, 0x82, 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0xba, 0xd5, 0xfa, 0x72, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x12, 0x72, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, - 0x64, 0x12, 0x2d, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xfb, 0xee, 0xc8, 0x80, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 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, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x88, 0x05, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x76, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0xd9, 0x8f, 0x99, 0x75, 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, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, + 0x65, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x82, 0x01, 0x05, 0x10, 0x01, 0x22, 0x01, 0x00, 0x52, 0x0c, + 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x14, + 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0xba, 0xd5, 0xfa, 0x72, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, + 0x41, 0x03, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xfb, 0xee, 0xc8, 0x80, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 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, 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, 0x46, 0x0a, 0x19, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0xbe, 0xb8, 0xd9, 0xf2, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, - 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x16, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x6f, - 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x44, 0x0a, - 0x18, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0xbf, 0xb8, 0xd9, 0xf2, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x15, 0x6f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x49, 0x64, 0x22, 0x74, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x52, 0x5f, - 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, - 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x52, 0x5f, 0x54, - 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, - 0x43, 0x4d, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x48, 0x42, 0x49, 0x10, 0x03, 0x12, 0x07, 0x0a, - 0x03, 0x4f, 0x43, 0x4d, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x49, - 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x05, 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, + 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, 0x46, 0x0a, 0x19, 0x73, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0xbe, 0xb8, 0xd9, 0xf2, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x16, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x49, 0x64, 0x12, 0x44, 0x0a, 0x18, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0xbf, + 0xb8, 0xd9, 0xf2, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, + 0x01, 0x52, 0x15, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x22, 0x74, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x50, 0x4f, + 0x52, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, + 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x50, 0x4f, 0x52, + 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, + 0x12, 0x07, 0x0a, 0x03, 0x41, 0x43, 0x4d, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x48, 0x42, 0x49, + 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x4d, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4e, + 0x4f, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x05, 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 ( diff --git a/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.validate.go deleted file mode 100644 index 62174aaa..00000000 --- a/api/kessel/inventory/v1beta1/relationships/reporter_data.pb.validate.go +++ /dev/null @@ -1,245 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/reporter_data.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 ReporterData 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 *ReporterData) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReporterData 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 ReporterDataMultiError, or -// nil if none found. -func (m *ReporterData) ValidateAll() error { - return m.validate(true) -} - -func (m *ReporterData) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if _, ok := _ReporterData_ReporterType_NotInLookup[m.GetReporterType()]; ok { - err := ReporterDataValidationError{ - field: "ReporterType", - reason: "value must not be in list [REPORTER_TYPE_UNSPECIFIED]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := ReporterData_ReporterType_name[int32(m.GetReporterType())]; !ok { - err := ReporterDataValidationError{ - field: "ReporterType", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for ReporterInstanceId - - // no validation rules for ReporterVersion - - if all { - switch v := interface{}(m.GetFirstReported()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReporterDataValidationError{ - field: "FirstReported", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReporterDataValidationError{ - 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 ReporterDataValidationError{ - 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, ReporterDataValidationError{ - field: "LastReported", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReporterDataValidationError{ - 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 ReporterDataValidationError{ - field: "LastReported", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if utf8.RuneCountInString(m.GetSubjectLocalResourceId()) < 1 { - err := ReporterDataValidationError{ - field: "SubjectLocalResourceId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetObjectLocalResourceId()) < 1 { - err := ReporterDataValidationError{ - field: "ObjectLocalResourceId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return ReporterDataMultiError(errors) - } - - return nil -} - -// ReporterDataMultiError is an error wrapping multiple validation errors -// returned by ReporterData.ValidateAll() if the designated constraints aren't met. -type ReporterDataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReporterDataMultiError) 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 ReporterDataMultiError) AllErrors() []error { return m } - -// ReporterDataValidationError is the validation error returned by -// ReporterData.Validate if the designated constraints aren't met. -type ReporterDataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReporterDataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReporterDataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReporterDataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReporterDataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReporterDataValidationError) ErrorName() string { return "ReporterDataValidationError" } - -// Error satisfies the builtin error interface -func (e ReporterDataValidationError) 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 %sReporterData.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReporterDataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReporterDataValidationError{} - -var _ReporterData_ReporterType_NotInLookup = map[ReporterData_ReporterType]struct{}{ - 0: {}, -} diff --git a/api/kessel/inventory/v1beta1/relationships/reporter_data.proto b/api/kessel/inventory/v1beta1/relationships/reporter_data.proto index 9e3cdc8c..5b00cfac 100644 --- a/api/kessel/inventory/v1beta1/relationships/reporter_data.proto +++ b/api/kessel/inventory/v1beta1/relationships/reporter_data.proto @@ -4,7 +4,7 @@ package kessel.inventory.v1beta1.relationships; import "google/api/field_behavior.proto"; import "google/protobuf/timestamp.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/relationships"; option java_multiple_files = true; @@ -21,7 +21,7 @@ message ReporterData { NOTIFICATIONS = 5; } - ReporterType reporter_type = 245778393 [ (validate.rules).enum = {not_in: [0], defined_only: true} ]; + ReporterType reporter_type = 245778393 [ (buf.validate.field).enum = {not_in: [0], defined_only: true} ]; // The ID of the instance of the reporter. This is derived from the // authentication mechanism, i.e. authentication token. @@ -41,9 +41,9 @@ message ReporterData { // The ID assigned by the reporter to resource which is the subject of the relationship. For example // OCM cluster ID, HBI's host id, or ACM managed cluster name etc. - string subject_local_resource_id = 508976190 [ (validate.rules).string.min_len = 1 ]; + string subject_local_resource_id = 508976190 [ (buf.validate.field).string.min_len = 1 ]; // The ID assigned by the reporter to resource which is the object of the relationship. For example // OCM cluster ID, HBI's host id, or ACM managed cluster name etc. - string object_local_resource_id = 508976191 [ (validate.rules).string.min_len = 1 ]; + string object_local_resource_id = 508976191 [ (buf.validate.field).string.min_len = 1 ]; } diff --git a/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_hcrns_parameter.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_hcrns_parameter.pb.validate.go deleted file mode 100644 index 1985b425..00000000 --- a/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_hcrns_parameter.pb.validate.go +++ /dev/null @@ -1,151 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_hcrns_parameter.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 -// UpdateResourceRelationshipByUrnHsHcrnsParameter 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 *UpdateResourceRelationshipByUrnHsHcrnsParameter) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// UpdateResourceRelationshipByUrnHsHcrnsParameter 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 -// UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError, or nil if none found. -func (m *UpdateResourceRelationshipByUrnHsHcrnsParameter) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRelationshipByUrnHsHcrnsParameter) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for SubjectUrn - - // no validation rules for ObjectUrn - - if len(errors) > 0 { - return UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError(errors) - } - - return nil -} - -// UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError is an error -// wrapping multiple validation errors returned by -// UpdateResourceRelationshipByUrnHsHcrnsParameter.ValidateAll() if the -// designated constraints aren't met. -type UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError) 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 UpdateResourceRelationshipByUrnHsHcrnsParameterMultiError) AllErrors() []error { return m } - -// UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError is the -// validation error returned by -// UpdateResourceRelationshipByUrnHsHcrnsParameter.Validate if the designated -// constraints aren't met. -type UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) Field() string { - return e.field -} - -// Reason function returns reason value. -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) Reason() string { - return e.reason -} - -// Cause function returns cause value. -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) ErrorName() string { - return "UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError) 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 %sUpdateResourceRelationshipByUrnHsHcrnsParameter.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRelationshipByUrnHsHcrnsParameterValidationError{} diff --git a/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_resources_parameter.pb.validate.go b/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_resources_parameter.pb.validate.go deleted file mode 100644 index 1e743248..00000000 --- a/api/kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_resources_parameter.pb.validate.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/relationships/update_resource_relationship_by_urnhs_resources_parameter.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 -// UpdateResourceRelationshipByUrnHsResourcesParameter 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 *UpdateResourceRelationshipByUrnHsResourcesParameter) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// UpdateResourceRelationshipByUrnHsResourcesParameter 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 -// UpdateResourceRelationshipByUrnHsResourcesParameterMultiError, or nil if -// none found. -func (m *UpdateResourceRelationshipByUrnHsResourcesParameter) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRelationshipByUrnHsResourcesParameter) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for SubjectResource - - // no validation rules for ObjectResource - - if len(errors) > 0 { - return UpdateResourceRelationshipByUrnHsResourcesParameterMultiError(errors) - } - - return nil -} - -// UpdateResourceRelationshipByUrnHsResourcesParameterMultiError is an error -// wrapping multiple validation errors returned by -// UpdateResourceRelationshipByUrnHsResourcesParameter.ValidateAll() if the -// designated constraints aren't met. -type UpdateResourceRelationshipByUrnHsResourcesParameterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRelationshipByUrnHsResourcesParameterMultiError) 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 UpdateResourceRelationshipByUrnHsResourcesParameterMultiError) AllErrors() []error { return m } - -// UpdateResourceRelationshipByUrnHsResourcesParameterValidationError is the -// validation error returned by -// UpdateResourceRelationshipByUrnHsResourcesParameter.Validate if the -// designated constraints aren't met. -type UpdateResourceRelationshipByUrnHsResourcesParameterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) Field() string { - return e.field -} - -// Reason function returns reason value. -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) Reason() string { - return e.reason -} - -// Cause function returns cause value. -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) Cause() error { - return e.cause -} - -// Key function returns key value. -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) ErrorName() string { - return "UpdateResourceRelationshipByUrnHsResourcesParameterValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRelationshipByUrnHsResourcesParameterValidationError) 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 %sUpdateResourceRelationshipByUrnHsResourcesParameter.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRelationshipByUrnHsResourcesParameterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRelationshipByUrnHsResourcesParameterValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.go index 53122d8e..383060fc 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.go +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -94,37 +94,37 @@ var file_kessel_inventory_v1beta1_resources_k8s_cluster_proto_rawDesc = []byte{ 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 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, 0x1a, 0x3b, 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, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x31, 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, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x02, 0x0a, 0x0a, - 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x48, 0x0a, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x62, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x66, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xca, 0xc7, 0x81, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, + 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3b, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, + 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x31, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x9e, 0x02, 0x0a, 0x0a, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x48, + 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2c, 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, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x60, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, - 0x10, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x64, 0x0a, 0x0d, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xca, 0xc7, 0x81, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, + 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x42, 0x97, 0x01, 0x0a, 0x32, 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, diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate.go deleted file mode 100644 index c6328203..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate.go +++ /dev/null @@ -1,244 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_cluster.proto - -package resources - -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 K8SCluster 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 *K8SCluster) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SCluster 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 K8SClusterMultiError, or -// nil if none found. -func (m *K8SCluster) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SCluster) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMetadata()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SClusterValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SClusterValidationError{ - 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 K8SClusterValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetReporterData() == nil { - err := K8SClusterValidationError{ - field: "ReporterData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetReporterData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetReporterData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SClusterValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetResourceData() == nil { - err := K8SClusterValidationError{ - field: "ResourceData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetResourceData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SClusterValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SClusterValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResourceData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SClusterValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return K8SClusterMultiError(errors) - } - - return nil -} - -// K8SClusterMultiError is an error wrapping multiple validation errors -// returned by K8SCluster.ValidateAll() if the designated constraints aren't met. -type K8SClusterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SClusterMultiError) 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 K8SClusterMultiError) AllErrors() []error { return m } - -// K8SClusterValidationError is the validation error returned by -// K8SCluster.Validate if the designated constraints aren't met. -type K8SClusterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SClusterValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SClusterValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SClusterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SClusterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SClusterValidationError) ErrorName() string { return "K8SClusterValidationError" } - -// Error satisfies the builtin error interface -func (e K8SClusterValidationError) 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 %sK8SCluster.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SClusterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SClusterValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate_test.go deleted file mode 100644 index 46038195..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster.pb.validate_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestK8_clusterValidatesSuccessfullyWithValidData(t *testing.T) { - k8cluster := K8SCluster{ - ReporterData: &ReporterData{ - ReporterType: 2, - LocalResourceId: "some-id", - }, - ResourceData: &K8SClusterDetail{ - ExternalClusterId: "some-cluster-id", - ClusterStatus: 2, - KubeVendor: 5, - KubeVersion: "v1.30.1", - VendorVersion: "4.16", - CloudPlatform: 6, - Nodes: []*K8SClusterDetailNodesInner{ - { - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - }, - }, - }, - } - err := k8cluster.ValidateAll() - assert.NoError(t, err) -} - -func TestK8ClusterValidationFailsWithMissingReporterData(t *testing.T) { - k8cluster := K8SCluster{ - ResourceData: &K8SClusterDetail{ - ExternalClusterId: "some-cluster-id", - ClusterStatus: 2, - KubeVendor: 5, - KubeVersion: "v1.30.1", - VendorVersion: "4.16", - CloudPlatform: 6, - Nodes: []*K8SClusterDetailNodesInner{ - { - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - }, - }, - }, - } - err := k8cluster.ValidateAll() - assert.ErrorContains(t, err, "K8SCluster.ReporterData") -} -func TestK8ClusterValidationFailsWithMissingResourceData(t *testing.T) { - k8cluster := K8SCluster{ - ReporterData: &ReporterData{ - ReporterType: 2, - LocalResourceId: "some-id", - }, - } - err := k8cluster.ValidateAll() - assert.ErrorContains(t, err, "K8SCluster.ResourceData") -} - -func TestK8ClusterValidationFailsWithMissingAllData(t *testing.T) { - k8cluster := K8SCluster{} - - err := k8cluster.ValidateAll() - assert.Error(t, err) - assert.Contains(t, err.Error(), "K8SCluster.ReporterData") - assert.Contains(t, err.Error(), "K8SCluster.ResourceData") -} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster.proto b/api/kessel/inventory/v1beta1/resources/k8s_cluster.proto index 76a6085f..94f67313 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster.proto +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto"; import "kessel/inventory/v1beta1/resources/metadata.proto"; @@ -18,7 +18,7 @@ message K8sCluster { Metadata metadata = 1; // Write only reporter specific data - ReporterData reporter_data = 245278792 [ (validate.rules).message.required = true ]; + ReporterData reporter_data = 245278792 [ (buf.validate.field).required = true ]; - K8sClusterDetail resource_data = 2122698 [ (validate.rules).message.required = true ]; + K8sClusterDetail resource_data = 2122698 [ (buf.validate.field).required = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.go index f4b5c7fa..a64789e8 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.go +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -354,97 +354,98 @@ var file_kessel_inventory_v1beta1_resources_k8s_cluster_detail_proto_rawDesc = [ 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x69, - 0x6e, 0x6e, 0x65, 0x72, 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, 0xde, 0x09, 0x0a, 0x10, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x3a, 0x0a, 0x13, 0x65, 0x78, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x8d, 0xcb, 0xd9, 0x68, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, - 0x01, 0x52, 0x11, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x49, 0x64, 0x12, 0x79, 0x0a, 0x0e, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x5f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0xd8, 0xdb, 0x8d, 0xee, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x42, 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, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x82, 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, - 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x25, 0x0a, 0x0c, 0x6b, 0x75, 0x62, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0xba, 0xa4, 0xe1, 0xbc, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6b, 0x75, 0x62, 0x65, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x6f, 0x0a, 0x0b, 0x6b, 0x75, 0x62, 0x65, 0x5f, 0x76, - 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x18, 0x9a, 0xfd, 0xfc, 0x7d, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3f, + 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xdf, 0x09, 0x0a, 0x10, 0x4b, 0x38, 0x73, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x3a, 0x0a, 0x13, + 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x8d, 0xcb, 0xd9, 0x68, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, + 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x11, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x7a, 0x0a, 0x0e, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0xd8, 0xdb, 0x8d, 0xee, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x42, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x82, 0x01, 0x05, + 0x10, 0x01, 0x22, 0x01, 0x00, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x25, 0x0a, 0x0c, 0x6b, 0x75, 0x62, 0x65, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xba, 0xa4, 0xe1, 0xbc, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x6b, 0x75, 0x62, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x70, 0x0a, 0x0b, 0x6b, + 0x75, 0x62, 0x65, 0x5f, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x18, 0x9a, 0xfd, 0xfc, 0x7d, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x3f, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x4b, 0x75, 0x62, 0x65, 0x56, 0x65, + 0x6e, 0x64, 0x6f, 0x72, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x82, 0x01, 0x05, 0x10, 0x01, 0x22, 0x01, + 0x00, 0x52, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x56, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x12, 0x31, 0x0a, + 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0xe3, 0xc1, 0xb6, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, + 0x01, 0x52, 0x0d, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x7a, 0x0a, 0x0e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, + 0x72, 0x6d, 0x18, 0xbe, 0xce, 0xab, 0xe3, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x42, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x2e, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, + 0x42, 0x0b, 0xba, 0x48, 0x08, 0x82, 0x01, 0x05, 0x10, 0x01, 0x22, 0x01, 0x00, 0x52, 0x0d, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x66, 0x0a, 0x05, + 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x91, 0xc5, 0xfc, 0x23, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x4b, 0x75, 0x62, 0x65, 0x56, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x42, - 0x0a, 0xfa, 0x42, 0x07, 0x82, 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, 0x52, 0x0a, 0x6b, 0x75, 0x62, - 0x65, 0x56, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x12, 0x31, 0x0a, 0x0e, 0x76, 0x65, 0x6e, 0x64, 0x6f, - 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xe3, 0xc1, 0xb6, 0x0b, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0d, 0x76, 0x65, 0x6e, - 0x64, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x79, 0x0a, 0x0e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x5f, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0xbe, 0xce, 0xab, - 0xe3, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x42, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x43, 0x6c, 0x6f, - 0x75, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x82, - 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, 0x52, 0x0d, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x68, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x91, - 0xc5, 0xfc, 0x23, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, - 0x65, 0x73, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x42, 0x0f, 0xfa, 0x42, 0x0c, 0x92, 0x01, 0x09, 0x08, - 0x01, 0x22, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x22, - 0x6d, 0x0a, 0x0d, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4c, 0x55, 0x53, 0x54, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, 0x55, 0x53, 0x54, 0x45, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, - 0x55, 0x53, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x45, - 0x41, 0x44, 0x59, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, - 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x04, 0x22, 0x73, - 0x0a, 0x0a, 0x4b, 0x75, 0x62, 0x65, 0x56, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x17, - 0x4b, 0x55, 0x42, 0x45, 0x5f, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, - 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4b, 0x55, 0x42, - 0x45, 0x5f, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, - 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4b, 0x53, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x45, 0x4b, 0x53, - 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x49, 0x4b, 0x53, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x4f, - 0x50, 0x45, 0x4e, 0x53, 0x48, 0x49, 0x46, 0x54, 0x10, 0x05, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x4b, - 0x45, 0x10, 0x06, 0x22, 0xfe, 0x02, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x50, 0x6c, 0x61, - 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x50, - 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x50, - 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, - 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x4e, 0x45, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x02, 0x12, 0x11, 0x0a, - 0x0d, 0x42, 0x41, 0x52, 0x45, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x03, - 0x12, 0x11, 0x0a, 0x0d, 0x42, 0x41, 0x52, 0x45, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x5f, 0x55, 0x50, - 0x49, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x57, 0x53, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x05, - 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x57, 0x53, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x06, 0x12, 0x0d, 0x0a, - 0x09, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, - 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x08, 0x12, 0x10, 0x0a, 0x0c, 0x49, - 0x42, 0x4d, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x09, 0x12, 0x10, 0x0a, - 0x0c, 0x49, 0x42, 0x4d, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x0a, 0x12, - 0x10, 0x0a, 0x0c, 0x4b, 0x55, 0x42, 0x45, 0x56, 0x49, 0x52, 0x54, 0x5f, 0x49, 0x50, 0x49, 0x10, - 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x50, 0x45, 0x4e, 0x53, 0x54, 0x41, 0x43, 0x4b, 0x5f, 0x49, - 0x50, 0x49, 0x10, 0x0c, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x50, 0x45, 0x4e, 0x53, 0x54, 0x41, 0x43, - 0x4b, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x0d, 0x12, 0x0b, 0x0a, 0x07, 0x47, 0x43, 0x50, 0x5f, 0x49, - 0x50, 0x49, 0x10, 0x0e, 0x12, 0x0b, 0x0a, 0x07, 0x47, 0x43, 0x50, 0x5f, 0x55, 0x50, 0x49, 0x10, - 0x0f, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x55, 0x54, 0x41, 0x4e, 0x49, 0x58, 0x5f, 0x49, 0x50, 0x49, - 0x10, 0x10, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x55, 0x54, 0x41, 0x4e, 0x49, 0x58, 0x5f, 0x55, 0x50, - 0x49, 0x10, 0x11, 0x12, 0x0f, 0x0a, 0x0b, 0x56, 0x53, 0x50, 0x48, 0x45, 0x52, 0x45, 0x5f, 0x49, - 0x50, 0x49, 0x10, 0x12, 0x12, 0x0f, 0x0a, 0x0b, 0x56, 0x53, 0x50, 0x48, 0x45, 0x52, 0x45, 0x5f, - 0x55, 0x50, 0x49, 0x10, 0x13, 0x12, 0x0d, 0x0a, 0x09, 0x4f, 0x56, 0x49, 0x52, 0x54, 0x5f, 0x49, - 0x50, 0x49, 0x10, 0x14, 0x42, 0x9d, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x42, 0x15, 0x4b, 0x38, 0x73, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x42, 0x0d, + 0xba, 0x48, 0x0a, 0x92, 0x01, 0x07, 0x08, 0x01, 0x22, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x05, 0x6e, + 0x6f, 0x64, 0x65, 0x73, 0x22, 0x6d, 0x0a, 0x0d, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4c, 0x55, 0x53, 0x54, 0x45, 0x52, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, 0x55, 0x53, 0x54, 0x45, 0x52, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, + 0x09, 0x0a, 0x05, 0x52, 0x45, 0x41, 0x44, 0x59, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x46, 0x41, + 0x49, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, + 0x45, 0x10, 0x04, 0x22, 0x73, 0x0a, 0x0a, 0x4b, 0x75, 0x62, 0x65, 0x56, 0x65, 0x6e, 0x64, 0x6f, + 0x72, 0x12, 0x1b, 0x0a, 0x17, 0x4b, 0x55, 0x42, 0x45, 0x5f, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, + 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, + 0x0a, 0x11, 0x4b, 0x55, 0x42, 0x45, 0x5f, 0x56, 0x45, 0x4e, 0x44, 0x4f, 0x52, 0x5f, 0x4f, 0x54, + 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4b, 0x53, 0x10, 0x02, 0x12, 0x07, + 0x0a, 0x03, 0x45, 0x4b, 0x53, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x49, 0x4b, 0x53, 0x10, 0x04, + 0x12, 0x0d, 0x0a, 0x09, 0x4f, 0x50, 0x45, 0x4e, 0x53, 0x48, 0x49, 0x46, 0x54, 0x10, 0x05, 0x12, + 0x07, 0x0a, 0x03, 0x47, 0x4b, 0x45, 0x10, 0x06, 0x22, 0xfe, 0x02, 0x0a, 0x0d, 0x43, 0x6c, 0x6f, + 0x75, 0x64, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1e, 0x0a, 0x1a, 0x43, 0x4c, + 0x4f, 0x55, 0x44, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, + 0x4f, 0x55, 0x44, 0x5f, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x4f, 0x54, 0x48, + 0x45, 0x52, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4e, 0x4f, 0x4e, 0x45, 0x5f, 0x55, 0x50, 0x49, + 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x42, 0x41, 0x52, 0x45, 0x4d, 0x45, 0x54, 0x41, 0x4c, 0x5f, + 0x49, 0x50, 0x49, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x42, 0x41, 0x52, 0x45, 0x4d, 0x45, 0x54, + 0x41, 0x4c, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x57, 0x53, 0x5f, + 0x49, 0x50, 0x49, 0x10, 0x05, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x57, 0x53, 0x5f, 0x55, 0x50, 0x49, + 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x49, 0x50, 0x49, 0x10, + 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x5a, 0x55, 0x52, 0x45, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x08, + 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x42, 0x4d, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x49, 0x50, 0x49, + 0x10, 0x09, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x42, 0x4d, 0x43, 0x4c, 0x4f, 0x55, 0x44, 0x5f, 0x55, + 0x50, 0x49, 0x10, 0x0a, 0x12, 0x10, 0x0a, 0x0c, 0x4b, 0x55, 0x42, 0x45, 0x56, 0x49, 0x52, 0x54, + 0x5f, 0x49, 0x50, 0x49, 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x50, 0x45, 0x4e, 0x53, 0x54, + 0x41, 0x43, 0x4b, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x0c, 0x12, 0x11, 0x0a, 0x0d, 0x4f, 0x50, 0x45, + 0x4e, 0x53, 0x54, 0x41, 0x43, 0x4b, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x0d, 0x12, 0x0b, 0x0a, 0x07, + 0x47, 0x43, 0x50, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x0e, 0x12, 0x0b, 0x0a, 0x07, 0x47, 0x43, 0x50, + 0x5f, 0x55, 0x50, 0x49, 0x10, 0x0f, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x55, 0x54, 0x41, 0x4e, 0x49, + 0x58, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x10, 0x12, 0x0f, 0x0a, 0x0b, 0x4e, 0x55, 0x54, 0x41, 0x4e, + 0x49, 0x58, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x11, 0x12, 0x0f, 0x0a, 0x0b, 0x56, 0x53, 0x50, 0x48, + 0x45, 0x52, 0x45, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x12, 0x12, 0x0f, 0x0a, 0x0b, 0x56, 0x53, 0x50, + 0x48, 0x45, 0x52, 0x45, 0x5f, 0x55, 0x50, 0x49, 0x10, 0x13, 0x12, 0x0d, 0x0a, 0x09, 0x4f, 0x56, + 0x49, 0x52, 0x54, 0x5f, 0x49, 0x50, 0x49, 0x10, 0x14, 0x42, 0x9d, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x42, 0x15, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.validate.go deleted file mode 100644 index f72c36ef..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.pb.validate.go +++ /dev/null @@ -1,294 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto - -package resources - -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 K8SClusterDetail 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 *K8SClusterDetail) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SClusterDetail 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 -// K8SClusterDetailMultiError, or nil if none found. -func (m *K8SClusterDetail) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SClusterDetail) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetExternalClusterId()) < 1 { - err := K8SClusterDetailValidationError{ - field: "ExternalClusterId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := _K8SClusterDetail_ClusterStatus_NotInLookup[m.GetClusterStatus()]; ok { - err := K8SClusterDetailValidationError{ - field: "ClusterStatus", - reason: "value must not be in list [CLUSTER_STATUS_UNSPECIFIED]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := K8SClusterDetail_ClusterStatus_name[int32(m.GetClusterStatus())]; !ok { - err := K8SClusterDetailValidationError{ - field: "ClusterStatus", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for KubeVersion - - if _, ok := _K8SClusterDetail_KubeVendor_NotInLookup[m.GetKubeVendor()]; ok { - err := K8SClusterDetailValidationError{ - field: "KubeVendor", - reason: "value must not be in list [KUBE_VENDOR_UNSPECIFIED]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := K8SClusterDetail_KubeVendor_name[int32(m.GetKubeVendor())]; !ok { - err := K8SClusterDetailValidationError{ - field: "KubeVendor", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetVendorVersion()) < 1 { - err := K8SClusterDetailValidationError{ - field: "VendorVersion", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := _K8SClusterDetail_CloudPlatform_NotInLookup[m.GetCloudPlatform()]; ok { - err := K8SClusterDetailValidationError{ - field: "CloudPlatform", - reason: "value must not be in list [CLOUD_PLATFORM_UNSPECIFIED]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := K8SClusterDetail_CloudPlatform_name[int32(m.GetCloudPlatform())]; !ok { - err := K8SClusterDetailValidationError{ - field: "CloudPlatform", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(m.GetNodes()) < 1 { - err := K8SClusterDetailValidationError{ - field: "Nodes", - reason: "value must contain at least 1 item(s)", - } - if !all { - return err - } - errors = append(errors, err) - } - - for idx, item := range m.GetNodes() { - _, _ = idx, item - - if item == nil { - err := K8SClusterDetailValidationError{ - field: fmt.Sprintf("Nodes[%v]", idx), - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SClusterDetailValidationError{ - field: fmt.Sprintf("Nodes[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SClusterDetailValidationError{ - field: fmt.Sprintf("Nodes[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SClusterDetailValidationError{ - field: fmt.Sprintf("Nodes[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return K8SClusterDetailMultiError(errors) - } - - return nil -} - -// K8SClusterDetailMultiError is an error wrapping multiple validation errors -// returned by K8SClusterDetail.ValidateAll() if the designated constraints -// aren't met. -type K8SClusterDetailMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SClusterDetailMultiError) 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 K8SClusterDetailMultiError) AllErrors() []error { return m } - -// K8SClusterDetailValidationError is the validation error returned by -// K8SClusterDetail.Validate if the designated constraints aren't met. -type K8SClusterDetailValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SClusterDetailValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SClusterDetailValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SClusterDetailValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SClusterDetailValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SClusterDetailValidationError) ErrorName() string { return "K8SClusterDetailValidationError" } - -// Error satisfies the builtin error interface -func (e K8SClusterDetailValidationError) 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 %sK8SClusterDetail.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SClusterDetailValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SClusterDetailValidationError{} - -var _K8SClusterDetail_ClusterStatus_NotInLookup = map[K8SClusterDetail_ClusterStatus]struct{}{ - 0: {}, -} - -var _K8SClusterDetail_KubeVendor_NotInLookup = map[K8SClusterDetail_KubeVendor]struct{}{ - 0: {}, -} - -var _K8SClusterDetail_CloudPlatform_NotInLookup = map[K8SClusterDetail_CloudPlatform]struct{}{ - 0: {}, -} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto index c821d714..e33cc072 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; import "kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources"; option java_multiple_files = true; @@ -60,19 +60,19 @@ message K8sClusterDetail { } // The OCP cluster ID or ARN etc for *KS - string external_cluster_id = 219571597 [ (validate.rules).string.min_len = 1 ]; + string external_cluster_id = 219571597 [ (buf.validate.field).string.min_len = 1 ]; - ClusterStatus cluster_status = 499346904 [ (validate.rules).enum = {not_in: [0], defined_only: true} ]; + ClusterStatus cluster_status = 499346904 [ (buf.validate.field).enum = {not_in: [0], defined_only: true} ]; // The version of kubernetes string kube_version = 395858490; - KubeVendor kube_vendor = 264191642 [ (validate.rules).enum = {not_in: [0], defined_only: true} ]; + KubeVendor kube_vendor = 264191642 [ (buf.validate.field).enum = {not_in: [0], defined_only: true} ]; // The version of the productized kubernetes distribution - string vendor_version = 23961827 [ (validate.rules).string.min_len = 1 ]; + string vendor_version = 23961827 [ (buf.validate.field).string.min_len = 1 ]; - CloudPlatform cloud_platform = 476768062 [ (validate.rules).enum = {not_in: [0], defined_only: true} ]; + CloudPlatform cloud_platform = 476768062 [ (buf.validate.field).enum = {not_in: [0], defined_only: true} ]; - repeated K8sClusterDetailNodesInner nodes = 75440785 [ (validate.rules).repeated = {min_items: 1, items: { message: { required: true}}} ]; + repeated K8sClusterDetailNodesInner nodes = 75440785 [ (buf.validate.field).repeated = {min_items: 1, items: { required: true}} ]; } diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.go index 8422c7bb..8a44a469 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.go +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -107,37 +107,37 @@ var file_kessel_inventory_v1beta1_resources_k8s_cluster_detail_nodes_inner_proto 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x5f, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 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, 0x1a, 0x37, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xda, 0x01, 0x0a, 0x1a, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x12, 0x1e, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x8b, 0xf5, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, - 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0xa8, 0x83, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x22, 0x0a, 0x06, 0x6d, - 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x81, 0x86, 0xf5, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, - 0x5b, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x83, 0xc0, 0xbe, 0x11, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x31, 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, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x42, 0x0d, 0xfa, 0x42, 0x0a, 0x92, 0x01, 0x07, 0x22, 0x05, 0x8a, - 0x01, 0x02, 0x10, 0x01, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x42, 0xa7, 0x01, 0x0a, - 0x32, 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, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x42, 0x1f, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x6e, 0x6e, 0x65, 0x72, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x1b, 0x62, + 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x37, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xd8, 0x01, 0x0a, 0x1a, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x6e, 0x6e, + 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x8b, 0xf5, 0xcd, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0xa8, 0x83, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, + 0x22, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x81, 0x86, 0xf5, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x6d, 0x65, 0x6d, + 0x6f, 0x72, 0x79, 0x12, 0x59, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x83, 0xc0, + 0xbe, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x92, 0x01, + 0x05, 0x22, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x42, 0xa7, + 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x42, 0x1f, 0x4b, 0x38, 0x73, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x49, 0x6e, 0x6e, 0x65, + 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate.go deleted file mode 100644 index 82a5919a..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate.go +++ /dev/null @@ -1,216 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto - -package resources - -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 K8SClusterDetailNodesInner 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 *K8SClusterDetailNodesInner) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SClusterDetailNodesInner 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 -// K8SClusterDetailNodesInnerMultiError, or nil if none found. -func (m *K8SClusterDetailNodesInner) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SClusterDetailNodesInner) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetName()) < 1 { - err := K8SClusterDetailNodesInnerValidationError{ - field: "Name", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCpu()) < 1 { - err := K8SClusterDetailNodesInnerValidationError{ - field: "Cpu", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetMemory()) < 1 { - err := K8SClusterDetailNodesInnerValidationError{ - field: "Memory", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - for idx, item := range m.GetLabels() { - _, _ = idx, item - - if item == nil { - err := K8SClusterDetailNodesInnerValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SClusterDetailNodesInnerValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SClusterDetailNodesInnerValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SClusterDetailNodesInnerValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return K8SClusterDetailNodesInnerMultiError(errors) - } - - return nil -} - -// K8SClusterDetailNodesInnerMultiError is an error wrapping multiple -// validation errors returned by K8SClusterDetailNodesInner.ValidateAll() if -// the designated constraints aren't met. -type K8SClusterDetailNodesInnerMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SClusterDetailNodesInnerMultiError) 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 K8SClusterDetailNodesInnerMultiError) AllErrors() []error { return m } - -// K8SClusterDetailNodesInnerValidationError is the validation error returned -// by K8SClusterDetailNodesInner.Validate if the designated constraints aren't met. -type K8SClusterDetailNodesInnerValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SClusterDetailNodesInnerValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SClusterDetailNodesInnerValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SClusterDetailNodesInnerValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SClusterDetailNodesInnerValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SClusterDetailNodesInnerValidationError) ErrorName() string { - return "K8SClusterDetailNodesInnerValidationError" -} - -// Error satisfies the builtin error interface -func (e K8SClusterDetailNodesInnerValidationError) 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 %sK8SClusterDetailNodesInner.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SClusterDetailNodesInnerValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SClusterDetailNodesInnerValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate_test.go deleted file mode 100644 index 4ec924aa..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.pb.validate_test.go +++ /dev/null @@ -1,118 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestK8SClusterDetailNodesInnerValidatesSuccessfullyWithValidData(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - } - err := node.ValidateAll() - assert.NoError(t, err) -} - -func TestK8SClusterDetailNodesInnerValidationFailsWithEmptyName(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - } - err := node.ValidateAll() - assert.ErrorContains(t, err, "invalid K8SClusterDetailNodesInner.Name: value length must be at least 1 runes") -} - -func TestK8SClusterDetailNodesInnerValidationFailsWithEmptyCpu(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - } - err := node.ValidateAll() - assert.ErrorContains(t, err, "invalid K8SClusterDetailNodesInner.Cpu: value length must be at least 1 runes") -} - -func TestK8SClusterDetailNodesInnerValidationFailsWithEmptyMemory(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "", - Labels: []*ResourceLabel{ - { - Key: "node.openshift.io/os_id", - Value: "rhcos", - }, - }, - } - err := node.ValidateAll() - assert.ErrorContains(t, err, "invalid K8SClusterDetailNodesInner.Memory: value length must be at least 1 runes") -} - -func TestK8SClusterDetailNodesInnerValidationFailsWithNilLabel(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - nil, - }, - } - err := node.ValidateAll() - assert.ErrorContains(t, err, "invalid K8SClusterDetailNodesInner.Labels[0]: value is required") -} - -func TestK8SClusterDetailNodesInnerValidationFailsWithInvalidLabel(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "ip-10-0-0-1.ec2.internal", - Cpu: "7500m", - Memory: "30973224Ki", - Labels: []*ResourceLabel{ - { - Key: "", - Value: "rhcos", - }, - }, - } - err := node.ValidateAll() - assert.ErrorContains(t, err, "invalid K8SClusterDetailNodesInner.Labels[0]: embedded message failed validation") -} - -var multipleErrorMessage = "invalid K8SClusterDetailNodesInner.Name: value length must be at least 1 runes; " + - "invalid K8SClusterDetailNodesInner.Cpu: value length must be at least 1 runes; " + - "invalid K8SClusterDetailNodesInner.Memory: value length must be at least 1 runes; " + - "invalid K8SClusterDetailNodesInner.Labels[0]: value is required" - -func TestK8SClusterDetailNodesInnerValidationWithMultipleErrors(t *testing.T) { - node := &K8SClusterDetailNodesInner{ - Name: "", - Cpu: "", - Memory: "", - Labels: []*ResourceLabel{nil}, - } - - err := node.ValidateAll() - assert.ErrorContains(t, err, multipleErrorMessage) - -} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto index 7cfc327e..ac16c92f 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto +++ b/api/kessel/inventory/v1beta1/resources/k8s_cluster_detail_nodes_inner.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/resource_label.proto"; @@ -14,16 +14,16 @@ option java_outer_classname = "K8sClusterDetailNodesInnerProto"; message K8sClusterDetailNodesInner { // The name of the node (this can contain private info) - string name = 3373707 [ (validate.rules).string.min_len = 1 ]; + string name = 3373707 [ (buf.validate.field).string.min_len = 1 ]; // CPU Capacity of the node defined in CPU units, e.g. \"0.5\" - string cpu = 98728 [ (validate.rules).string.min_len = 1 ]; + string cpu = 98728 [ (buf.validate.field).string.min_len = 1 ]; // Memory Capacity of the node defined as MiB, e.g. \"50Mi\" - string memory = 4014849 [ (validate.rules).string.min_len = 1 ]; + string memory = 4014849 [ (buf.validate.field).string.min_len = 1 ]; // Map of string keys and string values that can be used to organize and // categorize (scope and select) resources // Todo: Do we require at least 1 label? - repeated ResourceLabel labels = 36675587 [ (validate.rules).repeated.items.message.required = true ]; + repeated ResourceLabel labels = 36675587 [ (buf.validate.field).repeated.items.required = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/k8s_clusters_service.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_clusters_service.pb.validate.go deleted file mode 100644 index edb37759..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_clusters_service.pb.validate.go +++ /dev/null @@ -1,768 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_clusters_service.proto - -package resources - -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 CreateK8SClusterRequest 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 *CreateK8SClusterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateK8SClusterRequest 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 -// CreateK8SClusterRequestMultiError, or nil if none found. -func (m *CreateK8SClusterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SClusterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetK8SCluster()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SCluster()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateK8SClusterRequestMultiError(errors) - } - - return nil -} - -// CreateK8SClusterRequestMultiError is an error wrapping multiple validation -// errors returned by CreateK8SClusterRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateK8SClusterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SClusterRequestMultiError) 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 CreateK8SClusterRequestMultiError) AllErrors() []error { return m } - -// CreateK8SClusterRequestValidationError is the validation error returned by -// CreateK8SClusterRequest.Validate if the designated constraints aren't met. -type CreateK8SClusterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SClusterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateK8SClusterRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateK8SClusterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SClusterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SClusterRequestValidationError) ErrorName() string { - return "CreateK8SClusterRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SClusterRequestValidationError) 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 %sCreateK8SClusterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SClusterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SClusterRequestValidationError{} - -// Validate checks the field values on CreateK8SClusterResponse 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 *CreateK8SClusterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateK8SClusterResponse 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 -// CreateK8SClusterResponseMultiError, or nil if none found. -func (m *CreateK8SClusterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SClusterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetK8SCluster()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SCluster()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateK8SClusterResponseMultiError(errors) - } - - return nil -} - -// CreateK8SClusterResponseMultiError is an error wrapping multiple validation -// errors returned by CreateK8SClusterResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateK8SClusterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SClusterResponseMultiError) 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 CreateK8SClusterResponseMultiError) AllErrors() []error { return m } - -// CreateK8SClusterResponseValidationError is the validation error returned by -// CreateK8SClusterResponse.Validate if the designated constraints aren't met. -type CreateK8SClusterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SClusterResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateK8SClusterResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateK8SClusterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SClusterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SClusterResponseValidationError) ErrorName() string { - return "CreateK8SClusterResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SClusterResponseValidationError) 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 %sCreateK8SClusterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SClusterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SClusterResponseValidationError{} - -// Validate checks the field values on UpdateK8SClusterRequest 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 *UpdateK8SClusterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateK8SClusterRequest 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 -// UpdateK8SClusterRequestMultiError, or nil if none found. -func (m *UpdateK8SClusterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateK8SClusterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if all { - switch v := interface{}(m.GetK8SCluster()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SCluster()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateK8SClusterRequestValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateK8SClusterRequestMultiError(errors) - } - - return nil -} - -// UpdateK8SClusterRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateK8SClusterRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateK8SClusterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateK8SClusterRequestMultiError) 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 UpdateK8SClusterRequestMultiError) AllErrors() []error { return m } - -// UpdateK8SClusterRequestValidationError is the validation error returned by -// UpdateK8SClusterRequest.Validate if the designated constraints aren't met. -type UpdateK8SClusterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateK8SClusterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateK8SClusterRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateK8SClusterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateK8SClusterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateK8SClusterRequestValidationError) ErrorName() string { - return "UpdateK8SClusterRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateK8SClusterRequestValidationError) 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 %sUpdateK8SClusterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateK8SClusterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateK8SClusterRequestValidationError{} - -// Validate checks the field values on UpdateK8SClusterResponse 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 *UpdateK8SClusterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateK8SClusterResponse 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 -// UpdateK8SClusterResponseMultiError, or nil if none found. -func (m *UpdateK8SClusterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateK8SClusterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetK8SCluster()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SCluster()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateK8SClusterResponseValidationError{ - field: "K8SCluster", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateK8SClusterResponseMultiError(errors) - } - - return nil -} - -// UpdateK8SClusterResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateK8SClusterResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateK8SClusterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateK8SClusterResponseMultiError) 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 UpdateK8SClusterResponseMultiError) AllErrors() []error { return m } - -// UpdateK8SClusterResponseValidationError is the validation error returned by -// UpdateK8SClusterResponse.Validate if the designated constraints aren't met. -type UpdateK8SClusterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateK8SClusterResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateK8SClusterResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateK8SClusterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateK8SClusterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateK8SClusterResponseValidationError) ErrorName() string { - return "UpdateK8SClusterResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateK8SClusterResponseValidationError) 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 %sUpdateK8SClusterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateK8SClusterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateK8SClusterResponseValidationError{} - -// Validate checks the field values on DeleteK8SClusterRequest 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 *DeleteK8SClusterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteK8SClusterRequest 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 -// DeleteK8SClusterRequestMultiError, or nil if none found. -func (m *DeleteK8SClusterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteK8SClusterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if len(errors) > 0 { - return DeleteK8SClusterRequestMultiError(errors) - } - - return nil -} - -// DeleteK8SClusterRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteK8SClusterRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteK8SClusterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteK8SClusterRequestMultiError) 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 DeleteK8SClusterRequestMultiError) AllErrors() []error { return m } - -// DeleteK8SClusterRequestValidationError is the validation error returned by -// DeleteK8SClusterRequest.Validate if the designated constraints aren't met. -type DeleteK8SClusterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteK8SClusterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteK8SClusterRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteK8SClusterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteK8SClusterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteK8SClusterRequestValidationError) ErrorName() string { - return "DeleteK8SClusterRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteK8SClusterRequestValidationError) 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 %sDeleteK8SClusterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteK8SClusterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteK8SClusterRequestValidationError{} - -// Validate checks the field values on DeleteK8SClusterResponse 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 *DeleteK8SClusterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteK8SClusterResponse 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 -// DeleteK8SClusterResponseMultiError, or nil if none found. -func (m *DeleteK8SClusterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteK8SClusterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteK8SClusterResponseMultiError(errors) - } - - return nil -} - -// DeleteK8SClusterResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteK8SClusterResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteK8SClusterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteK8SClusterResponseMultiError) 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 DeleteK8SClusterResponseMultiError) AllErrors() []error { return m } - -// DeleteK8SClusterResponseValidationError is the validation error returned by -// DeleteK8SClusterResponse.Validate if the designated constraints aren't met. -type DeleteK8SClusterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteK8SClusterResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteK8SClusterResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteK8SClusterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteK8SClusterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteK8SClusterResponseValidationError) ErrorName() string { - return "DeleteK8SClusterResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteK8SClusterResponseValidationError) 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 %sDeleteK8SClusterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteK8SClusterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteK8SClusterResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policies_service.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_policies_service.pb.validate.go deleted file mode 100644 index 862ad147..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_policies_service.pb.validate.go +++ /dev/null @@ -1,739 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_policies_service.proto - -package resources - -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 CreateK8SPolicyRequest 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 *CreateK8SPolicyRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateK8SPolicyRequest 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 -// CreateK8SPolicyRequestMultiError, or nil if none found. -func (m *CreateK8SPolicyRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SPolicyRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetK8SPolicy()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SPolicy()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateK8SPolicyRequestMultiError(errors) - } - - return nil -} - -// CreateK8SPolicyRequestMultiError is an error wrapping multiple validation -// errors returned by CreateK8SPolicyRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateK8SPolicyRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SPolicyRequestMultiError) 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 CreateK8SPolicyRequestMultiError) AllErrors() []error { return m } - -// CreateK8SPolicyRequestValidationError is the validation error returned by -// CreateK8SPolicyRequest.Validate if the designated constraints aren't met. -type CreateK8SPolicyRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SPolicyRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateK8SPolicyRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateK8SPolicyRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SPolicyRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SPolicyRequestValidationError) ErrorName() string { - return "CreateK8SPolicyRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SPolicyRequestValidationError) 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 %sCreateK8SPolicyRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SPolicyRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SPolicyRequestValidationError{} - -// Validate checks the field values on CreateK8SPolicyResponse 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 *CreateK8SPolicyResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateK8SPolicyResponse 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 -// CreateK8SPolicyResponseMultiError, or nil if none found. -func (m *CreateK8SPolicyResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateK8SPolicyResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetK8SPolicy()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateK8SPolicyResponseValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateK8SPolicyResponseValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SPolicy()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateK8SPolicyResponseValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateK8SPolicyResponseMultiError(errors) - } - - return nil -} - -// CreateK8SPolicyResponseMultiError is an error wrapping multiple validation -// errors returned by CreateK8SPolicyResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateK8SPolicyResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateK8SPolicyResponseMultiError) 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 CreateK8SPolicyResponseMultiError) AllErrors() []error { return m } - -// CreateK8SPolicyResponseValidationError is the validation error returned by -// CreateK8SPolicyResponse.Validate if the designated constraints aren't met. -type CreateK8SPolicyResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateK8SPolicyResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateK8SPolicyResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateK8SPolicyResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateK8SPolicyResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateK8SPolicyResponseValidationError) ErrorName() string { - return "CreateK8SPolicyResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateK8SPolicyResponseValidationError) 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 %sCreateK8SPolicyResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateK8SPolicyResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateK8SPolicyResponseValidationError{} - -// Validate checks the field values on UpdateK8SPolicyRequest 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 *UpdateK8SPolicyRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateK8SPolicyRequest 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 -// UpdateK8SPolicyRequestMultiError, or nil if none found. -func (m *UpdateK8SPolicyRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateK8SPolicyRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if all { - switch v := interface{}(m.GetK8SPolicy()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetK8SPolicy()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateK8SPolicyRequestValidationError{ - field: "K8SPolicy", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateK8SPolicyRequestMultiError(errors) - } - - return nil -} - -// UpdateK8SPolicyRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateK8SPolicyRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateK8SPolicyRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateK8SPolicyRequestMultiError) 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 UpdateK8SPolicyRequestMultiError) AllErrors() []error { return m } - -// UpdateK8SPolicyRequestValidationError is the validation error returned by -// UpdateK8SPolicyRequest.Validate if the designated constraints aren't met. -type UpdateK8SPolicyRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateK8SPolicyRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateK8SPolicyRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateK8SPolicyRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateK8SPolicyRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateK8SPolicyRequestValidationError) ErrorName() string { - return "UpdateK8SPolicyRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateK8SPolicyRequestValidationError) 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 %sUpdateK8SPolicyRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateK8SPolicyRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateK8SPolicyRequestValidationError{} - -// Validate checks the field values on UpdateK8SPolicyResponse 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 *UpdateK8SPolicyResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateK8SPolicyResponse 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 -// UpdateK8SPolicyResponseMultiError, or nil if none found. -func (m *UpdateK8SPolicyResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateK8SPolicyResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdateK8SPolicyResponseMultiError(errors) - } - - return nil -} - -// UpdateK8SPolicyResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateK8SPolicyResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateK8SPolicyResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateK8SPolicyResponseMultiError) 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 UpdateK8SPolicyResponseMultiError) AllErrors() []error { return m } - -// UpdateK8SPolicyResponseValidationError is the validation error returned by -// UpdateK8SPolicyResponse.Validate if the designated constraints aren't met. -type UpdateK8SPolicyResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateK8SPolicyResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateK8SPolicyResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateK8SPolicyResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateK8SPolicyResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateK8SPolicyResponseValidationError) ErrorName() string { - return "UpdateK8SPolicyResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateK8SPolicyResponseValidationError) 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 %sUpdateK8SPolicyResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateK8SPolicyResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateK8SPolicyResponseValidationError{} - -// Validate checks the field values on DeleteK8SPolicyRequest 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 *DeleteK8SPolicyRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteK8SPolicyRequest 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 -// DeleteK8SPolicyRequestMultiError, or nil if none found. -func (m *DeleteK8SPolicyRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteK8SPolicyRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if len(errors) > 0 { - return DeleteK8SPolicyRequestMultiError(errors) - } - - return nil -} - -// DeleteK8SPolicyRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteK8SPolicyRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteK8SPolicyRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteK8SPolicyRequestMultiError) 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 DeleteK8SPolicyRequestMultiError) AllErrors() []error { return m } - -// DeleteK8SPolicyRequestValidationError is the validation error returned by -// DeleteK8SPolicyRequest.Validate if the designated constraints aren't met. -type DeleteK8SPolicyRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteK8SPolicyRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteK8SPolicyRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteK8SPolicyRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteK8SPolicyRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteK8SPolicyRequestValidationError) ErrorName() string { - return "DeleteK8SPolicyRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteK8SPolicyRequestValidationError) 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 %sDeleteK8SPolicyRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteK8SPolicyRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteK8SPolicyRequestValidationError{} - -// Validate checks the field values on DeleteK8SPolicyResponse 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 *DeleteK8SPolicyResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteK8SPolicyResponse 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 -// DeleteK8SPolicyResponseMultiError, or nil if none found. -func (m *DeleteK8SPolicyResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteK8SPolicyResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteK8SPolicyResponseMultiError(errors) - } - - return nil -} - -// DeleteK8SPolicyResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteK8SPolicyResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteK8SPolicyResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteK8SPolicyResponseMultiError) 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 DeleteK8SPolicyResponseMultiError) AllErrors() []error { return m } - -// DeleteK8SPolicyResponseValidationError is the validation error returned by -// DeleteK8SPolicyResponse.Validate if the designated constraints aren't met. -type DeleteK8SPolicyResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteK8SPolicyResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteK8SPolicyResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteK8SPolicyResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteK8SPolicyResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteK8SPolicyResponseValidationError) ErrorName() string { - return "DeleteK8SPolicyResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteK8SPolicyResponseValidationError) 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 %sDeleteK8SPolicyResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteK8SPolicyResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteK8SPolicyResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.go b/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.go index 607d9aeb..06e17125 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.go +++ b/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -30,7 +30,7 @@ type K8SPolicy struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` // Write only reporter specific data ReporterData *ReporterData `protobuf:"bytes,245278792,opt,name=reporter_data,json=reporterData,proto3" json:"reporter_data,omitempty"` - ResourceData *K8SPolicyDetail `protobuf:"bytes,2122699,opt,name=resource_data,json=resourceData,proto3" json:"resource_data,omitempty"` + ResourceData *K8SPolicyDetail `protobuf:"bytes,2122698,opt,name=resource_data,json=resourceData,proto3" json:"resource_data,omitempty"` } func (x *K8SPolicy) Reset() { @@ -94,36 +94,36 @@ var file_kessel_inventory_v1beta1_resources_k8s_policy_proto_rawDesc = []byte{ 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 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, 0x1a, 0x31, 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, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x31, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, + 0x73, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6b, 0x38, 0x73, 0x5f, 0x70, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, - 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa0, 0x02, 0x0a, 0x09, 0x4b, 0x38, - 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x48, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x62, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, - 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x08, 0xfa, - 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, - 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x65, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xcb, 0xc7, 0x81, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x33, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x02, + 0x0a, 0x09, 0x4b, 0x38, 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x48, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x60, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, + 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, + 0x61, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x63, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xca, 0xc7, 0x81, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x33, 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, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate.go deleted file mode 100644 index dcf1d562..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate.go +++ /dev/null @@ -1,244 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_policy.proto - -package resources - -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 K8SPolicy 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 *K8SPolicy) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SPolicy 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 K8SPolicyMultiError, or nil -// if none found. -func (m *K8SPolicy) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SPolicy) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMetadata()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - 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 K8SPolicyValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetReporterData() == nil { - err := K8SPolicyValidationError{ - field: "ReporterData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetReporterData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetReporterData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SPolicyValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetResourceData() == nil { - err := K8SPolicyValidationError{ - field: "ResourceData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetResourceData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, K8SPolicyValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResourceData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return K8SPolicyValidationError{ - field: "ResourceData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return K8SPolicyMultiError(errors) - } - - return nil -} - -// K8SPolicyMultiError is an error wrapping multiple validation errors returned -// by K8SPolicy.ValidateAll() if the designated constraints aren't met. -type K8SPolicyMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SPolicyMultiError) 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 K8SPolicyMultiError) AllErrors() []error { return m } - -// K8SPolicyValidationError is the validation error returned by -// K8SPolicy.Validate if the designated constraints aren't met. -type K8SPolicyValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SPolicyValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SPolicyValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SPolicyValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SPolicyValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SPolicyValidationError) ErrorName() string { return "K8SPolicyValidationError" } - -// Error satisfies the builtin error interface -func (e K8SPolicyValidationError) 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 %sK8SPolicy.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SPolicyValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SPolicyValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate_test.go deleted file mode 100644 index 9b6295bb..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy.pb.validate_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestK8SPolicyValidatesSuccessfullyWithValidData(t *testing.T) { - policy := K8SPolicy{ - Metadata: &Metadata{}, - ReporterData: &ReporterData{ - ReporterInstanceId: "reporter-id", - ReporterType: 1, //ACM - ConsoleHref: "https://example.com/console", - ApiHref: "https://example.com/api", - LocalResourceId: "local-resource-id", - ReporterVersion: "2.12"}, - ResourceData: &K8SPolicyDetail{}, - } - err := policy.ValidateAll() - assert.NoError(t, err) -} - -func TestK8SPolicyValidationFailsWithMissingReporterData(t *testing.T) { - policy := K8SPolicy{ - Metadata: &Metadata{}, - - ResourceData: &K8SPolicyDetail{}, - } - err := policy.ValidateAll() - assert.ErrorContains(t, err, "Policy.ReporterData") -} - -func TestK8SPolicyValidationFailsWithMissingResourceData(t *testing.T) { - policy := K8SPolicy{ - Metadata: &Metadata{}, - ReporterData: &ReporterData{ - ReporterInstanceId: "reporter-id", - ReporterType: 1, //ACM - ConsoleHref: "https://example.com/console", - ApiHref: "https://example.com/api", - LocalResourceId: "local-resource-id", - ReporterVersion: "2.12", - }, - } - err := policy.ValidateAll() - assert.ErrorContains(t, err, "Policy.ResourceData") -} - -// Missing ReporterData and ResourceData, Policy MetaData is not required -func TestK8SPolicyValidationWithAllErrors(t *testing.T) { - policy := K8SPolicy{} - err := policy.ValidateAll() - assert.Error(t, err) - assert.Contains(t, err.Error(), "Policy.ReporterData") - assert.Contains(t, err.Error(), "Policy.ResourceData") -} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy.proto b/api/kessel/inventory/v1beta1/resources/k8s_policy.proto index 447504b4..87b7c355 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy.proto +++ b/api/kessel/inventory/v1beta1/resources/k8s_policy.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/metadata.proto"; import "kessel/inventory/v1beta1/resources/k8s_policy_detail.proto"; @@ -17,7 +17,7 @@ message K8sPolicy { Metadata metadata = 1; // Write only reporter specific data - ReporterData reporter_data = 245278792 [ (validate.rules).message.required = true ]; + ReporterData reporter_data = 245278792 [ (buf.validate.field).required = true ]; - K8sPolicyDetail resource_data = 2122699 [ (validate.rules).message.required = true ]; + K8sPolicyDetail resource_data = 2122698 [ (buf.validate.field).required = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.go b/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.go index f9270b60..6ff6732b 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.go +++ b/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -145,33 +145,34 @@ var file_kessel_inventory_v1beta1_resources_k8s_policy_detail_proto_rawDesc = [] 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 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, 0x80, 0x02, 0x0a, 0x0f, 0x4b, 0x38, - 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x1e, 0x0a, - 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0xfd, 0xf4, 0x98, 0x81, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x66, 0x0a, - 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x80, 0xa6, 0xf4, 0xc0, 0x01, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x3c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, 0x50, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, - 0x79, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x73, 0x65, 0x76, - 0x65, 0x72, 0x69, 0x74, 0x79, 0x22, 0x65, 0x0a, 0x08, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, - 0x79, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, - 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, - 0x07, 0x0a, 0x03, 0x4c, 0x4f, 0x57, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x44, 0x49, - 0x55, 0x4d, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x49, 0x47, 0x48, 0x10, 0x04, 0x12, 0x0c, - 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54, 0x49, 0x43, 0x41, 0x4c, 0x10, 0x05, 0x42, 0x86, 0x01, 0x0a, - 0x32, 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, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x02, + 0x0a, 0x0f, 0x4b, 0x38, 0x73, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x12, 0x1e, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0xfd, 0xf4, + 0x98, 0x81, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x12, 0x66, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x80, 0xa6, + 0xf4, 0xc0, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4b, 0x38, 0x73, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x2e, 0x53, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x74, 0x79, 0x42, 0x08, 0xba, 0x48, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, + 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x22, 0x65, 0x0a, 0x08, 0x53, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x14, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, + 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x12, 0x0a, 0x0e, 0x53, 0x45, 0x56, 0x45, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x4f, 0x54, 0x48, 0x45, + 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x4c, 0x4f, 0x57, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x4d, 0x45, 0x44, 0x49, 0x55, 0x4d, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x49, 0x47, 0x48, + 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54, 0x49, 0x43, 0x41, 0x4c, 0x10, 0x05, + 0x42, 0x86, 0x01, 0x0a, 0x32, 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, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.validate.go b/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.validate.go deleted file mode 100644 index 0ef3273f..00000000 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.pb.validate.go +++ /dev/null @@ -1,149 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/k8s_policy_detail.proto - -package resources - -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 K8SPolicyDetail 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 *K8SPolicyDetail) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on K8SPolicyDetail 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 -// K8SPolicyDetailMultiError, or nil if none found. -func (m *K8SPolicyDetail) ValidateAll() error { - return m.validate(true) -} - -func (m *K8SPolicyDetail) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Disabled - - if _, ok := K8SPolicyDetail_Severity_name[int32(m.GetSeverity())]; !ok { - err := K8SPolicyDetailValidationError{ - field: "Severity", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return K8SPolicyDetailMultiError(errors) - } - - return nil -} - -// K8SPolicyDetailMultiError is an error wrapping multiple validation errors -// returned by K8SPolicyDetail.ValidateAll() if the designated constraints -// aren't met. -type K8SPolicyDetailMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m K8SPolicyDetailMultiError) 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 K8SPolicyDetailMultiError) AllErrors() []error { return m } - -// K8SPolicyDetailValidationError is the validation error returned by -// K8SPolicyDetail.Validate if the designated constraints aren't met. -type K8SPolicyDetailValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e K8SPolicyDetailValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e K8SPolicyDetailValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e K8SPolicyDetailValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e K8SPolicyDetailValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e K8SPolicyDetailValidationError) ErrorName() string { return "K8SPolicyDetailValidationError" } - -// Error satisfies the builtin error interface -func (e K8SPolicyDetailValidationError) 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 %sK8SPolicyDetail.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = K8SPolicyDetailValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = K8SPolicyDetailValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.proto b/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.proto index bd0395a6..0195c99c 100644 --- a/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.proto +++ b/api/kessel/inventory/v1beta1/resources/k8s_policy_detail.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources"; option java_multiple_files = true; @@ -23,5 +23,5 @@ message K8sPolicyDetail { // Defines if the policy is currently enabled or disabled across all targets bool disabled = 270940797; - Severity severity = 404558592 [ (validate.rules).enum.defined_only = true ]; + Severity severity = 404558592 [ (buf.validate.field).enum.defined_only = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/metadata.pb.validate.go b/api/kessel/inventory/v1beta1/resources/metadata.pb.validate.go deleted file mode 100644 index 5f68cf35..00000000 --- a/api/kessel/inventory/v1beta1/resources/metadata.pb.validate.go +++ /dev/null @@ -1,237 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/metadata.proto - -package resources - -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 ResourceType - - 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 - - // no validation rules for Workspace - - for idx, item := range m.GetLabels() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MetadataValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MetadataValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MetadataValidationError{ - field: fmt.Sprintf("Labels[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - 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/resources/metadata.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/metadata.pb.validate_test.go deleted file mode 100644 index 5ec898b3..00000000 --- a/api/kessel/inventory/v1beta1/resources/metadata.pb.validate_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestMetadataValid(t *testing.T) { - meta := Metadata{} - err := meta.ValidateAll() - - assert.NoError(t, err) -} - -func TestMetadataEmptyLabels(t *testing.T) { - meta := Metadata{ - Labels: []*ResourceLabel{}, - } - - 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/resources/notifications_integration.pb.go b/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.go index a98a556c..eb8149f0 100644 --- a/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.go +++ b/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -90,37 +90,37 @@ var file_kessel_inventory_v1beta1_resources_notifications_integration_proto_rawD 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 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, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x31, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, + 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x31, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xc9, 0x01, 0x0a, 0x18, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x48, + 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2c, 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, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x63, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x42, 0x09, 0xe0, 0x41, 0x04, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, + 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x86, 0x01, + 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcb, 0x01, - 0x0a, 0x18, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x49, - 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x65, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x42, 0x0b, 0xe0, 0x41, 0x04, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x72, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x86, 0x01, 0x0a, 0x32, - 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, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate.go b/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate.go deleted file mode 100644 index bfebd8de..00000000 --- a/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate.go +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/notifications_integration.proto - -package resources - -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 NotificationsIntegration 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 *NotificationsIntegration) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on NotificationsIntegration 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 -// NotificationsIntegrationMultiError, or nil if none found. -func (m *NotificationsIntegration) ValidateAll() error { - return m.validate(true) -} - -func (m *NotificationsIntegration) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMetadata()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, NotificationsIntegrationValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, NotificationsIntegrationValidationError{ - 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 NotificationsIntegrationValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetReporterData() == nil { - err := NotificationsIntegrationValidationError{ - field: "ReporterData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetReporterData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, NotificationsIntegrationValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, NotificationsIntegrationValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetReporterData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return NotificationsIntegrationValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return NotificationsIntegrationMultiError(errors) - } - - return nil -} - -// NotificationsIntegrationMultiError is an error wrapping multiple validation -// errors returned by NotificationsIntegration.ValidateAll() if the designated -// constraints aren't met. -type NotificationsIntegrationMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m NotificationsIntegrationMultiError) 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 NotificationsIntegrationMultiError) AllErrors() []error { return m } - -// NotificationsIntegrationValidationError is the validation error returned by -// NotificationsIntegration.Validate if the designated constraints aren't met. -type NotificationsIntegrationValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e NotificationsIntegrationValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e NotificationsIntegrationValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e NotificationsIntegrationValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e NotificationsIntegrationValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e NotificationsIntegrationValidationError) ErrorName() string { - return "NotificationsIntegrationValidationError" -} - -// Error satisfies the builtin error interface -func (e NotificationsIntegrationValidationError) 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 %sNotificationsIntegration.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = NotificationsIntegrationValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = NotificationsIntegrationValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate_test.go deleted file mode 100644 index ecb70161..00000000 --- a/api/kessel/inventory/v1beta1/resources/notifications_integration.pb.validate_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNotificationIntegrationOptionalMetadata(t *testing.T) { - notifintegration := NotificationsIntegration{ - ReporterData: &ReporterData{ - ReporterType: ReporterData_OCM, - LocalResourceId: "foo", - }, - } - err := notifintegration.ValidateAll() - - assert.NoError(t, err) -} - -func TestNotificationIntegrationMetadataIsValidatedIfFound(t *testing.T) { - notifintegration := NotificationsIntegration{ - ReporterData: &ReporterData{ - ReporterType: ReporterData_OCM, - LocalResourceId: "foo", - }, - Metadata: &Metadata{ - Labels: []*ResourceLabel{ - {}, - }, - }, - } - err := notifintegration.ValidateAll() - - assert.ErrorContains(t, err, "Integration.Metadata") - assert.ErrorContains(t, err, "Metadata.Labels") -} - -func TestNotificationIntegrationDataIsValidated(t *testing.T) { - host := NotificationsIntegration{} - err := host.ValidateAll() - - assert.ErrorContains(t, err, "Integration.ReporterData") -} diff --git a/api/kessel/inventory/v1beta1/resources/notifications_integration.proto b/api/kessel/inventory/v1beta1/resources/notifications_integration.proto index 66837edf..af274afb 100644 --- a/api/kessel/inventory/v1beta1/resources/notifications_integration.proto +++ b/api/kessel/inventory/v1beta1/resources/notifications_integration.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; import "google/api/field_behavior.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/metadata.proto"; import "kessel/inventory/v1beta1/resources/reporter_data.proto"; @@ -18,5 +18,5 @@ message NotificationsIntegration { // Write only reporter specific data ReporterData reporter_data = 245278792 - [ (google.api.field_behavior) = INPUT_ONLY, (validate.rules).message.required = true ]; + [ (google.api.field_behavior) = INPUT_ONLY, (buf.validate.field).required = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/notifications_integrations_service.pb.validate.go b/api/kessel/inventory/v1beta1/resources/notifications_integrations_service.pb.validate.go deleted file mode 100644 index 05745449..00000000 --- a/api/kessel/inventory/v1beta1/resources/notifications_integrations_service.pb.validate.go +++ /dev/null @@ -1,760 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/notifications_integrations_service.proto - -package resources - -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 CreateNotificationsIntegrationRequest -// 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 *CreateNotificationsIntegrationRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateNotificationsIntegrationRequest -// 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 -// CreateNotificationsIntegrationRequestMultiError, or nil if none found. -func (m *CreateNotificationsIntegrationRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateNotificationsIntegrationRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetIntegration()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetIntegration()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateNotificationsIntegrationRequestMultiError(errors) - } - - return nil -} - -// CreateNotificationsIntegrationRequestMultiError is an error wrapping -// multiple validation errors returned by -// CreateNotificationsIntegrationRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateNotificationsIntegrationRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateNotificationsIntegrationRequestMultiError) 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 CreateNotificationsIntegrationRequestMultiError) AllErrors() []error { return m } - -// CreateNotificationsIntegrationRequestValidationError is the validation error -// returned by CreateNotificationsIntegrationRequest.Validate if the -// designated constraints aren't met. -type CreateNotificationsIntegrationRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateNotificationsIntegrationRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateNotificationsIntegrationRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateNotificationsIntegrationRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateNotificationsIntegrationRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateNotificationsIntegrationRequestValidationError) ErrorName() string { - return "CreateNotificationsIntegrationRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateNotificationsIntegrationRequestValidationError) 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 %sCreateNotificationsIntegrationRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateNotificationsIntegrationRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateNotificationsIntegrationRequestValidationError{} - -// Validate checks the field values on CreateNotificationsIntegrationResponse -// 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 *CreateNotificationsIntegrationResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// CreateNotificationsIntegrationResponse 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 -// CreateNotificationsIntegrationResponseMultiError, or nil if none found. -func (m *CreateNotificationsIntegrationResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateNotificationsIntegrationResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetIntegration()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateNotificationsIntegrationResponseValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateNotificationsIntegrationResponseValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetIntegration()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateNotificationsIntegrationResponseValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateNotificationsIntegrationResponseMultiError(errors) - } - - return nil -} - -// CreateNotificationsIntegrationResponseMultiError is an error wrapping -// multiple validation errors returned by -// CreateNotificationsIntegrationResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateNotificationsIntegrationResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateNotificationsIntegrationResponseMultiError) 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 CreateNotificationsIntegrationResponseMultiError) AllErrors() []error { return m } - -// CreateNotificationsIntegrationResponseValidationError is the validation -// error returned by CreateNotificationsIntegrationResponse.Validate if the -// designated constraints aren't met. -type CreateNotificationsIntegrationResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateNotificationsIntegrationResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateNotificationsIntegrationResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateNotificationsIntegrationResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateNotificationsIntegrationResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateNotificationsIntegrationResponseValidationError) ErrorName() string { - return "CreateNotificationsIntegrationResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateNotificationsIntegrationResponseValidationError) 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 %sCreateNotificationsIntegrationResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateNotificationsIntegrationResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateNotificationsIntegrationResponseValidationError{} - -// Validate checks the field values on UpdateNotificationsIntegrationRequest -// 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 *UpdateNotificationsIntegrationRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateNotificationsIntegrationRequest -// 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 -// UpdateNotificationsIntegrationRequestMultiError, or nil if none found. -func (m *UpdateNotificationsIntegrationRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateNotificationsIntegrationRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if all { - switch v := interface{}(m.GetIntegration()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetIntegration()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateNotificationsIntegrationRequestValidationError{ - field: "Integration", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateNotificationsIntegrationRequestMultiError(errors) - } - - return nil -} - -// UpdateNotificationsIntegrationRequestMultiError is an error wrapping -// multiple validation errors returned by -// UpdateNotificationsIntegrationRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateNotificationsIntegrationRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateNotificationsIntegrationRequestMultiError) 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 UpdateNotificationsIntegrationRequestMultiError) AllErrors() []error { return m } - -// UpdateNotificationsIntegrationRequestValidationError is the validation error -// returned by UpdateNotificationsIntegrationRequest.Validate if the -// designated constraints aren't met. -type UpdateNotificationsIntegrationRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateNotificationsIntegrationRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateNotificationsIntegrationRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateNotificationsIntegrationRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateNotificationsIntegrationRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateNotificationsIntegrationRequestValidationError) ErrorName() string { - return "UpdateNotificationsIntegrationRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateNotificationsIntegrationRequestValidationError) 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 %sUpdateNotificationsIntegrationRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateNotificationsIntegrationRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateNotificationsIntegrationRequestValidationError{} - -// Validate checks the field values on UpdateNotificationsIntegrationResponse -// 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 *UpdateNotificationsIntegrationResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// UpdateNotificationsIntegrationResponse 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 -// UpdateNotificationsIntegrationResponseMultiError, or nil if none found. -func (m *UpdateNotificationsIntegrationResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateNotificationsIntegrationResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdateNotificationsIntegrationResponseMultiError(errors) - } - - return nil -} - -// UpdateNotificationsIntegrationResponseMultiError is an error wrapping -// multiple validation errors returned by -// UpdateNotificationsIntegrationResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateNotificationsIntegrationResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateNotificationsIntegrationResponseMultiError) 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 UpdateNotificationsIntegrationResponseMultiError) AllErrors() []error { return m } - -// UpdateNotificationsIntegrationResponseValidationError is the validation -// error returned by UpdateNotificationsIntegrationResponse.Validate if the -// designated constraints aren't met. -type UpdateNotificationsIntegrationResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateNotificationsIntegrationResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateNotificationsIntegrationResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateNotificationsIntegrationResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateNotificationsIntegrationResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateNotificationsIntegrationResponseValidationError) ErrorName() string { - return "UpdateNotificationsIntegrationResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateNotificationsIntegrationResponseValidationError) 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 %sUpdateNotificationsIntegrationResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateNotificationsIntegrationResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateNotificationsIntegrationResponseValidationError{} - -// Validate checks the field values on DeleteNotificationsIntegrationRequest -// 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 *DeleteNotificationsIntegrationRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteNotificationsIntegrationRequest -// 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 -// DeleteNotificationsIntegrationRequestMultiError, or nil if none found. -func (m *DeleteNotificationsIntegrationRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteNotificationsIntegrationRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Resource - - if len(errors) > 0 { - return DeleteNotificationsIntegrationRequestMultiError(errors) - } - - return nil -} - -// DeleteNotificationsIntegrationRequestMultiError is an error wrapping -// multiple validation errors returned by -// DeleteNotificationsIntegrationRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteNotificationsIntegrationRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteNotificationsIntegrationRequestMultiError) 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 DeleteNotificationsIntegrationRequestMultiError) AllErrors() []error { return m } - -// DeleteNotificationsIntegrationRequestValidationError is the validation error -// returned by DeleteNotificationsIntegrationRequest.Validate if the -// designated constraints aren't met. -type DeleteNotificationsIntegrationRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteNotificationsIntegrationRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteNotificationsIntegrationRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteNotificationsIntegrationRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteNotificationsIntegrationRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteNotificationsIntegrationRequestValidationError) ErrorName() string { - return "DeleteNotificationsIntegrationRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteNotificationsIntegrationRequestValidationError) 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 %sDeleteNotificationsIntegrationRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteNotificationsIntegrationRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteNotificationsIntegrationRequestValidationError{} - -// Validate checks the field values on DeleteNotificationsIntegrationResponse -// 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 *DeleteNotificationsIntegrationResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on -// DeleteNotificationsIntegrationResponse 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 -// DeleteNotificationsIntegrationResponseMultiError, or nil if none found. -func (m *DeleteNotificationsIntegrationResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteNotificationsIntegrationResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteNotificationsIntegrationResponseMultiError(errors) - } - - return nil -} - -// DeleteNotificationsIntegrationResponseMultiError is an error wrapping -// multiple validation errors returned by -// DeleteNotificationsIntegrationResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteNotificationsIntegrationResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteNotificationsIntegrationResponseMultiError) 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 DeleteNotificationsIntegrationResponseMultiError) AllErrors() []error { return m } - -// DeleteNotificationsIntegrationResponseValidationError is the validation -// error returned by DeleteNotificationsIntegrationResponse.Validate if the -// designated constraints aren't met. -type DeleteNotificationsIntegrationResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteNotificationsIntegrationResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteNotificationsIntegrationResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteNotificationsIntegrationResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteNotificationsIntegrationResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteNotificationsIntegrationResponseValidationError) ErrorName() string { - return "DeleteNotificationsIntegrationResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteNotificationsIntegrationResponseValidationError) 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 %sDeleteNotificationsIntegrationResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteNotificationsIntegrationResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteNotificationsIntegrationResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.go b/api/kessel/inventory/v1beta1/resources/reporter_data.pb.go index 11cf11cf..04bb4e6d 100644 --- a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.go +++ b/api/kessel/inventory/v1beta1/resources/reporter_data.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -207,57 +207,58 @@ var file_kessel_inventory_v1beta1_resources_reporter_data_proto_rawDesc = []byte 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, 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, 0xf3, 0x04, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x71, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0xd8, 0x8f, 0x99, 0x75, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x3d, 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, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, - 0x65, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x82, 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, 0x52, 0x0c, 0x72, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x38, 0x0a, 0x14, 0x72, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0xb8, 0xd5, 0xfa, 0x72, 0x20, 0x01, 0x28, 0x09, 0x42, 0x03, 0xe0, 0x41, - 0x03, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x49, 0x0a, 0x0e, 0x66, 0x69, 0x72, 0x73, 0x74, 0x5f, 0x72, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x18, 0x80, 0xed, 0xce, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, + 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x04, 0x0a, 0x0c, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x72, 0x0a, 0x0d, + 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0xd8, 0x8f, + 0x99, 0x75, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3d, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x72, 0x54, 0x79, 0x70, 0x65, 0x42, 0x0b, 0xba, 0x48, 0x08, 0x82, 0x01, 0x05, 0x10, 0x01, 0x22, + 0x01, 0x00, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x38, 0x0a, 0x14, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0xb8, 0xd5, 0xfa, 0x72, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x12, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x49, 0x0a, 0x0e, 0x66, 0x69, + 0x72, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x18, 0x80, 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, 0x8b, 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, 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, 0x8b, 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, 0x24, 0x0a, 0x0c, 0x63, 0x6f, - 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x5f, 0x68, 0x72, 0x65, 0x66, 0x18, 0x94, 0xa2, 0xc6, 0x45, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x48, 0x72, 0x65, 0x66, - 0x12, 0x1d, 0x0a, 0x08, 0x61, 0x70, 0x69, 0x5f, 0x68, 0x72, 0x65, 0x66, 0x18, 0xb1, 0xfc, 0x91, - 0xcd, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x69, 0x48, 0x72, 0x65, 0x66, 0x12, - 0x37, 0x0a, 0x11, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0xbd, 0xb8, 0xd9, 0xf2, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xfa, 0xee, 0xc8, - 0x80, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x74, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x52, 0x45, 0x50, 0x4f, 0x52, - 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x50, 0x4f, 0x52, 0x54, - 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x54, 0x48, 0x45, 0x52, 0x10, 0x01, 0x12, - 0x07, 0x0a, 0x03, 0x41, 0x43, 0x4d, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x48, 0x42, 0x49, 0x10, - 0x03, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x4d, 0x10, 0x04, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x4f, - 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x05, 0x42, 0x86, 0x01, - 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x12, + 0x24, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x5f, 0x68, 0x72, 0x65, 0x66, 0x18, + 0x94, 0xa2, 0xc6, 0x45, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, + 0x65, 0x48, 0x72, 0x65, 0x66, 0x12, 0x1d, 0x0a, 0x08, 0x61, 0x70, 0x69, 0x5f, 0x68, 0x72, 0x65, + 0x66, 0x18, 0xb1, 0xfc, 0x91, 0xcd, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x69, + 0x48, 0x72, 0x65, 0x66, 0x12, 0x37, 0x0a, 0x11, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0xbd, 0xb8, 0xd9, 0xf2, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0f, 0x6c, 0x6f, + 0x63, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x2d, 0x0a, + 0x10, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0xfa, 0xee, 0xc8, 0x80, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x65, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x74, 0x0a, 0x0c, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, + 0x52, 0x45, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x52, + 0x45, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x54, 0x48, + 0x45, 0x52, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x43, 0x4d, 0x10, 0x02, 0x12, 0x07, 0x0a, + 0x03, 0x48, 0x42, 0x49, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x43, 0x4d, 0x10, 0x04, 0x12, + 0x11, 0x0a, 0x0d, 0x4e, 0x4f, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, + 0x10, 0x05, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate.go b/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate.go deleted file mode 100644 index 754b4146..00000000 --- a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate.go +++ /dev/null @@ -1,238 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/reporter_data.proto - -package resources - -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 ReporterData 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 *ReporterData) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReporterData 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 ReporterDataMultiError, or -// nil if none found. -func (m *ReporterData) ValidateAll() error { - return m.validate(true) -} - -func (m *ReporterData) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if _, ok := _ReporterData_ReporterType_NotInLookup[m.GetReporterType()]; ok { - err := ReporterDataValidationError{ - field: "ReporterType", - reason: "value must not be in list [REPORTER_TYPE_UNSPECIFIED]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if _, ok := ReporterData_ReporterType_name[int32(m.GetReporterType())]; !ok { - err := ReporterDataValidationError{ - field: "ReporterType", - reason: "value must be one of the defined enum values", - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for ReporterInstanceId - - if all { - switch v := interface{}(m.GetFirstReported()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReporterDataValidationError{ - field: "FirstReported", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReporterDataValidationError{ - 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 ReporterDataValidationError{ - 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, ReporterDataValidationError{ - field: "LastReported", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReporterDataValidationError{ - 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 ReporterDataValidationError{ - field: "LastReported", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for ConsoleHref - - // no validation rules for ApiHref - - if utf8.RuneCountInString(m.GetLocalResourceId()) < 1 { - err := ReporterDataValidationError{ - field: "LocalResourceId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for ReporterVersion - - if len(errors) > 0 { - return ReporterDataMultiError(errors) - } - - return nil -} - -// ReporterDataMultiError is an error wrapping multiple validation errors -// returned by ReporterData.ValidateAll() if the designated constraints aren't met. -type ReporterDataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReporterDataMultiError) 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 ReporterDataMultiError) AllErrors() []error { return m } - -// ReporterDataValidationError is the validation error returned by -// ReporterData.Validate if the designated constraints aren't met. -type ReporterDataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReporterDataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReporterDataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReporterDataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReporterDataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReporterDataValidationError) ErrorName() string { return "ReporterDataValidationError" } - -// Error satisfies the builtin error interface -func (e ReporterDataValidationError) 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 %sReporterData.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReporterDataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReporterDataValidationError{} - -var _ReporterData_ReporterType_NotInLookup = map[ReporterData_ReporterType]struct{}{ - 0: {}, -} diff --git a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate_test.go deleted file mode 100644 index eb4ef219..00000000 --- a/api/kessel/inventory/v1beta1/resources/reporter_data.pb.validate_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package resources - -import ( - "strconv" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestReporterDataValid(t *testing.T) { - reporter := ReporterData{ - ReporterType: ReporterData_OCM, - LocalResourceId: "my-id", - } - - err := reporter.ValidateAll() - - assert.NoError(t, err) -} - -func TestReporterDataInvalidReporterTypes(t *testing.T) { - invalidReporterTypes := []int32{ - int32(ReporterData_REPORTER_TYPE_UNSPECIFIED), - 15, - 99, - } - - for _, reporterType := range invalidReporterTypes { - t.Run(strconv.Itoa(int(reporterType)), func(t *testing.T) { - reporter := ReporterData{ - ReporterType: ReporterData_ReporterType(reporterType), - LocalResourceId: "my-id", - } - - err := reporter.ValidateAll() - assert.ErrorContains(t, err, "ReporterData.ReporterType") - }) - } -} - -func TestReporterDataEmpty(t *testing.T) { - reporter := ReporterData{} - - err := reporter.ValidateAll() - - assert.ErrorContains(t, err, "ReporterData.ReporterType") - assert.ErrorContains(t, err, "ReporterData.LocalResourceId") -} diff --git a/api/kessel/inventory/v1beta1/resources/reporter_data.proto b/api/kessel/inventory/v1beta1/resources/reporter_data.proto index 81b16e33..bbc1b973 100644 --- a/api/kessel/inventory/v1beta1/resources/reporter_data.proto +++ b/api/kessel/inventory/v1beta1/resources/reporter_data.proto @@ -4,7 +4,7 @@ package kessel.inventory.v1beta1.resources; import "google/api/field_behavior.proto"; import "google/protobuf/timestamp.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources"; option java_multiple_files = true; @@ -21,7 +21,7 @@ message ReporterData { NOTIFICATIONS = 5; } - ReporterType reporter_type = 245778392 [ (validate.rules).enum = {not_in: [0], defined_only: true} ]; + ReporterType reporter_type = 245778392 [ (buf.validate.field).enum = {not_in: [0], defined_only: true} ]; // The ID of the instance of the reporter. This is derived from the // authentication mechanism, i.e. authentication token. @@ -46,7 +46,7 @@ message ReporterData { // The ID assigned to this resource by the reporter, for example OCM cluster // ID, HBI's host id, or ACM managed cluster name etc. - string local_resource_id = 508976189 [ (validate.rules).string.min_len = 1 ]; + string local_resource_id = 508976189 [ (buf.validate.field).string.min_len = 1 ]; // version of the reporter string reporter_version = 269629306; diff --git a/api/kessel/inventory/v1beta1/resources/resource_label.pb.go b/api/kessel/inventory/v1beta1/resources/resource_label.pb.go index d4abceb6..6babb8bc 100644 --- a/api/kessel/inventory/v1beta1/resources/resource_label.pb.go +++ b/api/kessel/inventory/v1beta1/resources/resource_label.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -84,23 +84,23 @@ var file_kessel_inventory_v1beta1_resources_resource_label_proto_rawDesc = []byt 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x22, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 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, 0x4e, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x1b, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0xdf, - 0xbc, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0xf1, 0xa2, - 0xb2, 0x35, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, - 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x1b, 0x62, + 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4e, 0x0a, 0x0d, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x1b, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0xdf, 0xbc, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, + 0x02, 0x10, 0x01, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0xf1, 0xa2, 0xb2, 0x35, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, + 0x02, 0x10, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x73, 0x50, 0x01, 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate.go b/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate.go deleted file mode 100644 index 0dc1cd53..00000000 --- a/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate.go +++ /dev/null @@ -1,158 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/resource_label.proto - -package resources - -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 ResourceLabel 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 *ResourceLabel) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceLabel 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 ResourceLabelMultiError, or -// nil if none found. -func (m *ResourceLabel) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceLabel) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetKey()) < 1 { - err := ResourceLabelValidationError{ - field: "Key", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetValue()) < 1 { - err := ResourceLabelValidationError{ - field: "Value", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return ResourceLabelMultiError(errors) - } - - return nil -} - -// ResourceLabelMultiError is an error wrapping multiple validation errors -// returned by ResourceLabel.ValidateAll() if the designated constraints -// aren't met. -type ResourceLabelMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceLabelMultiError) 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 ResourceLabelMultiError) AllErrors() []error { return m } - -// ResourceLabelValidationError is the validation error returned by -// ResourceLabel.Validate if the designated constraints aren't met. -type ResourceLabelValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceLabelValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceLabelValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceLabelValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceLabelValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceLabelValidationError) ErrorName() string { return "ResourceLabelValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceLabelValidationError) 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 %sResourceLabel.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceLabelValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceLabelValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate_test.go deleted file mode 100644 index de7d9a5d..00000000 --- a/api/kessel/inventory/v1beta1/resources/resource_label.pb.validate_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestResourceLabelValid(t *testing.T) { - label := ResourceLabel{ - Key: "key", - Value: "value", - } - - err := label.ValidateAll() - - assert.NoError(t, err) -} - -func TestResourceLabelEmpty(t *testing.T) { - label := ResourceLabel{} - - err := label.ValidateAll() - - assert.ErrorContains(t, err, "invalid ResourceLabel.Key") - assert.ErrorContains(t, err, "invalid ResourceLabel.Value") -} - -func TestResourceLabelNoKey(t *testing.T) { - label := ResourceLabel{ - Value: "value", - } - - err := label.ValidateAll() - - assert.ErrorContains(t, err, "invalid ResourceLabel.Key") - assert.NotContains(t, err.Error(), "invalid ResourceLabel.Value") -} - -func TestResourceLabelNoValue(t *testing.T) { - label := ResourceLabel{ - Key: "key", - } - - err := label.ValidateAll() - - assert.NotContains(t, err.Error(), "invalid ResourceLabel.Key") - assert.ErrorContains(t, err, "invalid ResourceLabel.Value") -} diff --git a/api/kessel/inventory/v1beta1/resources/resource_label.proto b/api/kessel/inventory/v1beta1/resources/resource_label.proto index 50d75d7b..6a465952 100644 --- a/api/kessel/inventory/v1beta1/resources/resource_label.proto +++ b/api/kessel/inventory/v1beta1/resources/resource_label.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources"; option java_multiple_files = true; @@ -10,7 +10,7 @@ option java_package = "org.project_kessel.api.inventory.v1beta1.resources"; message ResourceLabel { - string key = 106079 [ (validate.rules).string.min_len = 1 ]; + string key = 106079 [ (buf.validate.field).string.min_len = 1 ]; - string value = 111972721 [ (validate.rules).string.min_len = 1 ]; + string value = 111972721 [ (buf.validate.field).string.min_len = 1 ]; } diff --git a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.go b/api/kessel/inventory/v1beta1/resources/rhel_host.pb.go index 57793a76..b990b47c 100644 --- a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.go +++ b/api/kessel/inventory/v1beta1/resources/rhel_host.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -89,37 +89,37 @@ var file_kessel_inventory_v1beta1_resources_rhel_host_proto_rawDesc = []byte{ 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 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, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x31, 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, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc7, 0x01, - 0x0a, 0x08, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x54, 0x0a, 0x08, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 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, 0x65, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x31, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xc1, 0x01, 0x0a, 0x08, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x50, + 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2c, 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, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, + 0xba, 0x48, 0x03, 0xd8, 0x01, 0x03, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x63, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0xc8, 0xd0, 0xfa, 0x74, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, - 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x0b, 0xe0, 0x41, - 0x04, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, - 0x5a, 0x4e, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x09, 0xe0, 0x41, + 0x04, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x42, 0x86, 0x01, 0x0a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x50, 0x01, 0x5a, 0x4e, + 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate.go b/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate.go deleted file mode 100644 index a7767881..00000000 --- a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate.go +++ /dev/null @@ -1,204 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/rhel_host.proto - -package resources - -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 RhelHost 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 *RhelHost) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RhelHost 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 RhelHostMultiError, or nil -// if none found. -func (m *RhelHost) ValidateAll() error { - return m.validate(true) -} - -func (m *RhelHost) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMetadata()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RhelHostValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RhelHostValidationError{ - 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 RhelHostValidationError{ - field: "Metadata", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if m.GetReporterData() == nil { - err := RhelHostValidationError{ - field: "ReporterData", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetReporterData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RhelHostValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RhelHostValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetReporterData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RhelHostValidationError{ - field: "ReporterData", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RhelHostMultiError(errors) - } - - return nil -} - -// RhelHostMultiError is an error wrapping multiple validation errors returned -// by RhelHost.ValidateAll() if the designated constraints aren't met. -type RhelHostMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RhelHostMultiError) 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 RhelHostMultiError) AllErrors() []error { return m } - -// RhelHostValidationError is the validation error returned by -// RhelHost.Validate if the designated constraints aren't met. -type RhelHostValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RhelHostValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RhelHostValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RhelHostValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RhelHostValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RhelHostValidationError) ErrorName() string { return "RhelHostValidationError" } - -// Error satisfies the builtin error interface -func (e RhelHostValidationError) 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 %sRhelHost.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RhelHostValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RhelHostValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate_test.go b/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate_test.go deleted file mode 100644 index 5bfe171b..00000000 --- a/api/kessel/inventory/v1beta1/resources/rhel_host.pb.validate_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package resources - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestRhelHostOptionalMetadata(t *testing.T) { - host := RhelHost{ - ReporterData: &ReporterData{ - ReporterType: ReporterData_OCM, - LocalResourceId: "foo", - }, - } - err := host.ValidateAll() - - assert.NoError(t, err) -} - -func TestRhelHostMetadataIsValidatedIfFound(t *testing.T) { - host := RhelHost{ - ReporterData: &ReporterData{ - ReporterType: ReporterData_OCM, - LocalResourceId: "foo", - }, - Metadata: &Metadata{ - Labels: []*ResourceLabel{ - {}, - }, - }, - } - err := host.ValidateAll() - - assert.ErrorContains(t, err, "RhelHost.Metadata") - assert.ErrorContains(t, err, "Metadata.Labels") -} - -func TestRhelHostReporterDataIsValidated(t *testing.T) { - host := RhelHost{} - err := host.ValidateAll() - - assert.ErrorContains(t, err, "RhelHost.ReporterData") -} diff --git a/api/kessel/inventory/v1beta1/resources/rhel_host.proto b/api/kessel/inventory/v1beta1/resources/rhel_host.proto index 58c04e34..be3dd6ef 100644 --- a/api/kessel/inventory/v1beta1/resources/rhel_host.proto +++ b/api/kessel/inventory/v1beta1/resources/rhel_host.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; import "google/api/field_behavior.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/metadata.proto"; import "kessel/inventory/v1beta1/resources/reporter_data.proto"; @@ -14,9 +14,9 @@ option java_package = "org.project_kessel.api.inventory.v1beta1.resources"; message RhelHost { // Metadata about this resource - Metadata metadata = 1 [ (validate.rules).message = {required: false, skip: false} ]; + Metadata metadata = 1 [ (buf.validate.field) = {required: false, ignore: IGNORE_ALWAYS} ]; // Write only reporter specific data ReporterData reporter_data = 245278792 - [ (google.api.field_behavior) = INPUT_ONLY, (validate.rules).message.required = true ]; + [ (google.api.field_behavior) = INPUT_ONLY, (buf.validate.field).required = true ]; } diff --git a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.go b/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.go index aba7c938..bc526e30 100644 --- a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.go +++ b/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.go @@ -7,7 +7,7 @@ package resources import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -302,34 +302,34 @@ var file_kessel_inventory_v1beta1_resources_rhel_hosts_service_proto_rawDesc = [ 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 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, 0x1a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x72, 0x68, 0x65, - 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x15, + 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x32, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2f, 0x72, 0x68, 0x65, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x6a, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x51, 0x0a, 0x09, 0x72, 0x68, 0x65, + 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x73, 0x2e, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, + 0x01, 0x01, 0x52, 0x08, 0x72, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x09, 0x72, 0x68, 0x65, 0x6c, 0x5f, 0x68, 0x6f, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x23, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x09, 0x72, 0x68, 0x65, 0x6c, 0x5f, 0x68, 0x6f, + 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x68, - 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, - 0x52, 0x08, 0x72, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x91, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, - 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, - 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x09, 0x72, 0x68, 0x65, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 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, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2e, 0x52, 0x68, 0x65, 0x6c, - 0x48, 0x6f, 0x73, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, + 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x08, 0x72, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x18, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3c, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x08, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, + 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xf0, 0x04, 0x0a, 0x15, 0x4b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x52, 0x68, 0x65, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x72, diff --git a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.validate.go b/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.validate.go deleted file mode 100644 index cba03cf5..00000000 --- a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.pb.validate.go +++ /dev/null @@ -1,750 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/inventory/v1beta1/resources/rhel_hosts_service.proto - -package resources - -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 CreateRhelHostRequest 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 *CreateRhelHostRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateRhelHostRequest 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 -// CreateRhelHostRequestMultiError, or nil if none found. -func (m *CreateRhelHostRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateRhelHostRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetRhelHost() == nil { - err := CreateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetRhelHost()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRhelHost()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateRhelHostRequestMultiError(errors) - } - - return nil -} - -// CreateRhelHostRequestMultiError is an error wrapping multiple validation -// errors returned by CreateRhelHostRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateRhelHostRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateRhelHostRequestMultiError) 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 CreateRhelHostRequestMultiError) AllErrors() []error { return m } - -// CreateRhelHostRequestValidationError is the validation error returned by -// CreateRhelHostRequest.Validate if the designated constraints aren't met. -type CreateRhelHostRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateRhelHostRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateRhelHostRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateRhelHostRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateRhelHostRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateRhelHostRequestValidationError) ErrorName() string { - return "CreateRhelHostRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateRhelHostRequestValidationError) 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 %sCreateRhelHostRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateRhelHostRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateRhelHostRequestValidationError{} - -// Validate checks the field values on CreateRhelHostResponse 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 *CreateRhelHostResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateRhelHostResponse 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 -// CreateRhelHostResponseMultiError, or nil if none found. -func (m *CreateRhelHostResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateRhelHostResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return CreateRhelHostResponseMultiError(errors) - } - - return nil -} - -// CreateRhelHostResponseMultiError is an error wrapping multiple validation -// errors returned by CreateRhelHostResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateRhelHostResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateRhelHostResponseMultiError) 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 CreateRhelHostResponseMultiError) AllErrors() []error { return m } - -// CreateRhelHostResponseValidationError is the validation error returned by -// CreateRhelHostResponse.Validate if the designated constraints aren't met. -type CreateRhelHostResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateRhelHostResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateRhelHostResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateRhelHostResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateRhelHostResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateRhelHostResponseValidationError) ErrorName() string { - return "CreateRhelHostResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateRhelHostResponseValidationError) 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 %sCreateRhelHostResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateRhelHostResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateRhelHostResponseValidationError{} - -// Validate checks the field values on UpdateRhelHostRequest 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 *UpdateRhelHostRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateRhelHostRequest 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 -// UpdateRhelHostRequestMultiError, or nil if none found. -func (m *UpdateRhelHostRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateRhelHostRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetResource()) < 1 { - err := UpdateRhelHostRequestValidationError{ - field: "Resource", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.GetRhelHost() == nil { - err := UpdateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetRhelHost()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRhelHost()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateRhelHostRequestValidationError{ - field: "RhelHost", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateRhelHostRequestMultiError(errors) - } - - return nil -} - -// UpdateRhelHostRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateRhelHostRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateRhelHostRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateRhelHostRequestMultiError) 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 UpdateRhelHostRequestMultiError) AllErrors() []error { return m } - -// UpdateRhelHostRequestValidationError is the validation error returned by -// UpdateRhelHostRequest.Validate if the designated constraints aren't met. -type UpdateRhelHostRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateRhelHostRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateRhelHostRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateRhelHostRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateRhelHostRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateRhelHostRequestValidationError) ErrorName() string { - return "UpdateRhelHostRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateRhelHostRequestValidationError) 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 %sUpdateRhelHostRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateRhelHostRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateRhelHostRequestValidationError{} - -// Validate checks the field values on UpdateRhelHostResponse 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 *UpdateRhelHostResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateRhelHostResponse 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 -// UpdateRhelHostResponseMultiError, or nil if none found. -func (m *UpdateRhelHostResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateRhelHostResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdateRhelHostResponseMultiError(errors) - } - - return nil -} - -// UpdateRhelHostResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateRhelHostResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateRhelHostResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateRhelHostResponseMultiError) 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 UpdateRhelHostResponseMultiError) AllErrors() []error { return m } - -// UpdateRhelHostResponseValidationError is the validation error returned by -// UpdateRhelHostResponse.Validate if the designated constraints aren't met. -type UpdateRhelHostResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateRhelHostResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateRhelHostResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateRhelHostResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateRhelHostResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateRhelHostResponseValidationError) ErrorName() string { - return "UpdateRhelHostResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateRhelHostResponseValidationError) 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 %sUpdateRhelHostResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateRhelHostResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateRhelHostResponseValidationError{} - -// Validate checks the field values on DeleteRhelHostRequest 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 *DeleteRhelHostRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteRhelHostRequest 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 -// DeleteRhelHostRequestMultiError, or nil if none found. -func (m *DeleteRhelHostRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteRhelHostRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetResource()) < 1 { - err := DeleteRhelHostRequestValidationError{ - field: "Resource", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return DeleteRhelHostRequestMultiError(errors) - } - - return nil -} - -// DeleteRhelHostRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteRhelHostRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteRhelHostRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteRhelHostRequestMultiError) 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 DeleteRhelHostRequestMultiError) AllErrors() []error { return m } - -// DeleteRhelHostRequestValidationError is the validation error returned by -// DeleteRhelHostRequest.Validate if the designated constraints aren't met. -type DeleteRhelHostRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteRhelHostRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteRhelHostRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteRhelHostRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteRhelHostRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteRhelHostRequestValidationError) ErrorName() string { - return "DeleteRhelHostRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteRhelHostRequestValidationError) 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 %sDeleteRhelHostRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteRhelHostRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteRhelHostRequestValidationError{} - -// Validate checks the field values on DeleteRhelHostResponse 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 *DeleteRhelHostResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteRhelHostResponse 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 -// DeleteRhelHostResponseMultiError, or nil if none found. -func (m *DeleteRhelHostResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteRhelHostResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteRhelHostResponseMultiError(errors) - } - - return nil -} - -// DeleteRhelHostResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteRhelHostResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteRhelHostResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteRhelHostResponseMultiError) 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 DeleteRhelHostResponseMultiError) AllErrors() []error { return m } - -// DeleteRhelHostResponseValidationError is the validation error returned by -// DeleteRhelHostResponse.Validate if the designated constraints aren't met. -type DeleteRhelHostResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteRhelHostResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteRhelHostResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteRhelHostResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteRhelHostResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteRhelHostResponseValidationError) ErrorName() string { - return "DeleteRhelHostResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteRhelHostResponseValidationError) 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 %sDeleteRhelHostResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteRhelHostResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteRhelHostResponseValidationError{} diff --git a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.proto b/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.proto index d20df31f..9626e6c6 100644 --- a/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.proto +++ b/api/kessel/inventory/v1beta1/resources/rhel_hosts_service.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package kessel.inventory.v1beta1.resources; import "google/api/annotations.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; import "kessel/inventory/v1beta1/resources/rhel_host.proto"; @@ -13,7 +13,7 @@ option java_package = "org.project_kessel.api.inventory.v1beta1.resources"; message CreateRhelHostRequest { // The Rhel Host to create in Kessel Asset Inventory - RhelHost rhel_host = 1 [ (validate.rules).message.required = true ]; + RhelHost rhel_host = 1 [ (buf.validate.field).required = true ]; } message CreateRhelHostResponse {} @@ -21,9 +21,9 @@ message CreateRhelHostResponse {} message UpdateRhelHostRequest { // A resource instance using the format: // \":\" - string resource = 1 [ (validate.rules).string.min_len = 1 ]; + string resource = 1 [ (buf.validate.field).string.min_len = 1 ]; // The Rhel host to update - RhelHost rhel_host = 2 [ (validate.rules).message.required = true ]; + RhelHost rhel_host = 2 [ (buf.validate.field).required = true ]; } message UpdateRhelHostResponse {} @@ -31,7 +31,7 @@ message UpdateRhelHostResponse {} message DeleteRhelHostRequest { // A resource instance using the format: // \":\" - string resource = 1 [ (validate.rules).string.min_len = 1 ]; + string resource = 1 [ (buf.validate.field).string.min_len = 1 ]; } message DeleteRhelHostResponse {} diff --git a/go.mod b/go.mod index b3f561b5..08e890bc 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,13 @@ module github.com/project-kessel/inventory-api go 1.22.5 require ( + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403 + github.com/bufbuild/protovalidate-go v0.6.4 github.com/cloudevents/sdk-go/protocol/kafka_confluent/v2 v2.0.0-20240718090307-5f0cc73d49ff github.com/cloudevents/sdk-go/v2 v2.15.2 github.com/confluentinc/confluent-kafka-go/v2 v2.5.0 github.com/coreos/go-oidc/v3 v3.11.0 - github.com/envoyproxy/protoc-gen-validate v1.1.0 github.com/go-kratos/kratos/v2 v2.8.0 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/wire v0.6.0 @@ -28,15 +29,19 @@ require ( ) require ( + github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect github.com/containerd/platforms v0.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-jose/go-jose/v4 v4.0.2 // indirect github.com/go-kratos/aegis v0.2.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/form/v4 v4.2.1 // indirect + github.com/google/cel-go v0.21.0 // indirect + github.com/google/subcommands v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect @@ -61,6 +66,7 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect + github.com/stoewer/go-strcase v1.3.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.opentelemetry.io/otel v1.28.0 // indirect @@ -71,11 +77,13 @@ 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 gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index fb51a8cd..321dc7fb 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 h1:SZRVx928rbYZ6hEKUIN+vtGDkl7uotABRWGY4OAg5gM= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= cel.dev/expr v0.15.0 h1:O1jzfJCQBfL5BFoYktaxwIhuttaQPsVWerH9/EEKx0w= cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -22,6 +24,8 @@ github.com/Microsoft/hcsshim v0.11.4 h1:68vKo2VN8DE9AdN4tnkWnmdhqdbpUFM8OF3Airm7 github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYxPRqGcpAD9w= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= +github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= +github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403 h1:bQeIwWWRI9bl93poTqpix4sYHi+gnXUPK7N6bMtXzBE= github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403/go.mod h1:s3qC7V7XIbiNWERv7Lfljy/Lx25/V1Qlexb0WJuA8uQ= github.com/aws/aws-sdk-go-v2 v1.26.1 h1:5554eUqIYVWpU0YmeeYZ0wU64H2VLBs8TlhRB2L+EkA= @@ -54,6 +58,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bufbuild/protovalidate-go v0.6.4 h1:QtNIz4LGclM3UArQv/R1AKNF7MO8wriT9v7b8Gnmqak= +github.com/bufbuild/protovalidate-go v0.6.4/go.mod h1:HlkVnkE/zVYZvHIG/a7QZuzqC9bSqHaOOTeRomYF0Q8= github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY= github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -185,6 +191,8 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/cel-go v0.21.0 h1:cl6uW/gxN+Hy50tNYvI691+sXxioCnstFzLp2WO4GCI= +github.com/google/cel-go v0.21.0/go.mod h1:rHUlWCcBKgyEk+eV03RPdZUekPp6YcJwV0FxuUksYxc= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -195,6 +203,7 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -383,6 +392,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= +github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -395,6 +406,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -500,6 +512,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 +597,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= diff --git a/internal/middleware/validation.go b/internal/middleware/validation.go new file mode 100644 index 00000000..133fe88e --- /dev/null +++ b/internal/middleware/validation.go @@ -0,0 +1,23 @@ +package middleware + +import ( + "context" + + "github.com/bufbuild/protovalidate-go" + "github.com/go-kratos/kratos/v2/errors" + "github.com/go-kratos/kratos/v2/middleware" + "google.golang.org/protobuf/proto" +) + +func Validation(validator *protovalidate.Validator) middleware.Middleware { + return func(handler middleware.Handler) middleware.Handler { + return func(ctx context.Context, req interface{}) (interface{}, error) { + if v, ok := req.(proto.Message); ok { + if err := validator.Validate(v); err != nil { + return nil, errors.BadRequest("VALIDATOR", err.Error()).WithCause(err) + } + } + return handler(ctx, req) + } + } +} diff --git a/internal/middleware/validation_test.go b/internal/middleware/validation_test.go new file mode 100644 index 00000000..ef4030e2 --- /dev/null +++ b/internal/middleware/validation_test.go @@ -0,0 +1,52 @@ +package middleware + +import ( + "context" + "testing" + + "github.com/bufbuild/protovalidate-go" + "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources" + + "github.com/stretchr/testify/assert" +) + +func TestValidation_ValidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + m := Validation(validator) + + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return "success", nil + } + + resp, err := m(handler)(context.Background(), &resources.CreateRhelHostRequest{ + RhelHost: &resources.RhelHost{ + Metadata: &resources.Metadata{}, + ReporterData: &resources.ReporterData{ + ReporterType: 1, + LocalResourceId: "1", + }, + }, + }) + assert.NoError(t, err) + assert.Equal(t, "success", resp) +} + +func TestValidation_InvalidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + m := Validation(validator) + + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return nil, nil + } + resp, err := m(handler)(context.Background(), &resources.CreateRhelHostRequest{}) + assert.Error(t, err) + assert.Equal(t, resp, nil) +} diff --git a/internal/server/grpc/grpc.go b/internal/server/grpc/grpc.go index bc22db3d..1a7c43ff 100644 --- a/internal/server/grpc/grpc.go +++ b/internal/server/grpc/grpc.go @@ -1,19 +1,25 @@ package grpc import ( + "github.com/bufbuild/protovalidate-go" "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/selector" kgrpc "github.com/go-kratos/kratos/v2/transport/grpc" + m "github.com/project-kessel/inventory-api/internal/middleware" ) // New creates a new a gRPC server. func New(c CompletedConfig, authn middleware.Middleware) *kgrpc.Server { - + validator, err := protovalidate.New() + if err != nil { + return nil + } // TODO: pass in health, authn middleware var opts = []kgrpc.ServerOption{ kgrpc.Middleware( recovery.Recovery(), + m.Validation(validator), selector.Server( authn, ).Match(NewWhiteListMatcher).Build(), diff --git a/internal/server/http/http.go b/internal/server/http/http.go index d0b1aa3f..12101bb2 100644 --- a/internal/server/http/http.go +++ b/internal/server/http/http.go @@ -1,18 +1,25 @@ package http import ( + "github.com/bufbuild/protovalidate-go" "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/selector" "github.com/go-kratos/kratos/v2/transport/http" + m "github.com/project-kessel/inventory-api/internal/middleware" ) // New create a new http server. func New(c CompletedConfig, authn middleware.Middleware) *http.Server { + validator, err := protovalidate.New() + if err != nil { + return nil + } // TODO: pass in health, authn middleware var opts = []http.ServerOption{ http.Middleware( recovery.Recovery(), + m.Validation(validator), selector.Server( authn, ).Match(NewWhiteListMatcher).Build(), diff --git a/internal/service/hosts/hosts.go b/internal/service/hosts/hosts.go index 31e334be..d183b350 100644 --- a/internal/service/hosts/hosts.go +++ b/internal/service/hosts/hosts.go @@ -3,7 +3,6 @@ package hosts import ( "context" - "github.com/go-kratos/kratos/v2/errors" pb "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources" authnapi "github.com/project-kessel/inventory-api/internal/authn/api" biz "github.com/project-kessel/inventory-api/internal/biz/hosts" @@ -26,10 +25,6 @@ func New(c *biz.HostUsecase) *HostsService { } func (c *HostsService) CreateRhelHost(ctx context.Context, r *pb.CreateRhelHostRequest) (*pb.CreateRhelHostResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, errors.BadRequest("BADREQUEST", err.Error()) - } - identity, err := middleware.GetIdentity(ctx) if err != nil { return nil, err @@ -48,16 +43,10 @@ func (c *HostsService) CreateRhelHost(ctx context.Context, r *pb.CreateRhelHostR } func (c *HostsService) UpdateRhelHost(ctx context.Context, r *pb.UpdateRhelHostRequest) (*pb.UpdateRhelHostResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, err - } return nil, nil } func (c *HostsService) DeleteRhelHost(ctx context.Context, r *pb.DeleteRhelHostRequest) (*pb.DeleteRhelHostResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, err - } return nil, nil } diff --git a/internal/service/hosts/hosts_test.go b/internal/service/hosts/hosts_test.go index 8897f6f2..2be9914b 100644 --- a/internal/service/hosts/hosts_test.go +++ b/internal/service/hosts/hosts_test.go @@ -102,26 +102,3 @@ func TestCreateHostWithOptionalAttributesIsSuccess(t *testing.T) { assert.NoError(t, err) } - -func TestCreateInvalidHostIsBadRequest(t *testing.T) { - repo := new(HostRepoMock) - hostUsecase := hosts.New(repo, log.DefaultLogger) - - service := HostsService{ - Ctl: hostUsecase, - } - ctx := mockContext() - - request := pb.CreateRhelHostRequest{ - RhelHost: &pb.RhelHost{ - Metadata: nil, - ReporterData: &pb.ReporterData{ - ReporterType: pb.ReporterData_OCM, - }, - }, - } - - _, err := service.CreateRhelHost(ctx, &request) - - assert.ErrorContains(t, err, "400") -} diff --git a/internal/service/k8sclusters/k8scluster.go b/internal/service/k8sclusters/k8scluster.go index 40b5f105..8fb84ff0 100644 --- a/internal/service/k8sclusters/k8scluster.go +++ b/internal/service/k8sclusters/k8scluster.go @@ -30,10 +30,6 @@ func New(c *biz.K8sClusterUsecase) *K8sClustersService { } func (c *K8sClustersService) CreateK8SCluster(ctx context.Context, r *resources.CreateK8SClusterRequest) (*resources.CreateK8SClusterResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, err - } - if !strings.EqualFold(r.K8SCluster.Metadata.ResourceType, biz.ResourceType) { return nil, errors.BadRequest("BADREQUEST", fmt.Sprintf("incorrect resource type: expected %s", biz.ResourceType)) } diff --git a/internal/service/k8spolicies/k8spolicies.go b/internal/service/k8spolicies/k8spolicies.go index 70fd608c..94297ef1 100644 --- a/internal/service/k8spolicies/k8spolicies.go +++ b/internal/service/k8spolicies/k8spolicies.go @@ -3,7 +3,6 @@ package k8spolicies import ( "context" - "github.com/go-kratos/kratos/v2/errors" "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources" pb "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources" authnapi "github.com/project-kessel/inventory-api/internal/authn/api" @@ -27,10 +26,6 @@ func New(c *biz.K8sPolicyUsecase) *K8sPolicyService { } func (c *K8sPolicyService) CreateK8SPolicy(ctx context.Context, r *resources.CreateK8SPolicyRequest) (*resources.CreateK8SPolicyResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, errors.BadRequest("BADREQUEST", err.Error()) - } - identity, err := middleware.GetIdentity(ctx) if err != nil { return nil, err diff --git a/internal/service/notificationsintegrations/notificationsintegrations.go b/internal/service/notificationsintegrations/notificationsintegrations.go index 6f7322bb..a16166d3 100644 --- a/internal/service/notificationsintegrations/notificationsintegrations.go +++ b/internal/service/notificationsintegrations/notificationsintegrations.go @@ -3,7 +3,6 @@ package notificationsintegrations import ( "context" - "github.com/go-kratos/kratos/v2/errors" pb "github.com/project-kessel/inventory-api/api/kessel/inventory/v1beta1/resources" authnapi "github.com/project-kessel/inventory-api/internal/authn/api" biz "github.com/project-kessel/inventory-api/internal/biz/notificationsintegrations" @@ -26,10 +25,6 @@ func New(c *biz.NotificationsIntegrationUsecase) *NotificationsIntegrationsServi } func (c *NotificationsIntegrationsService) CreateNotificationsIntegration(ctx context.Context, r *pb.CreateNotificationsIntegrationRequest) (*pb.CreateNotificationsIntegrationResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, errors.BadRequest("BADREQUEST", err.Error()) - } - identity, err := middleware.GetIdentity(ctx) if err != nil { return nil, err @@ -48,16 +43,10 @@ func (c *NotificationsIntegrationsService) CreateNotificationsIntegration(ctx co } func (c *NotificationsIntegrationsService) UpdateNotificationsIntegration(ctx context.Context, r *pb.UpdateNotificationsIntegrationRequest) (*pb.UpdateNotificationsIntegrationResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, err - } return nil, nil } func (c *NotificationsIntegrationsService) DeleteNotificationsIntegration(ctx context.Context, r *pb.DeleteNotificationsIntegrationRequest) (*pb.DeleteNotificationsIntegrationResponse, error) { - if err := r.ValidateAll(); err != nil { - return nil, err - } return nil, nil } diff --git a/internal/service/notificationsintegrations/notificationsintegrations_test.go b/internal/service/notificationsintegrations/notificationsintegrations_test.go index 65277535..0b11bc73 100644 --- a/internal/service/notificationsintegrations/notificationsintegrations_test.go +++ b/internal/service/notificationsintegrations/notificationsintegrations_test.go @@ -71,27 +71,3 @@ func TestCreateNotificationIntegrationWithRequiredDataIsSuccess(t *testing.T) { assert.NoError(t, err) } - -func TestCreateInvalidNotificationIntegrationIsBadRequest(t *testing.T) { - repo := new(NotificationIntegrationsRepoMock) - notificationsintegrationsUsecase := biz.New(repo, log.DefaultLogger) - - service := NotificationsIntegrationsService{ - Ctl: notificationsintegrationsUsecase, - } - - ctx := mockContext() - - request := pb.CreateNotificationsIntegrationRequest{ - Integration: &pb.NotificationsIntegration{ - Metadata: nil, - ReporterData: &pb.ReporterData{ - ReporterType: pb.ReporterData_HBI, - }, - }, - } - - _, err := service.CreateNotificationsIntegration(ctx, &request) - - assert.ErrorContains(t, err, "400") -}