diff --git a/api/Dockerfile b/api/Dockerfile index 5673b8a..fe7759a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -13,7 +13,6 @@ RUN ln -s /usr/local/go/bin/go /usr/local/bin/go RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest RUN go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest -RUN go install github.com/envoyproxy/protoc-gen-validate@latest # Install Buf RUN go install github.com/bufbuild/buf/cmd/buf@latest @@ -24,5 +23,4 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.10 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/buf /usr/local/bin/buf diff --git a/api/buf.gen.yaml b/api/buf.gen.yaml index 1afbdd9..4128aed 100644 --- a/api/buf.gen.yaml +++ b/api/buf.gen.yaml @@ -14,8 +14,3 @@ plugins: opt: - fq_schema_naming=true - default_response=false - - local: protoc-gen-validate - opt: - - paths=source_relative - - lang=go - out: . diff --git a/api/buf.lock b/api/buf.lock index 3db32a7..0b2cbf6 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: f0e53af8f2fc4556b94f482688b57223 - digest: b5:24e758f963ee1bb3b5218eb452e0bdfb7a5449d9a77d174b8284b6368ccc1884213689381cdcd79e4231796c281c128ac1ae50825237b1774deb542bdc704b32 + commit: 8bc2c51e08c447cd8886cdea48a73e14 + digest: b5:b7e0ac9d192bd0eae88160101269550281448c51f25121cd0d51957661a350aab07001bc145fe9029a8da10b99ff000ae5b284ecaca9c75f2a99604a04d9b4ab diff --git a/api/buf.yaml b/api/buf.yaml index 9e43c0d..7dfc4b9 100644 --- a/api/buf.yaml +++ b/api/buf.yaml @@ -8,4 +8,4 @@ breaking: - FILE deps: - buf.build/googleapis/googleapis - - buf.build/envoyproxy/protoc-gen-validate + - buf.build/bufbuild/protovalidate diff --git a/api/kessel/relations/v1/health.pb.validate.go b/api/kessel/relations/v1/health.pb.validate.go deleted file mode 100644 index bafc2b8..0000000 --- a/api/kessel/relations/v1/health.pb.validate.go +++ /dev/null @@ -1,446 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/relations/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/relations/v1beta1/check.pb.go b/api/kessel/relations/v1beta1/check.pb.go index e0404e6..3ed89da 100644 --- a/api/kessel/relations/v1beta1/check.pb.go +++ b/api/kessel/relations/v1beta1/check.pb.go @@ -7,7 +7,7 @@ package v1beta1 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" @@ -192,21 +192,21 @@ var file_kessel_relations_v1beta1_check_proto_rawDesc = []byte{ 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 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, 0xd4, - 0x01, 0x0a, 0x0c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x4f, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x29, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, - 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4e, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x07, 0x73, 0x75, + 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, 0xd0, 0x01, 0x0a, 0x0c, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4c, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, + 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x22, 0xa3, 0x01, 0x0a, 0x0d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x07, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, diff --git a/api/kessel/relations/v1beta1/check.pb.validate.go b/api/kessel/relations/v1beta1/check.pb.validate.go deleted file mode 100644 index e032078..0000000 --- a/api/kessel/relations/v1beta1/check.pb.validate.go +++ /dev/null @@ -1,278 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/relations/v1beta1/check.proto - -package v1beta1 - -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 CheckRequest 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 *CheckRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CheckRequest 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 CheckRequestMultiError, or -// nil if none found. -func (m *CheckRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CheckRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetResource() == nil { - err := CheckRequestValidationError{ - field: "Resource", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetResource(); a != nil { - - } - - if utf8.RuneCountInString(m.GetRelation()) < 1 { - err := CheckRequestValidationError{ - field: "Relation", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.GetSubject() == nil { - err := CheckRequestValidationError{ - field: "Subject", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetSubject(); a != nil { - - } - - if len(errors) > 0 { - return CheckRequestMultiError(errors) - } - - return nil -} - -// CheckRequestMultiError is an error wrapping multiple validation errors -// returned by CheckRequest.ValidateAll() if the designated constraints aren't met. -type CheckRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CheckRequestMultiError) 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 CheckRequestMultiError) AllErrors() []error { return m } - -// CheckRequestValidationError is the validation error returned by -// CheckRequest.Validate if the designated constraints aren't met. -type CheckRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CheckRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CheckRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CheckRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CheckRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CheckRequestValidationError) ErrorName() string { return "CheckRequestValidationError" } - -// Error satisfies the builtin error interface -func (e CheckRequestValidationError) 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 %sCheckRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CheckRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CheckRequestValidationError{} - -// Validate checks the field values on CheckResponse 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 *CheckResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CheckResponse 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 CheckResponseMultiError, or -// nil if none found. -func (m *CheckResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CheckResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Allowed - - if len(errors) > 0 { - return CheckResponseMultiError(errors) - } - - return nil -} - -// CheckResponseMultiError is an error wrapping multiple validation errors -// returned by CheckResponse.ValidateAll() if the designated constraints -// aren't met. -type CheckResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CheckResponseMultiError) 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 CheckResponseMultiError) AllErrors() []error { return m } - -// CheckResponseValidationError is the validation error returned by -// CheckResponse.Validate if the designated constraints aren't met. -type CheckResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CheckResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CheckResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CheckResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CheckResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CheckResponseValidationError) ErrorName() string { return "CheckResponseValidationError" } - -// Error satisfies the builtin error interface -func (e CheckResponseValidationError) 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 %sCheckResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CheckResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CheckResponseValidationError{} diff --git a/api/kessel/relations/v1beta1/check.proto b/api/kessel/relations/v1beta1/check.proto index f815003..721cd62 100644 --- a/api/kessel/relations/v1beta1/check.proto +++ b/api/kessel/relations/v1beta1/check.proto @@ -4,7 +4,7 @@ package kessel.relations.v1beta1; import "google/api/annotations.proto"; import "kessel/relations/v1beta1/common.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1"; @@ -23,9 +23,9 @@ service KesselCheckService { } message CheckRequest { - ObjectReference resource = 1 [(validate.rules).any.required = true]; - string relation = 2 [(validate.rules).string.min_len = 1]; - SubjectReference subject = 3 [(validate.rules).any.required = true]; + ObjectReference resource = 1 [(buf.validate.field).required = true]; + string relation = 2 [(buf.validate.field).string.min_len = 1]; + SubjectReference subject = 3 [(buf.validate.field).required = true]; } message CheckResponse { diff --git a/api/kessel/relations/v1beta1/common.pb.go b/api/kessel/relations/v1beta1/common.pb.go index 514f502..4dd0d3d 100644 --- a/api/kessel/relations/v1beta1/common.pb.go +++ b/api/kessel/relations/v1beta1/common.pb.go @@ -7,7 +7,7 @@ package v1beta1 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" @@ -370,63 +370,63 @@ var file_kessel_relations_v1beta1_common_proto_rawDesc = []byte{ 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 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, 0xd4, 0x01, 0x0a, 0x0c, 0x52, - 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x12, 0x4f, 0x0a, 0x08, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, - 0x08, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x0a, 0x08, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x4e, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, - 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x22, 0x8f, 0x01, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, + 0x31, 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, 0xd0, + 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x12, + 0x4d, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x29, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x06, 0xba, 0x48, + 0x03, 0xc8, 0x01, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, + 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x4c, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x22, 0x8d, 0x01, 0x0a, 0x10, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x4d, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, + 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x4b, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, - 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x07, 0x73, - 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x7d, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x2a, 0x02, 0x20, 0x00, - 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x32, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x74, 0x69, - 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x15, 0x0a, 0x13, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x22, 0x43, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x74, - 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6e, 0x0a, 0x0f, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x42, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, - 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, - 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, - 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x22, 0x50, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, - 0x01, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, - 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x72, 0x0a, 0x28, 0x6f, 0x72, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x50, 0x01, 0x5a, 0x44, 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, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2d, 0x61, 0x70, 0x69, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x63, 0x65, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x22, 0x7d, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xba, 0x48, 0x04, 0x2a, 0x02, 0x20, 0x00, 0x52, 0x05, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x32, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x48, 0x00, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x15, 0x0a, 0x13, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x22, 0x43, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, + 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6c, 0x0a, 0x0f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x40, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x06, 0xba, 0x48, + 0x03, 0xc8, 0x01, 0x01, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, + 0x02, 0x69, 0x64, 0x22, 0x50, 0x0a, 0x0a, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x25, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x72, 0x0a, 0x28, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x50, 0x01, 0x5a, 0x44, 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, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/api/kessel/relations/v1beta1/common.pb.validate.go b/api/kessel/relations/v1beta1/common.pb.validate.go deleted file mode 100644 index 22ed79f..0000000 --- a/api/kessel/relations/v1beta1/common.pb.validate.go +++ /dev/null @@ -1,763 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/relations/v1beta1/common.proto - -package v1beta1 - -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 Relationship 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 *Relationship) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Relationship 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 RelationshipMultiError, or -// nil if none found. -func (m *Relationship) ValidateAll() error { - return m.validate(true) -} - -func (m *Relationship) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetResource() == nil { - err := RelationshipValidationError{ - field: "Resource", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetResource(); a != nil { - - } - - if utf8.RuneCountInString(m.GetRelation()) < 1 { - err := RelationshipValidationError{ - field: "Relation", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.GetSubject() == nil { - err := RelationshipValidationError{ - field: "Subject", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetSubject(); a != nil { - - } - - if len(errors) > 0 { - return RelationshipMultiError(errors) - } - - return nil -} - -// RelationshipMultiError is an error wrapping multiple validation errors -// returned by Relationship.ValidateAll() if the designated constraints aren't met. -type RelationshipMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RelationshipMultiError) 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 RelationshipMultiError) AllErrors() []error { return m } - -// RelationshipValidationError is the validation error returned by -// Relationship.Validate if the designated constraints aren't met. -type RelationshipValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RelationshipValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RelationshipValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RelationshipValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RelationshipValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RelationshipValidationError) ErrorName() string { return "RelationshipValidationError" } - -// Error satisfies the builtin error interface -func (e RelationshipValidationError) 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 %sRelationship.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RelationshipValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RelationshipValidationError{} - -// Validate checks the field values on SubjectReference 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 *SubjectReference) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on SubjectReference 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 -// SubjectReferenceMultiError, or nil if none found. -func (m *SubjectReference) ValidateAll() error { - return m.validate(true) -} - -func (m *SubjectReference) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetSubject() == nil { - err := SubjectReferenceValidationError{ - field: "Subject", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetSubject(); a != nil { - - } - - if m.Relation != nil { - // no validation rules for Relation - } - - if len(errors) > 0 { - return SubjectReferenceMultiError(errors) - } - - return nil -} - -// SubjectReferenceMultiError is an error wrapping multiple validation errors -// returned by SubjectReference.ValidateAll() if the designated constraints -// aren't met. -type SubjectReferenceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m SubjectReferenceMultiError) 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 SubjectReferenceMultiError) AllErrors() []error { return m } - -// SubjectReferenceValidationError is the validation error returned by -// SubjectReference.Validate if the designated constraints aren't met. -type SubjectReferenceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e SubjectReferenceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e SubjectReferenceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e SubjectReferenceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e SubjectReferenceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e SubjectReferenceValidationError) ErrorName() string { return "SubjectReferenceValidationError" } - -// Error satisfies the builtin error interface -func (e SubjectReferenceValidationError) 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 %sSubjectReference.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = SubjectReferenceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = SubjectReferenceValidationError{} - -// Validate checks the field values on RequestPagination 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 *RequestPagination) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RequestPagination 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 -// RequestPaginationMultiError, or nil if none found. -func (m *RequestPagination) ValidateAll() error { - return m.validate(true) -} - -func (m *RequestPagination) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetLimit() <= 0 { - err := RequestPaginationValidationError{ - field: "Limit", - reason: "value must be greater than 0", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.ContinuationToken != nil { - // no validation rules for ContinuationToken - } - - if len(errors) > 0 { - return RequestPaginationMultiError(errors) - } - - return nil -} - -// RequestPaginationMultiError is an error wrapping multiple validation errors -// returned by RequestPagination.ValidateAll() if the designated constraints -// aren't met. -type RequestPaginationMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RequestPaginationMultiError) 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 RequestPaginationMultiError) AllErrors() []error { return m } - -// RequestPaginationValidationError is the validation error returned by -// RequestPagination.Validate if the designated constraints aren't met. -type RequestPaginationValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RequestPaginationValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RequestPaginationValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RequestPaginationValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RequestPaginationValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RequestPaginationValidationError) ErrorName() string { - return "RequestPaginationValidationError" -} - -// Error satisfies the builtin error interface -func (e RequestPaginationValidationError) 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 %sRequestPagination.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RequestPaginationValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RequestPaginationValidationError{} - -// Validate checks the field values on ResponsePagination 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 *ResponsePagination) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResponsePagination 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 -// ResponsePaginationMultiError, or nil if none found. -func (m *ResponsePagination) ValidateAll() error { - return m.validate(true) -} - -func (m *ResponsePagination) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for ContinuationToken - - if len(errors) > 0 { - return ResponsePaginationMultiError(errors) - } - - return nil -} - -// ResponsePaginationMultiError is an error wrapping multiple validation errors -// returned by ResponsePagination.ValidateAll() if the designated constraints -// aren't met. -type ResponsePaginationMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResponsePaginationMultiError) 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 ResponsePaginationMultiError) AllErrors() []error { return m } - -// ResponsePaginationValidationError is the validation error returned by -// ResponsePagination.Validate if the designated constraints aren't met. -type ResponsePaginationValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResponsePaginationValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResponsePaginationValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResponsePaginationValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResponsePaginationValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResponsePaginationValidationError) ErrorName() string { - return "ResponsePaginationValidationError" -} - -// Error satisfies the builtin error interface -func (e ResponsePaginationValidationError) 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 %sResponsePagination.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResponsePaginationValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResponsePaginationValidationError{} - -// Validate checks the field values on ObjectReference 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 *ObjectReference) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ObjectReference 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 -// ObjectReferenceMultiError, or nil if none found. -func (m *ObjectReference) ValidateAll() error { - return m.validate(true) -} - -func (m *ObjectReference) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetType() == nil { - err := ObjectReferenceValidationError{ - field: "Type", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetType(); a != nil { - - } - - if utf8.RuneCountInString(m.GetId()) < 1 { - err := ObjectReferenceValidationError{ - field: "Id", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return ObjectReferenceMultiError(errors) - } - - return nil -} - -// ObjectReferenceMultiError is an error wrapping multiple validation errors -// returned by ObjectReference.ValidateAll() if the designated constraints -// aren't met. -type ObjectReferenceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ObjectReferenceMultiError) 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 ObjectReferenceMultiError) AllErrors() []error { return m } - -// ObjectReferenceValidationError is the validation error returned by -// ObjectReference.Validate if the designated constraints aren't met. -type ObjectReferenceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ObjectReferenceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ObjectReferenceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ObjectReferenceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ObjectReferenceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ObjectReferenceValidationError) ErrorName() string { return "ObjectReferenceValidationError" } - -// Error satisfies the builtin error interface -func (e ObjectReferenceValidationError) 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 %sObjectReference.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ObjectReferenceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ObjectReferenceValidationError{} - -// Validate checks the field values on ObjectType 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 *ObjectType) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ObjectType 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 ObjectTypeMultiError, or -// nil if none found. -func (m *ObjectType) ValidateAll() error { - return m.validate(true) -} - -func (m *ObjectType) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetNamespace()) < 1 { - err := ObjectTypeValidationError{ - field: "Namespace", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetName()) < 1 { - err := ObjectTypeValidationError{ - field: "Name", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return ObjectTypeMultiError(errors) - } - - return nil -} - -// ObjectTypeMultiError is an error wrapping multiple validation errors -// returned by ObjectType.ValidateAll() if the designated constraints aren't met. -type ObjectTypeMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ObjectTypeMultiError) 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 ObjectTypeMultiError) AllErrors() []error { return m } - -// ObjectTypeValidationError is the validation error returned by -// ObjectType.Validate if the designated constraints aren't met. -type ObjectTypeValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ObjectTypeValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ObjectTypeValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ObjectTypeValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ObjectTypeValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ObjectTypeValidationError) ErrorName() string { return "ObjectTypeValidationError" } - -// Error satisfies the builtin error interface -func (e ObjectTypeValidationError) 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 %sObjectType.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ObjectTypeValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ObjectTypeValidationError{} diff --git a/api/kessel/relations/v1beta1/common.proto b/api/kessel/relations/v1beta1/common.proto index ef539f6..189be9f 100644 --- a/api/kessel/relations/v1beta1/common.proto +++ b/api/kessel/relations/v1beta1/common.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package kessel.relations.v1beta1; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1"; option java_multiple_files = true; @@ -18,9 +18,9 @@ option java_package = "org.project_kessel.api.relations.v1beta1"; // Conventionally, we generally refer to the Resource first, then Subject, // following the direction of typical graph traversal (Resource to Subject). message Relationship { - ObjectReference resource = 1 [(validate.rules).any.required = true]; - string relation = 2 [(validate.rules).string.min_len = 1]; - SubjectReference subject = 3 [(validate.rules).any.required = true]; + ObjectReference resource = 1 [(buf.validate.field).required = true]; + string relation = 2 [(buf.validate.field).string.min_len = 1]; + SubjectReference subject = 3 [(buf.validate.field).required = true]; } // A reference to a Subject or, if a `relation` is provided, a Subject Set. @@ -28,11 +28,11 @@ message SubjectReference { // An optional relation which points to a set of Subjects instead of the single Subject. // e.g. "members" or "owners" of a group identified in `subject`. optional string relation = 1; - ObjectReference subject = 2 [(validate.rules).any.required = true]; + ObjectReference subject = 2 [(buf.validate.field).required = true]; } message RequestPagination { - uint32 limit = 1 [(validate.rules).uint32 = {gt: 0}]; + uint32 limit = 1 [(buf.validate.field).uint32 = {gt: 0}]; optional string continuation_token = 2; } @@ -41,11 +41,11 @@ message ResponsePagination { } message ObjectReference { - ObjectType type = 1 [(validate.rules).any.required = true]; - string id = 2 [(validate.rules).string.min_len = 1]; + ObjectType type = 1 [(buf.validate.field).required = true]; + string id = 2 [(buf.validate.field).string.min_len = 1]; } message ObjectType { - string namespace = 1 [(validate.rules).string.min_len = 1]; - string name = 2 [(validate.rules).string.min_len = 1]; + string namespace = 1 [(buf.validate.field).string.min_len = 1]; + string name = 2 [(buf.validate.field).string.min_len = 1]; } diff --git a/api/kessel/relations/v1beta1/lookup.pb.go b/api/kessel/relations/v1beta1/lookup.pb.go index 51894f3..4b88a27 100644 --- a/api/kessel/relations/v1beta1/lookup.pb.go +++ b/api/kessel/relations/v1beta1/lookup.pb.go @@ -7,7 +7,7 @@ package v1beta1 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" @@ -293,22 +293,22 @@ var file_kessel_relations_v1beta1_lookup_proto_rawDesc = []byte{ 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 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, - 0xc3, 0x02, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x0d, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x24, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, - 0x01, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4e, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 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, 0xbf, 0x02, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x51, + 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x42, 0x06, 0xba, 0x48, 0x03, + 0xc8, 0x01, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4c, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, + 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, @@ -326,70 +326,70 @@ var file_kessel_relations_v1beta1_lookup_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x86, 0x03, 0x0a, 0x15, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x82, 0x03, 0x0a, 0x15, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x4f, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x12, 0x4d, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, - 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x12, 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x51, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6b, - 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, - 0x70, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x0b, 0x73, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x10, 0x73, 0x75, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0a, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x13, 0x0a, 0x11, 0x5f, - 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, - 0xac, 0x01, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x07, 0x73, 0x75, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, - 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, - 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x12, 0x4c, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xbf, - 0x02, 0x0a, 0x13, 0x4b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x90, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, - 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x2f, 0x2e, 0x6b, 0x65, 0x73, 0x73, - 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6b, 0x65, 0x73, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x06, 0xba, + 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, + 0x23, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xba, 0x48, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, - 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x30, 0x01, 0x12, 0x94, 0x01, 0x0a, 0x0f, 0x4c, 0x6f, - 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x30, 0x2e, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x31, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, - 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x30, 0x01, - 0x42, 0x72, 0x0a, 0x28, 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x50, 0x01, 0x5a, 0x44, - 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, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, - 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6b, 0x65, 0x73, 0x73, + 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x01, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0d, 0x0a, 0x0b, + 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xac, 0x01, 0x0a, 0x16, + 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, + 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x4c, 0x0a, 0x0a, + 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, + 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xbf, 0x02, 0x0a, 0x13, 0x4b, + 0x65, 0x73, 0x73, 0x65, 0x6c, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x90, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x2f, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, + 0x12, 0x11, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x73, 0x30, 0x01, 0x12, 0x94, 0x01, 0x0a, 0x0f, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x30, 0x2e, 0x6b, 0x65, 0x73, 0x73, + 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x6b, 0x65, + 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x30, 0x01, 0x42, 0x72, 0x0a, 0x28, + 0x6f, 0x72, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x6b, 0x65, 0x73, 0x73, + 0x65, 0x6c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x50, 0x01, 0x5a, 0x44, 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, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2d, + 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/kessel/relations/v1beta1/lookup.pb.validate.go b/api/kessel/relations/v1beta1/lookup.pb.validate.go deleted file mode 100644 index e69abd9..0000000 --- a/api/kessel/relations/v1beta1/lookup.pb.validate.go +++ /dev/null @@ -1,712 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/relations/v1beta1/lookup.proto - -package v1beta1 - -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 LookupResourcesRequest 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 *LookupResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LookupResourcesRequest 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 -// LookupResourcesRequestMultiError, or nil if none found. -func (m *LookupResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LookupResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetResourceType() == nil { - err := LookupResourcesRequestValidationError{ - field: "ResourceType", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetResourceType(); a != nil { - - } - - if utf8.RuneCountInString(m.GetRelation()) < 1 { - err := LookupResourcesRequestValidationError{ - field: "Relation", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.GetSubject() == nil { - err := LookupResourcesRequestValidationError{ - field: "Subject", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetSubject(); a != nil { - - } - - if m.Pagination != nil { - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupResourcesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupResourcesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupResourcesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return LookupResourcesRequestMultiError(errors) - } - - return nil -} - -// LookupResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by LookupResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type LookupResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LookupResourcesRequestMultiError) 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 LookupResourcesRequestMultiError) AllErrors() []error { return m } - -// LookupResourcesRequestValidationError is the validation error returned by -// LookupResourcesRequest.Validate if the designated constraints aren't met. -type LookupResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LookupResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LookupResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LookupResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LookupResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LookupResourcesRequestValidationError) ErrorName() string { - return "LookupResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e LookupResourcesRequestValidationError) 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 %sLookupResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LookupResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LookupResourcesRequestValidationError{} - -// Validate checks the field values on LookupResourcesResponse 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 *LookupResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LookupResourcesResponse 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 -// LookupResourcesResponseMultiError, or nil if none found. -func (m *LookupResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LookupResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupResourcesResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupResourcesResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupResourcesResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupResourcesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupResourcesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupResourcesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LookupResourcesResponseMultiError(errors) - } - - return nil -} - -// LookupResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by LookupResourcesResponse.ValidateAll() if the designated -// constraints aren't met. -type LookupResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LookupResourcesResponseMultiError) 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 LookupResourcesResponseMultiError) AllErrors() []error { return m } - -// LookupResourcesResponseValidationError is the validation error returned by -// LookupResourcesResponse.Validate if the designated constraints aren't met. -type LookupResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LookupResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LookupResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LookupResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LookupResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LookupResourcesResponseValidationError) ErrorName() string { - return "LookupResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e LookupResourcesResponseValidationError) 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 %sLookupResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LookupResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LookupResourcesResponseValidationError{} - -// Validate checks the field values on LookupSubjectsRequest 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 *LookupSubjectsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LookupSubjectsRequest 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 -// LookupSubjectsRequestMultiError, or nil if none found. -func (m *LookupSubjectsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LookupSubjectsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetResource() == nil { - err := LookupSubjectsRequestValidationError{ - field: "Resource", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetResource(); a != nil { - - } - - if utf8.RuneCountInString(m.GetRelation()) < 1 { - err := LookupSubjectsRequestValidationError{ - field: "Relation", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if m.GetSubjectType() == nil { - err := LookupSubjectsRequestValidationError{ - field: "SubjectType", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetSubjectType(); a != nil { - - } - - if m.SubjectRelation != nil { - // no validation rules for SubjectRelation - } - - if m.Pagination != nil { - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupSubjectsRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupSubjectsRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupSubjectsRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return LookupSubjectsRequestMultiError(errors) - } - - return nil -} - -// LookupSubjectsRequestMultiError is an error wrapping multiple validation -// errors returned by LookupSubjectsRequest.ValidateAll() if the designated -// constraints aren't met. -type LookupSubjectsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LookupSubjectsRequestMultiError) 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 LookupSubjectsRequestMultiError) AllErrors() []error { return m } - -// LookupSubjectsRequestValidationError is the validation error returned by -// LookupSubjectsRequest.Validate if the designated constraints aren't met. -type LookupSubjectsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LookupSubjectsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LookupSubjectsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LookupSubjectsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LookupSubjectsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LookupSubjectsRequestValidationError) ErrorName() string { - return "LookupSubjectsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e LookupSubjectsRequestValidationError) 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 %sLookupSubjectsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LookupSubjectsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LookupSubjectsRequestValidationError{} - -// Validate checks the field values on LookupSubjectsResponse 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 *LookupSubjectsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LookupSubjectsResponse 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 -// LookupSubjectsResponseMultiError, or nil if none found. -func (m *LookupSubjectsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LookupSubjectsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetSubject()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupSubjectsResponseValidationError{ - field: "Subject", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupSubjectsResponseValidationError{ - field: "Subject", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupSubjectsResponseValidationError{ - field: "Subject", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LookupSubjectsResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LookupSubjectsResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LookupSubjectsResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LookupSubjectsResponseMultiError(errors) - } - - return nil -} - -// LookupSubjectsResponseMultiError is an error wrapping multiple validation -// errors returned by LookupSubjectsResponse.ValidateAll() if the designated -// constraints aren't met. -type LookupSubjectsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LookupSubjectsResponseMultiError) 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 LookupSubjectsResponseMultiError) AllErrors() []error { return m } - -// LookupSubjectsResponseValidationError is the validation error returned by -// LookupSubjectsResponse.Validate if the designated constraints aren't met. -type LookupSubjectsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LookupSubjectsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LookupSubjectsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LookupSubjectsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LookupSubjectsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LookupSubjectsResponseValidationError) ErrorName() string { - return "LookupSubjectsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e LookupSubjectsResponseValidationError) 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 %sLookupSubjectsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LookupSubjectsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LookupSubjectsResponseValidationError{} diff --git a/api/kessel/relations/v1beta1/lookup.proto b/api/kessel/relations/v1beta1/lookup.proto index ac1fa45..e0439c4 100644 --- a/api/kessel/relations/v1beta1/lookup.proto +++ b/api/kessel/relations/v1beta1/lookup.proto @@ -4,7 +4,7 @@ package kessel.relations.v1beta1; import "google/api/annotations.proto"; import "kessel/relations/v1beta1/common.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1"; @@ -25,9 +25,9 @@ service KesselLookupService { } message LookupResourcesRequest { - ObjectType resource_type = 1 [(validate.rules).any.required = true]; - string relation = 2 [(validate.rules).string.min_len = 1]; - SubjectReference subject = 3 [(validate.rules).any.required = true]; + ObjectType resource_type = 1 [(buf.validate.field).required = true]; + string relation = 2 [(buf.validate.field).string.min_len = 1]; + SubjectReference subject = 3 [(buf.validate.field).required = true]; optional RequestPagination pagination = 4; } @@ -37,9 +37,9 @@ message LookupResourcesResponse { } message LookupSubjectsRequest { - ObjectReference resource = 1 [(validate.rules).any.required = true]; - string relation = 2 [(validate.rules).string.min_len = 1]; - ObjectType subject_type = 3 [(validate.rules).any.required = true]; + ObjectReference resource = 1 [(buf.validate.field).required = true]; + string relation = 2 [(buf.validate.field).string.min_len = 1]; + ObjectType subject_type = 3 [(buf.validate.field).required = true]; optional string subject_relation = 4; optional RequestPagination pagination = 5; } diff --git a/api/kessel/relations/v1beta1/relation_tuples.pb.go b/api/kessel/relations/v1beta1/relation_tuples.pb.go index 3cbcd77..88ad91f 100644 --- a/api/kessel/relations/v1beta1/relation_tuples.pb.go +++ b/api/kessel/relations/v1beta1/relation_tuples.pb.go @@ -7,7 +7,7 @@ package v1beta1 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" @@ -479,45 +479,45 @@ var file_kessel_relations_v1beta1_relation_tuples_proto_rawDesc = []byte{ 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 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, 0x6d, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x75, 0x70, 0x73, 0x65, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x75, 0x70, 0x73, 0x65, 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x74, 0x75, 0x70, 0x6c, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, - 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x52, - 0x06, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x22, 0x16, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0xc5, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x61, 0x64, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4f, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, - 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x46, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x06, - 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6b, 0x65, 0x73, - 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xa0, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x61, 0x64, - 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, - 0x0a, 0x05, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, - 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x68, 0x69, 0x70, 0x52, 0x05, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x12, 0x4c, 0x0a, 0x0a, - 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x2c, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, - 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x66, 0x0a, 0x13, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x4f, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2d, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x42, 0x08, 0xfa, 0x42, 0x05, 0xa2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, + 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, 0x6d, 0x0a, 0x13, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x70, 0x73, 0x65, 0x72, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x70, 0x73, 0x65, 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x74, + 0x75, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6b, 0x65, + 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x68, 0x69, 0x70, 0x52, 0x06, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x22, 0x16, 0x0a, 0x14, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0xc3, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x61, 0x64, 0x54, 0x75, 0x70, 0x6c, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x06, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x6b, 0x65, 0x73, 0x73, + 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, + 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, + 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6b, + 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x0a, 0x70, 0x61, 0x67, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xa0, 0x01, 0x0a, 0x12, 0x52, 0x65, + 0x61, 0x64, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x3c, 0x0a, 0x05, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x26, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x52, 0x05, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x12, 0x4c, + 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x64, 0x0a, 0x13, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x6b, 0x65, 0x73, 0x73, 0x65, 0x6c, 0x2e, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x42, 0x06, 0xba, 0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xe8, 0x02, 0x0a, 0x13, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x46, 0x69, 0x6c, 0x74, diff --git a/api/kessel/relations/v1beta1/relation_tuples.pb.validate.go b/api/kessel/relations/v1beta1/relation_tuples.pb.validate.go deleted file mode 100644 index ae0f3aa..0000000 --- a/api/kessel/relations/v1beta1/relation_tuples.pb.validate.go +++ /dev/null @@ -1,1072 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: kessel/relations/v1beta1/relation_tuples.proto - -package v1beta1 - -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 CreateTuplesRequest 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 *CreateTuplesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTuplesRequest 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 -// CreateTuplesRequestMultiError, or nil if none found. -func (m *CreateTuplesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTuplesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Upsert - - for idx, item := range m.GetTuples() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateTuplesRequestValidationError{ - field: fmt.Sprintf("Tuples[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateTuplesRequestValidationError{ - field: fmt.Sprintf("Tuples[%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 CreateTuplesRequestValidationError{ - field: fmt.Sprintf("Tuples[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return CreateTuplesRequestMultiError(errors) - } - - return nil -} - -// CreateTuplesRequestMultiError is an error wrapping multiple validation -// errors returned by CreateTuplesRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateTuplesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTuplesRequestMultiError) 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 CreateTuplesRequestMultiError) AllErrors() []error { return m } - -// CreateTuplesRequestValidationError is the validation error returned by -// CreateTuplesRequest.Validate if the designated constraints aren't met. -type CreateTuplesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTuplesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTuplesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTuplesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTuplesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTuplesRequestValidationError) ErrorName() string { - return "CreateTuplesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTuplesRequestValidationError) 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 %sCreateTuplesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTuplesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTuplesRequestValidationError{} - -// Validate checks the field values on CreateTuplesResponse 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 *CreateTuplesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTuplesResponse 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 -// CreateTuplesResponseMultiError, or nil if none found. -func (m *CreateTuplesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTuplesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return CreateTuplesResponseMultiError(errors) - } - - return nil -} - -// CreateTuplesResponseMultiError is an error wrapping multiple validation -// errors returned by CreateTuplesResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateTuplesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTuplesResponseMultiError) 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 CreateTuplesResponseMultiError) AllErrors() []error { return m } - -// CreateTuplesResponseValidationError is the validation error returned by -// CreateTuplesResponse.Validate if the designated constraints aren't met. -type CreateTuplesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTuplesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTuplesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTuplesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTuplesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTuplesResponseValidationError) ErrorName() string { - return "CreateTuplesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTuplesResponseValidationError) 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 %sCreateTuplesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTuplesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTuplesResponseValidationError{} - -// Validate checks the field values on ReadTuplesRequest 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 *ReadTuplesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReadTuplesRequest 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 -// ReadTuplesRequestMultiError, or nil if none found. -func (m *ReadTuplesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ReadTuplesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetFilter() == nil { - err := ReadTuplesRequestValidationError{ - field: "Filter", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetFilter(); a != nil { - - } - - if m.Pagination != nil { - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadTuplesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadTuplesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadTuplesRequestValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ReadTuplesRequestMultiError(errors) - } - - return nil -} - -// ReadTuplesRequestMultiError is an error wrapping multiple validation errors -// returned by ReadTuplesRequest.ValidateAll() if the designated constraints -// aren't met. -type ReadTuplesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReadTuplesRequestMultiError) 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 ReadTuplesRequestMultiError) AllErrors() []error { return m } - -// ReadTuplesRequestValidationError is the validation error returned by -// ReadTuplesRequest.Validate if the designated constraints aren't met. -type ReadTuplesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReadTuplesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReadTuplesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReadTuplesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReadTuplesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReadTuplesRequestValidationError) ErrorName() string { - return "ReadTuplesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ReadTuplesRequestValidationError) 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 %sReadTuplesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReadTuplesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReadTuplesRequestValidationError{} - -// Validate checks the field values on ReadTuplesResponse 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 *ReadTuplesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReadTuplesResponse 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 -// ReadTuplesResponseMultiError, or nil if none found. -func (m *ReadTuplesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ReadTuplesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetTuple()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadTuplesResponseValidationError{ - field: "Tuple", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadTuplesResponseValidationError{ - field: "Tuple", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetTuple()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadTuplesResponseValidationError{ - field: "Tuple", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPagination()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadTuplesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadTuplesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPagination()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadTuplesResponseValidationError{ - field: "Pagination", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ReadTuplesResponseMultiError(errors) - } - - return nil -} - -// ReadTuplesResponseMultiError is an error wrapping multiple validation errors -// returned by ReadTuplesResponse.ValidateAll() if the designated constraints -// aren't met. -type ReadTuplesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReadTuplesResponseMultiError) 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 ReadTuplesResponseMultiError) AllErrors() []error { return m } - -// ReadTuplesResponseValidationError is the validation error returned by -// ReadTuplesResponse.Validate if the designated constraints aren't met. -type ReadTuplesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReadTuplesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReadTuplesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReadTuplesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReadTuplesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReadTuplesResponseValidationError) ErrorName() string { - return "ReadTuplesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ReadTuplesResponseValidationError) 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 %sReadTuplesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReadTuplesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReadTuplesResponseValidationError{} - -// Validate checks the field values on DeleteTuplesRequest 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 *DeleteTuplesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteTuplesRequest 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 -// DeleteTuplesRequestMultiError, or nil if none found. -func (m *DeleteTuplesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteTuplesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetFilter() == nil { - err := DeleteTuplesRequestValidationError{ - field: "Filter", - reason: "value is required", - } - if !all { - return err - } - errors = append(errors, err) - } - - if a := m.GetFilter(); a != nil { - - } - - if len(errors) > 0 { - return DeleteTuplesRequestMultiError(errors) - } - - return nil -} - -// DeleteTuplesRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteTuplesRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteTuplesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteTuplesRequestMultiError) 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 DeleteTuplesRequestMultiError) AllErrors() []error { return m } - -// DeleteTuplesRequestValidationError is the validation error returned by -// DeleteTuplesRequest.Validate if the designated constraints aren't met. -type DeleteTuplesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteTuplesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteTuplesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteTuplesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteTuplesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteTuplesRequestValidationError) ErrorName() string { - return "DeleteTuplesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteTuplesRequestValidationError) 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 %sDeleteTuplesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteTuplesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteTuplesRequestValidationError{} - -// Validate checks the field values on DeleteTuplesResponse 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 *DeleteTuplesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteTuplesResponse 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 -// DeleteTuplesResponseMultiError, or nil if none found. -func (m *DeleteTuplesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteTuplesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return DeleteTuplesResponseMultiError(errors) - } - - return nil -} - -// DeleteTuplesResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteTuplesResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteTuplesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteTuplesResponseMultiError) 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 DeleteTuplesResponseMultiError) AllErrors() []error { return m } - -// DeleteTuplesResponseValidationError is the validation error returned by -// DeleteTuplesResponse.Validate if the designated constraints aren't met. -type DeleteTuplesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteTuplesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteTuplesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteTuplesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteTuplesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteTuplesResponseValidationError) ErrorName() string { - return "DeleteTuplesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteTuplesResponseValidationError) 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 %sDeleteTuplesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteTuplesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteTuplesResponseValidationError{} - -// Validate checks the field values on RelationTupleFilter 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 *RelationTupleFilter) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RelationTupleFilter 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 -// RelationTupleFilterMultiError, or nil if none found. -func (m *RelationTupleFilter) ValidateAll() error { - return m.validate(true) -} - -func (m *RelationTupleFilter) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.ResourceNamespace != nil { - // no validation rules for ResourceNamespace - } - - if m.ResourceType != nil { - // no validation rules for ResourceType - } - - if m.ResourceId != nil { - // no validation rules for ResourceId - } - - if m.Relation != nil { - // no validation rules for Relation - } - - if m.SubjectFilter != nil { - - if all { - switch v := interface{}(m.GetSubjectFilter()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RelationTupleFilterValidationError{ - field: "SubjectFilter", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RelationTupleFilterValidationError{ - field: "SubjectFilter", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSubjectFilter()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RelationTupleFilterValidationError{ - field: "SubjectFilter", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RelationTupleFilterMultiError(errors) - } - - return nil -} - -// RelationTupleFilterMultiError is an error wrapping multiple validation -// errors returned by RelationTupleFilter.ValidateAll() if the designated -// constraints aren't met. -type RelationTupleFilterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RelationTupleFilterMultiError) 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 RelationTupleFilterMultiError) AllErrors() []error { return m } - -// RelationTupleFilterValidationError is the validation error returned by -// RelationTupleFilter.Validate if the designated constraints aren't met. -type RelationTupleFilterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RelationTupleFilterValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RelationTupleFilterValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RelationTupleFilterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RelationTupleFilterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RelationTupleFilterValidationError) ErrorName() string { - return "RelationTupleFilterValidationError" -} - -// Error satisfies the builtin error interface -func (e RelationTupleFilterValidationError) 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 %sRelationTupleFilter.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RelationTupleFilterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RelationTupleFilterValidationError{} - -// Validate checks the field values on SubjectFilter 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 *SubjectFilter) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on SubjectFilter 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 SubjectFilterMultiError, or -// nil if none found. -func (m *SubjectFilter) ValidateAll() error { - return m.validate(true) -} - -func (m *SubjectFilter) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.SubjectNamespace != nil { - // no validation rules for SubjectNamespace - } - - if m.SubjectType != nil { - // no validation rules for SubjectType - } - - if m.SubjectId != nil { - // no validation rules for SubjectId - } - - if m.Relation != nil { - // no validation rules for Relation - } - - if len(errors) > 0 { - return SubjectFilterMultiError(errors) - } - - return nil -} - -// SubjectFilterMultiError is an error wrapping multiple validation errors -// returned by SubjectFilter.ValidateAll() if the designated constraints -// aren't met. -type SubjectFilterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m SubjectFilterMultiError) 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 SubjectFilterMultiError) AllErrors() []error { return m } - -// SubjectFilterValidationError is the validation error returned by -// SubjectFilter.Validate if the designated constraints aren't met. -type SubjectFilterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e SubjectFilterValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e SubjectFilterValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e SubjectFilterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e SubjectFilterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e SubjectFilterValidationError) ErrorName() string { return "SubjectFilterValidationError" } - -// Error satisfies the builtin error interface -func (e SubjectFilterValidationError) 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 %sSubjectFilter.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = SubjectFilterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = SubjectFilterValidationError{} diff --git a/api/kessel/relations/v1beta1/relation_tuples.proto b/api/kessel/relations/v1beta1/relation_tuples.proto index 2a08393..d55703a 100644 --- a/api/kessel/relations/v1beta1/relation_tuples.proto +++ b/api/kessel/relations/v1beta1/relation_tuples.proto @@ -4,7 +4,7 @@ package kessel.relations.v1beta1; import "google/api/annotations.proto"; import "kessel/relations/v1beta1/common.proto"; -import "validate/validate.proto"; +import "buf/validate/validate.proto"; option go_package = "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1"; option java_multiple_files = true; @@ -47,7 +47,7 @@ message CreateTuplesRequest { message CreateTuplesResponse {} message ReadTuplesRequest { - RelationTupleFilter filter = 1 [(validate.rules).any.required = true]; + RelationTupleFilter filter = 1 [(buf.validate.field).required = true]; optional RequestPagination pagination = 2; } message ReadTuplesResponse { @@ -56,7 +56,7 @@ message ReadTuplesResponse { } message DeleteTuplesRequest { - RelationTupleFilter filter = 1 [(validate.rules).any.required = true]; + RelationTupleFilter filter = 1 [(buf.validate.field).required = true]; } message DeleteTuplesResponse {} diff --git a/go.mod b/go.mod index 815ac4a..22b76ad 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,11 @@ module github.com/project-kessel/relations-api go 1.21 require ( + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 github.com/MicahParks/keyfunc/v3 v3.3.3 github.com/authzed/authzed-go v0.13.0 github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403 - github.com/envoyproxy/protoc-gen-validate v1.1.0 + github.com/bufbuild/protovalidate-go v0.6.4 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 @@ -32,6 +33,7 @@ require ( github.com/MicahParks/jwkset v0.5.18 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect + github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect @@ -42,6 +44,7 @@ require ( github.com/docker/docker v27.1.1+incompatible // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -49,6 +52,7 @@ require ( github.com/go-playground/form/v4 v4.2.0 // indirect github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/cel-go v0.21.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/subcommands v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect @@ -73,6 +77,7 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/samber/lo v1.39.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect + github.com/stoewer/go-strcase v1.3.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect diff --git a/go.sum b/go.sum index d8da580..27ad046 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= @@ -17,6 +19,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= +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/authzed-go v0.13.0 h1:wX/YpL/CW5RZLqMUKor2z1knJhCh7DjEu1qW3HVsp/w= github.com/authzed/authzed-go v0.13.0/go.mod h1:i62WRU5roWUGzYPxuZzBi3/FBUNvGWYEjyI/m3xWMQc= github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403 h1:bQeIwWWRI9bl93poTqpix4sYHi+gnXUPK7N6bMtXzBE= @@ -24,6 +28,8 @@ github.com/authzed/grpcutil v0.0.0-20230908193239-4286bb1d6403/go.mod h1:s3qC7V7 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/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -91,6 +97,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/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -167,12 +175,19 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +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= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 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.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= diff --git a/internal/data/spicedb-test-data/basic_schema.yaml b/internal/data/spicedb-test-data/basic_schema.yaml index 0e3c3db..3feafb8 100644 --- a/internal/data/spicedb-test-data/basic_schema.yaml +++ b/internal/data/spicedb-test-data/basic_schema.yaml @@ -1,30 +1,30 @@ schema: |- - definition user {} + definition rbac/user {} - definition group { - relation member: user | group#member + definition rbac/group { + relation member: rbac/user | rbac/group#member } - definition role { - relation view_the_thing: user:* + definition rbac/role { + relation view_the_thing: rbac/user:* } - definition role_binding { - relation subject : user | group#member - relation granted: role + definition rbac/role_binding { + relation subject : rbac/user | rbac/group#member + relation granted: rbac/role permission view_the_thing = subject & granted->view_the_thing } - definition workspace { - relation parent: workspace - relation user_grant: role_binding + definition rbac/workspace { + relation parent: rbac/workspace + relation user_grant: rbac/role_binding permission view_the_thing = user_grant->view_the_thing } - definition thing { - relation workspace: workspace + definition rbac/thing { + relation workspace: rbac/workspace permission view = workspace->view_the_thing } \ No newline at end of file diff --git a/internal/data/spicedb_test.go b/internal/data/spicedb_test.go index 4ac8793..222030c 100644 --- a/internal/data/spicedb_test.go +++ b/internal/data/spicedb_test.go @@ -48,7 +48,7 @@ func TestCreateRelationship(t *testing.T) { spiceDbRepo, err := container.CreateSpiceDbRepository() assert.NoError(t, err) - preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.False(t, preExisting) rels := []*apiV1beta1.Relationship{ @@ -60,7 +60,7 @@ func TestCreateRelationship(t *testing.T) { err = spiceDbRepo.CreateRelationships(ctx, rels, touch) assert.NoError(t, err) - exists := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + exists := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.True(t, exists) } @@ -71,7 +71,7 @@ func TestSecondCreateRelationshipFailsWithTouchFalse(t *testing.T) { spiceDbRepo, err := container.CreateSpiceDbRepository() assert.NoError(t, err) - preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.False(t, preExisting) rels := []*apiV1beta1.Relationship{ @@ -87,7 +87,7 @@ func TestSecondCreateRelationshipFailsWithTouchFalse(t *testing.T) { assert.Error(t, err) assert.Equal(t, status.Convert(err).Code(), codes.AlreadyExists) - exists := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + exists := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.True(t, exists) } @@ -98,7 +98,7 @@ func TestSecondCreateRelationshipSucceedsWithTouchTrue(t *testing.T) { spiceDbRepo, err := container.CreateSpiceDbRepository() assert.NoError(t, err) - preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + preExisting := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.False(t, preExisting) rels := []*apiV1beta1.Relationship{ @@ -115,7 +115,7 @@ func TestSecondCreateRelationshipSucceedsWithTouchTrue(t *testing.T) { err = spiceDbRepo.CreateRelationships(ctx, rels, touch) assert.NoError(t, err) - exists := CheckForRelationship(spiceDbRepo.client, "bob", "user", "", "member", "group", "bob_club") + exists := CheckForRelationship(spiceDbRepo.client, "bob", "rbac/user", "", "member", "rbac/group", "bob_club") assert.True(t, exists) } @@ -151,10 +151,10 @@ func TestCreateRelationshipFailsWithBadSubjectType(t *testing.T) { spiceDbRepo, err := container.CreateSpiceDbRepository() assert.NoError(t, err) - badSubjectType := "not_a_user" + badSubjectType := simple_type("not_a_user") rels := []*apiV1beta1.Relationship{ - createRelationship("bob", simple_type(badSubjectType), "", "member", simple_type("group"), "bob_club"), + createRelationship("bob", badSubjectType, "", "member", simple_type("group"), "bob_club"), } touch := biz.TouchSemantics(false) @@ -162,7 +162,8 @@ func TestCreateRelationshipFailsWithBadSubjectType(t *testing.T) { err = spiceDbRepo.CreateRelationships(ctx, rels, touch) assert.Error(t, err) assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition) - assert.Contains(t, err.Error(), "object definition `"+badSubjectType+"` not found") + assert.Contains(t, err.Error(), + fmt.Sprintf("object definition `%s/%s` not found", badSubjectType.GetNamespace(), badSubjectType.GetName())) } func TestCreateRelationshipFailsWithBadObjectType(t *testing.T) { @@ -172,10 +173,10 @@ func TestCreateRelationshipFailsWithBadObjectType(t *testing.T) { spiceDbRepo, err := container.CreateSpiceDbRepository() assert.NoError(t, err) - badObjectType := "not_an_object" + badObjectType := simple_type("not_an_object") rels := []*apiV1beta1.Relationship{ - createRelationship("bob", simple_type("user"), "", "member", simple_type(badObjectType), "bob_club"), + createRelationship("bob", simple_type("user"), "", "member", badObjectType, "bob_club"), } touch := biz.TouchSemantics(false) @@ -183,7 +184,9 @@ func TestCreateRelationshipFailsWithBadObjectType(t *testing.T) { err = spiceDbRepo.CreateRelationships(ctx, rels, touch) assert.Error(t, err) assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition) - assert.Contains(t, err.Error(), "object definition `"+badObjectType+"` not found") + assert.Contains(t, err.Error(), + fmt.Sprintf("object definition `%s/%s` not found", badObjectType.GetNamespace(), badObjectType.GetName())) + } func TestWriteAndReadBackRelationships(t *testing.T) { @@ -207,11 +210,11 @@ func TestWriteAndReadBackRelationships(t *testing.T) { readRelChan, _, err := spiceDbRepo.ReadRelationships(ctx, &apiV1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &apiV1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, 0, "") @@ -244,11 +247,11 @@ func TestWriteReadBackDeleteAndReadBackRelationships(t *testing.T) { readRelChan, _, err := spiceDbRepo.ReadRelationships(ctx, &apiV1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &apiV1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, 0, "") @@ -261,11 +264,11 @@ func TestWriteReadBackDeleteAndReadBackRelationships(t *testing.T) { err = spiceDbRepo.DeleteRelationships(ctx, &apiV1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &apiV1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }) @@ -275,11 +278,11 @@ func TestWriteReadBackDeleteAndReadBackRelationships(t *testing.T) { readRelChan, _, err = spiceDbRepo.ReadRelationships(ctx, &apiV1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &apiV1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, 0, "") @@ -349,11 +352,11 @@ func TestSpiceDbRepository_CheckPermission(t *testing.T) { //Remove // role_binding:rb_test#subject@user:bob err = spiceDbRepo.DeleteRelationships(ctx, &apiV1beta1.RelationTupleFilter{ ResourceId: pointerize("rb_test"), - ResourceType: pointerize("role_binding"), + ResourceType: pointerize("rbac/role_binding"), Relation: pointerize("subject"), SubjectFilter: &apiV1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }) if !assert.NoError(t, err) { @@ -378,7 +381,7 @@ func TestSpiceDbRepository_CheckPermission(t *testing.T) { } func simple_type(typename string) *apiV1beta1.ObjectType { - return &apiV1beta1.ObjectType{Name: typename} + return &apiV1beta1.ObjectType{Name: typename, Namespace: "rbac"} } func pointerize(value string) *string { //Used to turn string literals into pointers diff --git a/internal/server/grpc.go b/internal/server/grpc.go index ea20291..5f7ff87 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -1,12 +1,12 @@ package server import ( + "github.com/bufbuild/protovalidate-go" "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/middleware/auth/jwt" "github.com/go-kratos/kratos/v2/middleware/logging" "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/selector" - "github.com/go-kratos/kratos/v2/middleware/validate" "github.com/go-kratos/kratos/v2/transport/grpc" jwtv5 "github.com/golang-jwt/jwt/v5" h "github.com/project-kessel/relations-api/api/kessel/relations/v1" @@ -34,10 +34,14 @@ func NewGRPCServer(c *conf.Server, relations *service.RelationshipsService, heal if err != nil { return nil, err } + validator, err := protovalidate.New() + if err != nil { + return nil, err + } var opts = []grpc.ServerOption{ grpc.Middleware( recovery.Recovery(), - validate.Validator(), + middleware.ValidationMiddleware(validator), logging.Server(logger), metrics.Server( metrics.WithSeconds(seconds), @@ -46,7 +50,7 @@ func NewGRPCServer(c *conf.Server, relations *service.RelationshipsService, heal ), grpc.Options(googlegrpc.ChainStreamInterceptor( middleware.StreamLogInterceptor(logger), - middleware.StreamValidationInterceptor(), + middleware.StreamValidationInterceptor(validator), kesselRecovery.StreamRecoveryInterceptor(logger), kesselMetrics.StreamMetricsInterceptor( kesselMetrics.WithSeconds(seconds), diff --git a/internal/server/http.go b/internal/server/http.go index 81ae6ab..48a2808 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -4,18 +4,19 @@ import ( "context" "github.com/MicahParks/keyfunc/v3" + "github.com/bufbuild/protovalidate-go" "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/middleware/auth/jwt" "github.com/go-kratos/kratos/v2/middleware/logging" "github.com/go-kratos/kratos/v2/middleware/metrics" "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/selector" - "github.com/go-kratos/kratos/v2/middleware/validate" "github.com/go-kratos/kratos/v2/transport/http" jwt2 "github.com/golang-jwt/jwt/v5" h "github.com/project-kessel/relations-api/api/kessel/relations/v1" v1beta1 "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" "github.com/project-kessel/relations-api/internal/conf" + "github.com/project-kessel/relations-api/internal/server/middleware" "github.com/project-kessel/relations-api/internal/service" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -32,10 +33,14 @@ func NewHTTPServer(c *conf.Server, relationships *service.RelationshipsService, if err != nil { return nil, err } + validator, err := protovalidate.New() + if err != nil { + return nil, err + } var opts = []http.ServerOption{ http.Middleware( recovery.Recovery(), - validate.Validator(), + middleware.ValidationMiddleware(validator), logging.Server(logger), metrics.Server( metrics.WithSeconds(seconds), diff --git a/internal/server/middleware/validation.go b/internal/server/middleware/validation.go index e7027fd..2304344 100644 --- a/internal/server/middleware/validation.go +++ b/internal/server/middleware/validation.go @@ -1,23 +1,25 @@ 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/grpc" + "google.golang.org/protobuf/proto" ) -type validator interface { //Duplicated from github.com/go-kratos/kratos/v2/middleware/validate because not exported - Validate() error -} - -func StreamValidationInterceptor() grpc.StreamServerInterceptor { +func StreamValidationInterceptor(validator *protovalidate.Validator) grpc.StreamServerInterceptor { return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { - wrapper := &requestValidatingWrapper{ServerStream: ss} + wrapper := &requestValidatingWrapper{ServerStream: ss, Validator: validator} return handler(srv, wrapper) } } type requestValidatingWrapper struct { grpc.ServerStream + *protovalidate.Validator } func (w *requestValidatingWrapper) RecvMsg(m interface{}) error { @@ -26,8 +28,8 @@ func (w *requestValidatingWrapper) RecvMsg(m interface{}) error { return err } - if v, ok := m.(validator); ok { - if err = v.Validate(); err != nil { + if v, ok := m.(proto.Message); ok { + if err = w.Validator.Validate(v); err != nil { return errors.BadRequest("VALIDATOR", err.Error()).WithCause(err) } } @@ -38,3 +40,16 @@ func (w *requestValidatingWrapper) RecvMsg(m interface{}) error { func (w *requestValidatingWrapper) SendMsg(m interface{}) error { return w.ServerStream.SendMsg(m) } + +func ValidationMiddleware(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/server/middleware/validation_test.go b/internal/server/middleware/validation_test.go new file mode 100644 index 0000000..1ff7e48 --- /dev/null +++ b/internal/server/middleware/validation_test.go @@ -0,0 +1,122 @@ +package middleware + +import ( + "context" + "testing" + + "github.com/bufbuild/protovalidate-go" + "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc" +) + +func TestValidationMiddleware_ValidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + m := ValidationMiddleware(validator) + + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return "success", nil + } + + resp, err := m(handler)(context.Background(), &v1beta1.LookupSubjectsRequest{ + Resource: &v1beta1.ObjectReference{ + Type: &v1beta1.ObjectType{Namespace: "rbac", Name: "user"}, + Id: "bob", + }, + Relation: "member", + SubjectType: &v1beta1.ObjectType{Namespace: "rbac", Name: "group"}, + }) + assert.NoError(t, err) + assert.Equal(t, "success", resp) +} + +func TestValidationMiddleware_InvalidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + m := ValidationMiddleware(validator) + + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return nil, nil + } + + resp, err := m(handler)(context.Background(), &v1beta1.LookupSubjectsRequest{ + Resource: &v1beta1.ObjectReference{}, + }) + assert.Error(t, err) + assert.Equal(t, resp, nil) +} + +type DummyServerStream struct { + grpc.ServerStream + RecvMsgFunc func(msg interface{}) error +} + +func (m *DummyServerStream) RecvMsg(msg interface{}) error { + return m.RecvMsgFunc(msg) +} + +func TestStreamValidationInterceptor_ValidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + interceptor := StreamValidationInterceptor(validator) + + dummyStream := &DummyServerStream{ + RecvMsgFunc: func(msg interface{}) error { + *msg.(*v1beta1.LookupSubjectsRequest) = v1beta1.LookupSubjectsRequest{ + Resource: &v1beta1.ObjectReference{ + Type: &v1beta1.ObjectType{Namespace: "rbac", Name: "user"}, + Id: "bob", + }, + Relation: "member", + SubjectType: &v1beta1.ObjectType{Namespace: "rbac", Name: "group"}, + } + return nil + }, + } + + handler := func(srv interface{}, stream grpc.ServerStream) error { + msg := &v1beta1.LookupSubjectsRequest{} + err := stream.RecvMsg(msg) + return err + } + + err = interceptor(nil, dummyStream, nil, handler) + assert.NoError(t, err) +} + +func TestStreamValidationInterceptor_InvalidRequest(t *testing.T) { + t.Parallel() + + validator, err := protovalidate.New() + assert.NoError(t, err) + + interceptor := StreamValidationInterceptor(validator) + + dummyStream := &DummyServerStream{ + RecvMsgFunc: func(msg interface{}) error { + *msg.(*v1beta1.LookupSubjectsRequest) = v1beta1.LookupSubjectsRequest{ + Resource: &v1beta1.ObjectReference{}, + } + return nil + }, + } + + handler := func(srv interface{}, stream grpc.ServerStream) error { + msg := &v1beta1.LookupSubjectsRequest{} + err := stream.RecvMsg(msg) + return err + } + + err = interceptor(nil, dummyStream, nil, handler) + assert.Error(t, err) +} diff --git a/internal/service/check.go b/internal/service/check.go index 393a2dc..361530e 100644 --- a/internal/service/check.go +++ b/internal/service/check.go @@ -6,7 +6,6 @@ import ( "github.com/project-kessel/relations-api/internal/biz" - "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/log" pb "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" @@ -26,21 +25,6 @@ func NewCheckService(logger log.Logger, checkUseCase *biz.CheckUsecase) *CheckSe } func (s *CheckService) Check(ctx context.Context, req *pb.CheckRequest) (*pb.CheckResponse, error) { - if err := req.ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req) - return nil, errors.BadRequest("Invalid request", err.Error()) - } - - if err := req.Subject.ValidateAll(); err != nil { - s.log.Infof("Subject failed to pass validation: %v", req) - return nil, errors.BadRequest("Invalid request", err.Error()) - } - - if err := req.Resource.ValidateAll(); err != nil { - s.log.Infof("Resource failed to pass validation: %v", req) - return nil, errors.BadRequest("Invalid request", err.Error()) - } - resp, err := s.check.Check(ctx, req) if err != nil { return resp, fmt.Errorf("failed to perform check: %w", err) diff --git a/internal/service/lookup.go b/internal/service/lookup.go index 438c6df..ce3a935 100644 --- a/internal/service/lookup.go +++ b/internal/service/lookup.go @@ -3,7 +3,6 @@ package service import ( "fmt" - "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/log" pb "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" "github.com/project-kessel/relations-api/internal/biz" @@ -26,18 +25,7 @@ func NewLookupService(logger log.Logger, subjectsUseCase *biz.GetSubjectsUsecase } func (s *LookupService) LookupSubjects(req *pb.LookupSubjectsRequest, conn pb.KesselLookupService_LookupSubjectsServer) error { - if err := req.ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - - if err := req.Resource.ValidateAll(); err != nil { - s.log.Infof("Resource failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - ctx := conn.Context() - s.log.Debugf("Lookup subjects request: %v", req) //TODO: remove when logging middleware supports streaming subs, errs, err := s.subjectsUsecase.Get(ctx, req) @@ -64,21 +52,6 @@ func (s *LookupService) LookupSubjects(req *pb.LookupSubjectsRequest, conn pb.Ke } func (s *LookupService) LookupResources(req *pb.LookupResourcesRequest, conn pb.KesselLookupService_LookupResourcesServer) error { - if err := req.ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - - if err := req.Subject.ValidateAll(); err != nil { - s.log.Infof("Subject failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - - if err := req.Subject.Subject.ValidateAll(); err != nil { - s.log.Infof("Subject failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - ctx := conn.Context() res, errs, err := s.resourcesUsecase.Get(ctx, req) diff --git a/internal/service/lookup_test.go b/internal/service/lookup_test.go index 8ce0226..6d40932 100644 --- a/internal/service/lookup_test.go +++ b/internal/service/lookup_test.go @@ -15,30 +15,6 @@ import ( "google.golang.org/grpc" ) -func TestLookupService_LookupSubjects_EmptyRequest(t *testing.T) { - t.Parallel() - ctx := context.TODO() - spicedb, err := container.CreateSpiceDbRepository() - assert.NoError(t, err) - service := createLookupService(spicedb) - responseCollector := NewLookup_SubjectsServerStub(ctx) - err = service.LookupSubjects(&v1beta1.LookupSubjectsRequest{}, responseCollector) - - assert.Error(t, err) -} - -func TestLookupService_LookupResources_EmptyRequest(t *testing.T) { - t.Parallel() - ctx := context.TODO() - spicedb, err := container.CreateSpiceDbRepository() - assert.NoError(t, err) - service := createLookupService(spicedb) - responseCollector := NewLookup_ResourcesServerStub(ctx) - err = service.LookupResources(&v1beta1.LookupResourcesRequest{}, responseCollector) - - assert.Error(t, err) -} - func TestLookupService_LookupSubjects_NoResults(t *testing.T) { t.Parallel() ctx := context.TODO() @@ -63,26 +39,6 @@ func TestLookupService_LookupSubjects_NoResults(t *testing.T) { assert.Empty(t, results) } -func TestLookupService_LookupResources_Empty(t *testing.T) { - t.Parallel() - ctx := context.TODO() - spicedb, err := container.CreateSpiceDbRepository() - assert.NoError(t, err) - - service := createLookupService(spicedb) - - responseCollector := NewLookup_ResourcesServerStub(ctx) - err = service.LookupResources(&v1beta1.LookupResourcesRequest{ - Subject: &v1beta1.SubjectReference{Subject: &v1beta1.ObjectReference{}}, - Relation: "view", - ResourceType: &v1beta1.ObjectType{}, - }, responseCollector) - assert.ErrorContains(t, err, "Invalid request message") - results := responseCollector.GetResponses() - - assert.Empty(t, results) -} - func TestLookupService_LookupResources_NoResults(t *testing.T) { t.Parallel() ctx := context.TODO() @@ -98,9 +54,10 @@ func TestLookupService_LookupResources_NoResults(t *testing.T) { responseCollector := NewLookup_ResourcesServerStub(ctx) err = service.LookupResources(&v1beta1.LookupResourcesRequest{ Subject: &v1beta1.SubjectReference{Subject: &v1beta1.ObjectReference{Type: simple_type("workspace"), Id: "default"}}, - Relation: "view", + Relation: "view_the_thing", ResourceType: &v1beta1.ObjectType{ - Name: "thing", + Name: "workspace", + Namespace: "rbac", }, }, responseCollector) assert.NoError(t, err) @@ -152,7 +109,8 @@ func TestLookupService_LookupResources_OneResult(t *testing.T) { Subject: &v1beta1.SubjectReference{Subject: &v1beta1.ObjectReference{Type: simple_type("workspace"), Id: "default"}}, Relation: "workspace", ResourceType: &v1beta1.ObjectType{ - Name: "thing", + Name: "thing", + Namespace: "rbac", }, }, responseCollector) assert.NoError(t, err) @@ -181,7 +139,8 @@ func TestLookupService_LookupResources_TwoResults(t *testing.T) { //Subject: &v1beta1.SubjectReference{Subject: &v1beta1.ObjectReference{Type: simple_type("workspace"), Id: "default"}}, Relation: "subject", ResourceType: &v1beta1.ObjectType{ - Name: "role_binding", + Name: "role_binding", + Namespace: "rbac", }, }, responseCollector) assert.NoError(t, err) diff --git a/internal/service/relationships.go b/internal/service/relationships.go index 0cf7f3f..2b118a1 100644 --- a/internal/service/relationships.go +++ b/internal/service/relationships.go @@ -6,7 +6,6 @@ import ( "github.com/project-kessel/relations-api/internal/biz" - "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/log" pb "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" @@ -30,15 +29,6 @@ func NewRelationshipsService(logger log.Logger, createUseCase *biz.CreateRelatio } func (s *RelationshipsService) CreateTuples(ctx context.Context, req *pb.CreateTuplesRequest) (*pb.CreateTuplesResponse, error) { - s.log.Debugf("Create tuples request: %v", req) - - for idx := range req.Tuples { - if err := req.Tuples[idx].ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req.Tuples[idx]) - return nil, errors.BadRequest("Invalid request", err.Error()) - } - } - err := s.createUsecase.CreateRelationships(ctx, req.Tuples, req.GetUpsert()) //The generated .GetUpsert() defaults to false if err != nil { return nil, fmt.Errorf("error creating tuples: %w", err) @@ -48,13 +38,7 @@ func (s *RelationshipsService) CreateTuples(ctx context.Context, req *pb.CreateT } func (s *RelationshipsService) ReadTuples(req *pb.ReadTuplesRequest, conn pb.KesselTupleService_ReadTuplesServer) error { - if err := req.ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req) - return errors.BadRequest("Invalid request", err.Error()) - } - ctx := conn.Context() - s.log.Debugf("Read tuples request: %v", req) //TODO: remove when logging middleware supports streaming relationships, errs, err := s.readUsecase.ReadRelationships(ctx, req) @@ -81,13 +65,6 @@ func (s *RelationshipsService) ReadTuples(req *pb.ReadTuplesRequest, conn pb.Kes } func (s *RelationshipsService) DeleteTuples(ctx context.Context, req *pb.DeleteTuplesRequest) (*pb.DeleteTuplesResponse, error) { - s.log.Debugf("Delete tuples request: %v", req) - - if err := req.ValidateAll(); err != nil { - s.log.Infof("Request failed to pass validation: %v", req) - return nil, errors.BadRequest("Invalid request", err.Error()) - } - err := s.deleteUsecase.DeleteRelationships(ctx, req.Filter) if err != nil { return nil, fmt.Errorf("error deleting tuples: %w", err) diff --git a/internal/service/relationships_test.go b/internal/service/relationships_test.go index 53fc5b4..5768ab8 100644 --- a/internal/service/relationships_test.go +++ b/internal/service/relationships_test.go @@ -59,11 +59,11 @@ func TestRelationshipsService_CreateRelationships(t *testing.T) { readReq := &v1beta1.ReadTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, } @@ -103,11 +103,11 @@ func TestRelationshipsService_CreateRelationshipsWithTouchFalse(t *testing.T) { readReq := &v1beta1.ReadTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, } @@ -152,8 +152,8 @@ func TestRelationshipsService_CreateRelationshipsWithBadSubjectType(t *testing.T err, relationshipsService := setup(t) assert.NoError(t, err) ctx := context.Background() - badSubjectType := "not_a_user" - expected := createRelationship("bob", simple_type(badSubjectType), "", "member", simple_type("group"), "bob_club") + badSubjectType := simple_type("not_a_user") + expected := createRelationship("bob", badSubjectType, "", "member", simple_type("group"), "bob_club") req := &v1beta1.CreateTuplesRequest{ Tuples: []*v1beta1.Relationship{ expected, @@ -162,7 +162,8 @@ func TestRelationshipsService_CreateRelationshipsWithBadSubjectType(t *testing.T _, err = relationshipsService.CreateTuples(ctx, req) assert.Error(t, err) assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition) - assert.Contains(t, err.Error(), "object definition `"+badSubjectType+"` not found") + assert.Contains(t, err.Error(), + fmt.Sprintf("object definition `%s/%s` not found", badSubjectType.GetNamespace(), badSubjectType.GetName())) } func TestRelationshipsService_CreateRelationshipsWithBadObjectType(t *testing.T) { @@ -170,8 +171,8 @@ func TestRelationshipsService_CreateRelationshipsWithBadObjectType(t *testing.T) err, relationshipsService := setup(t) assert.NoError(t, err) ctx := context.Background() - badObjectType := "not_an_object" - expected := createRelationship("bob", simple_type("user"), "", "member", simple_type(badObjectType), "bob_club") + badObjectType := simple_type("not_an_object") + expected := createRelationship("bob", simple_type("user"), "", "member", badObjectType, "bob_club") req := &v1beta1.CreateTuplesRequest{ Tuples: []*v1beta1.Relationship{ expected, @@ -179,8 +180,9 @@ func TestRelationshipsService_CreateRelationshipsWithBadObjectType(t *testing.T) } _, err = relationshipsService.CreateTuples(ctx, req) assert.Error(t, err) - assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition) - assert.Contains(t, err.Error(), "object definition `"+badObjectType+"` not found") + assert.Equal(t, codes.FailedPrecondition, status.Convert(err).Code()) + assert.Contains(t, err.Error(), + fmt.Sprintf("object definition `%s/%s` not found", badObjectType.GetNamespace(), badObjectType.GetName())) } func TestRelationshipsService_DeleteRelationships(t *testing.T) { @@ -201,11 +203,11 @@ func TestRelationshipsService_DeleteRelationships(t *testing.T) { delreq := &v1beta1.DeleteTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }} _, err = relationshipsService.DeleteTuples(ctx, delreq) @@ -213,11 +215,11 @@ func TestRelationshipsService_DeleteRelationships(t *testing.T) { readReq := &v1beta1.ReadTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, } @@ -282,11 +284,11 @@ func TestRelationshipsService_ReadRelationships(t *testing.T) { req := &v1beta1.ReadTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ ResourceId: pointerize("bob_club"), - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, } @@ -334,11 +336,11 @@ func TestRelationshipsService_ReadRelationships_Paginated(t *testing.T) { container.WaitForQuantizationInterval() req := &v1beta1.ReadTuplesRequest{Filter: &v1beta1.RelationTupleFilter{ - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ SubjectId: pointerize("bob"), - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), }, }, Pagination: &v1beta1.RequestPagination{ @@ -369,7 +371,7 @@ func TestRelationshipsService_ReadRelationships_Paginated(t *testing.T) { } func simple_type(typename string) *v1beta1.ObjectType { - return &v1beta1.ObjectType{Name: typename} + return &v1beta1.ObjectType{Name: typename, Namespace: "rbac"} } func pointerize(value string) *string { //Used to turn string literals into pointers diff --git a/test/kessel_test.go b/test/kessel_test.go index 04f6262..95b209b 100644 --- a/test/kessel_test.go +++ b/test/kessel_test.go @@ -3,12 +3,13 @@ package test import ( "context" "fmt" - "github.com/authzed/grpcutil" "os" "sync" "testing" "time" + "github.com/authzed/grpcutil" + "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/middleware/tracing" v1beta1 "github.com/project-kessel/relations-api/api/kessel/relations/v1beta1" @@ -108,11 +109,11 @@ func TestKesselAPIGRPC_ReadTuples(t *testing.T) { client := v1beta1.NewKesselTupleServiceClient(conn) _, err = client.ReadTuples(context.Background(), &v1beta1.ReadTuplesRequest{ Filter: &v1beta1.RelationTupleFilter{ - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), ResourceId: pointerize("bob_club"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), SubjectId: pointerize("bob"), }, }, @@ -140,11 +141,11 @@ func TestKesselAPIGRPC_DeleteTuples(t *testing.T) { _, err = client.DeleteTuples(context.Background(), &v1beta1.DeleteTuplesRequest{ Filter: &v1beta1.RelationTupleFilter{ - ResourceType: pointerize("group"), + ResourceType: pointerize("rbac/group"), ResourceId: pointerize("bob_club"), Relation: pointerize("member"), SubjectFilter: &v1beta1.SubjectFilter{ - SubjectType: pointerize("user"), + SubjectType: pointerize("rbac/user"), SubjectId: pointerize("bob"), }, }, @@ -174,7 +175,8 @@ func TestKesselAPIGRPC_Check(t *testing.T) { Subject: &v1beta1.SubjectReference{ Subject: &v1beta1.ObjectReference{ Type: &v1beta1.ObjectType{ - Name: "user", + Namespace: "rbac", + Name: "user", }, Id: "bob", }, @@ -182,7 +184,8 @@ func TestKesselAPIGRPC_Check(t *testing.T) { Relation: "member", Resource: &v1beta1.ObjectReference{ Type: &v1beta1.ObjectType{ - Name: "group", + Namespace: "rbac", + Name: "group", }, Id: "bob_club", }, @@ -237,12 +240,13 @@ func TestKesselAPIGRPC_LookupResources(t *testing.T) { _, err = client.LookupResources( context.Background(), &v1beta1.LookupResourcesRequest{ - ResourceType: &v1beta1.ObjectType{Name: "group"}, + ResourceType: &v1beta1.ObjectType{Name: "group", Namespace: "rbac"}, Relation: "member", Subject: &v1beta1.SubjectReference{ Subject: &v1beta1.ObjectReference{ Type: &v1beta1.ObjectType{ - Name: "user", + Name: "user", + Namespace: "rbac", }, Id: "bob", }, @@ -256,7 +260,7 @@ func pointerize(value string) *string { //Used to turn string literals into poin } func simple_type(typename string) *v1beta1.ObjectType { - return &v1beta1.ObjectType{Name: typename} + return &v1beta1.ObjectType{Name: typename, Namespace: "rbac"} } func createRelations(subName string, subId string, relation string, resouceName string, ResouceId string) []*v1beta1.Relationship { @@ -265,7 +269,8 @@ func createRelations(subName string, subId string, relation string, resouceName Subject: &v1beta1.SubjectReference{ Subject: &v1beta1.ObjectReference{ Type: &v1beta1.ObjectType{ - Name: subName, + Name: subName, + Namespace: "rbac", }, Id: subId, }, @@ -273,7 +278,8 @@ func createRelations(subName string, subId string, relation string, resouceName Relation: relation, Resource: &v1beta1.ObjectReference{ Type: &v1beta1.ObjectType{ - Name: resouceName, + Name: resouceName, + Namespace: "rbac", }, Id: ResouceId, },