Skip to content

Commit

Permalink
made changes with buf library
Browse files Browse the repository at this point in the history
  • Loading branch information
rambleraptor committed Jul 17, 2024
1 parent 0a40060 commit 2a9c3fc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
bitbucket.org/creachadair/stringset v0.0.12
buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2
cloud.google.com/go/longrunning v0.5.6
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/gertd/go-pluralize v0.2.1
Expand All @@ -13,20 +14,21 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/pflag v1.0.5
github.com/stoewer/go-strcase v1.3.0
golang.org/x/text v0.14.0
google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7
google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v2 v2.4.0
)

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2 // indirect
github.com/bufbuild/protocompile v0.8.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.62.1 // indirect
)
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
bitbucket.org/creachadair/stringset v0.0.12 h1:APD8dIoAzGv70a6p1oasPDjPwkp+ajszdgKyWUcNqo0=
bitbucket.org/creachadair/stringset v0.0.12/go.mod h1:KtNk2s0hRO1T0r78lv9Zq/S/Lp0du2zI0Fj5j5Y4LDo=
buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2 h1:0Ka0tKxAfSnJm9sVa7RVtnkTZ8DeTjuNhfHdk0ruLZ8=
buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2/go.mod h1:7GnupzUM4BaoyPcUUTZZwrcVZvCBNcyn6iR/kddRTuU=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2 h1:Vs037OPnb+uCAQrDAxeGOM8UWvIBhET3hx+ZePssyrQ=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw=
cloud.google.com/go/longrunning v0.5.6 h1:xAe8+0YaWoCKr9t1+aWe+OeQgN/iJK1fEgZSXmjuEaE=
cloud.google.com/go/longrunning v0.5.6/go.mod h1:vUaDrWYOMKRuhiv6JBnn49YxCPz2Ayn9GqyjaBT8/mA=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
Expand Down Expand Up @@ -52,8 +56,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
6 changes: 2 additions & 4 deletions rules/aep0155/request_id_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package aep0155

import (
"github.com/aep-dev/api-linter/lint"
"github.com/aep-dev/api-linter/rules/internal/utils"
"github.com/jhump/protoreflect/desc"
"google.golang.org/protobuf/types/descriptorpb"
)
Expand All @@ -25,11 +24,10 @@ var requestIdFormat = &lint.FieldRule{
Name: lint.NewRuleName(155, "request-id-format"),
RuleType: lint.NewRuleType(lint.MustRule),
OnlyIf: func(fd *desc.FieldDescriptor) bool {
return fd.GetName() == "request_id" &&
fd.GetType() != descriptorpb.FieldDescriptorProto_TYPE_MESSAGE;
return fd.GetName() == "request_id"
},
LintField: func(fd *desc.FieldDescriptor) []lint.Problem {
if(fd.GetMessageType().GetFullyQualifiedName() != "aep.api.IdempotencyKey") {
if(fd.GetType() != descriptorpb.FieldDescriptorProto_TYPE_MESSAGE || fd.GetMessageType().GetFullyQualifiedName() != "aep.api.IdempotencyKey") {
return []lint.Problem{{
Message: "The `request_id` field should have type `aep.api.IdempotencyKey`",
Descriptor: fd,
Expand Down
2 changes: 1 addition & 1 deletion rules/aep0155/request_id_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestRequestIdFormat(t *testing.T) {
name: "InvalidType",
FieldName: "request_id",
Type: "string",
problems: testutils.Problems{{Message: "format = UUID4"}},
problems: testutils.Problems{{Message: "type `aep.api.IdempotencyKey`"}},
},
} {
t.Run(test.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rules/internal/testutils/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import (
// These imports cause the common protos to be registered with
// the protocol buffer registry, and therefore make the call to
// `proto.FileDescriptor` work for the imported files.
_ "buf.build/gen/go/aep/api/protocolbuffers/go/aep/api"
_ "cloud.google.com/go/longrunning/autogen/longrunningpb"
_ "google.golang.org/genproto/googleapis/api/annotations"
_ "google.golang.org/genproto/googleapis/type/date"
_ "google.golang.org/genproto/googleapis/type/datetime"
_ "google.golang.org/genproto/googleapis/type/timeofday"
// TODO: Add aep to genproto to make linter tests pass.
)

// ParseProtoStrings parses a map representing a proto files, and returns
Expand Down

0 comments on commit 2a9c3fc

Please sign in to comment.