Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/go-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:

- name: Go Lint on ./v2
if: steps.golangci_configuration.outputs.files_exists == 'true'
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
with:
version: v1.61
version: v2.0
working-directory: v2

1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "2"
run:
timeout: 5m

Expand Down
7 changes: 4 additions & 3 deletions v2/binding/buffering/copy_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ func CopyMessage(ctx context.Context, m binding.Message, transformers ...binding
bm := binaryBufferedMessage{}

encoding, err := binding.DirectWrite(ctx, m, &sm, &bm, transformers...)
if encoding == binding.EncodingStructured {
switch encoding {
case binding.EncodingStructured:
return &sm, err
} else if encoding == binding.EncodingBinary {
case binding.EncodingBinary:
return &bm, err
} else {
default:
e, err := binding.ToEvent(ctx, m, transformers...)
if err != nil {
return nil, err
Expand Down
8 changes: 5 additions & 3 deletions v2/binding/test/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ func RunTransformerTests(t *testing.T, ctx context.Context, tests []TransformerT
require.NoError(t, err)

var e *event.Event
if enc == binding.EncodingStructured {
switch enc {
case binding.EncodingStructured:
e, err = binding.ToEvent(ctx, &mockStructured)
require.NoError(t, err)
} else if enc == binding.EncodingBinary {
case binding.EncodingBinary:
e, err = binding.ToEvent(ctx, &mockBinary)
require.NoError(t, err)
} else {
default:
t.Fatalf("Unexpected encoding %v", enc)
}

require.NoError(t, err)
if tt.AssertFunc != nil {
tt.AssertFunc(t, *e)
Expand Down
2 changes: 1 addition & 1 deletion v2/event/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func validateExtensionName(key string) error {
}

for _, c := range key {
if !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
if (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9') {
return errors.New("bad key, CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z'), upper-case letters ('A' to 'Z') or digits ('0' to '9') from the ASCII character set")
}
}
Expand Down
5 changes: 3 additions & 2 deletions v2/protocol/http/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ func TestNewMessageFromHttpRequest(t *testing.T) {
test.EachEvent(t, test.Events(), func(t *testing.T, eventIn event.Event) {
t.Run(tt.name, func(t *testing.T) {
ctx := context.TODO()
if tt.encoding == binding.EncodingStructured {
switch tt.encoding {
case binding.EncodingStructured:
ctx = binding.WithForceStructured(ctx)
} else if tt.encoding == binding.EncodingBinary {
case binding.EncodingBinary:
ctx = binding.WithForceBinary(ctx)
}

Expand Down
2 changes: 1 addition & 1 deletion v2/protocol/http/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (p *Protocol) ServeHTTP(rw http.ResponseWriter, req *http.Request) {

if !ok {
rw.Header().Add("Retry-After", strconv.Itoa(int(reset)))
http.Error(rw, "limit exceeded", 429)
http.Error(rw, "limit exceeded", http.StatusTooManyRequests)
return
}

Expand Down
5 changes: 3 additions & 2 deletions v2/protocol/http/utility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ func TestNewEventFromHttpRequest(t *testing.T) {
test.EachEvent(t, test.Events(), func(t *testing.T, eventIn event.Event) {
t.Run(tt.name, func(t *testing.T) {
ctx := context.TODO()
if tt.encoding == binding.EncodingStructured {
switch tt.encoding {
case binding.EncodingStructured:
ctx = binding.WithForceStructured(ctx)
} else if tt.encoding == binding.EncodingBinary {
case binding.EncodingBinary:
ctx = binding.WithForceBinary(ctx)
}

Expand Down