Skip to content

Commit

Permalink
Merge branch 'main' into release-2.4
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <snichols@vmware.com>
  • Loading branch information
Scott Nichols committed Apr 14, 2021
2 parents 45722cb + c5f062f commit a6f076e
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 148 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/conformance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Conformance

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Go Format

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Code Style

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Unit Test

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
43 changes: 5 additions & 38 deletions .github/workflows/inclusive.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Inclusive

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand All @@ -17,39 +15,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
# since their action is not yet released under a stable version.
- name: Woke
shell: bash
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
WOKE_VERSION: v0.1.11
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'
echo '::group:: Installing woke ... https://github.com/get-woke/woke'
curl -sfL https://raw.githubusercontent.com/get-woke/woke/main/install.sh | sh -s -- -b "${TEMP_PATH}" "${WOKE_VERSION}" 2>&1
echo '::endgroup::'
# Create a minimal .wokeignore if none already exist.
if [ ! -f .wokeignore ]; then
echo "vendor\nthird_party" > .wokeignore
fi
echo '::group:: Running woke with reviewdog 🐶 ...'
woke --output simple \
| reviewdog -efm="%f:%l:%c: %m" \
-name="woke" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error" \
echo '::endgroup::'
uses: get-woke/woke-action-reviewdog@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
4 changes: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Integration Tests

on:
push:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]
branches: [ 'main', 'release-*' ]

jobs:

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![go-doc](https://godoc.org/github.com/cloudevents/sdk-go?status.svg)](https://godoc.org/github.com/cloudevents/sdk-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/cloudevents/sdk-go)](https://goreportcard.com/report/github.com/cloudevents/sdk-go)
[![Releases](https://img.shields.io/github/release-pre/cloudevents/sdk-go.svg)](https://github.com/cloudevents/sdk-go/releases)
[![LICENSE](https://img.shields.io/github/license/cloudevents/sdk-go.svg)](https://github.com/cloudevents/sdk-go/blob/master/LICENSE)
[![LICENSE](https://img.shields.io/github/license/cloudevents/sdk-go.svg)](https://github.com/cloudevents/sdk-go/blob/main/LICENSE)

Official CloudEvents SDK to integrate your application with CloudEvents.

Expand All @@ -26,8 +26,8 @@ _Note:_ Supported go version: 1.14+

Add the module as dependency using go mod:

```
% go get github.com/cloudevents/sdk-go/v2@v2.3.1
```shell
go get github.com/cloudevents/sdk-go/v2@v2.4.0
```

And import the module in your code
Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
At the time of writing, there are two major versions being releases,

- v1.+ are released from the `release-1.y.z` branch.
- v2.+ are released from the `master` branch.
- v2.+ are released from the `main` branch.

General rules that apply to both releases:

Expand Down
49 changes: 27 additions & 22 deletions docs/event_data_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ nav_order: 3
---

# Event data structure

{: .no_toc }

1. TOC
{:toc}
1. TOC {:toc}

## Overview

The `Event` data structure is the representation of a `CloudEvent` in sdk-go. The main features are:
The `Event` data structure is the representation of a `CloudEvent` in sdk-go.
The main features are:

* Support for multiple event versions
* Type safe implementation of CloudEvents attributes and extensions
* Validation of the event
* Implementation of marshalling/unmarshalling to JSON.
* Implementation of `data` field codecs
- Support for multiple event versions
- Type safe implementation of CloudEvents attributes and extensions
- Validation of the event
- Implementation of marshalling/unmarshalling to JSON.
- Implementation of `data` field codecs

## Writing/Reading the attributes and extensions

To read and write attributes and extensions of the `Event`, you can use the methods of `EventContextReader`/`EventContextWriter`:
To read and write attributes and extensions of the `Event`, you can use the
methods of `EventContextReader`/`EventContextWriter`:

```go
ev := cloudevents.NewEvent()
Expand All @@ -33,23 +35,26 @@ ev := cloudevents.NewEvent()
err := ev.Context.SetExtension("aaa", "hello_world")
```

Attributes and extensions are represented internally using wrapper types from [`types` module](https://github.com/cloudevents/sdk-go/tree/master/v2/types).
Attributes and extensions are represented internally using wrapper types from
[`types` module](https://github.com/cloudevents/sdk-go/tree/main/v2/types).

## Writing/Reading the data field

To write the `data` field in your `Event`, use `Event.SetData()`. This method accepts
both the content type and the payload. If the payload is a `[]byte`, then no encoding
will be made, otherwise the [`datacodec` module](https://github.com/cloudevents/sdk-go/tree/master/v2/event/datacodec) will be used to
encode the payload.
To write the `data` field in your `Event`, use `Event.SetData()`. This method
accepts both the content type and the payload. If the payload is a `[]byte`,
then no encoding will be made, otherwise the
[`datacodec` module](https://github.com/cloudevents/sdk-go/tree/main/v2/event/datacodec)
will be used to encode the payload.

You can read the `data` or accessing directly to the underlying `[]byte` using `Event.Data()` or
decoding it using `event.DataAs()`, which uses a specific `Decoder` from `datacodec` module
to decode the event `data`.
You can read the `data` or accessing directly to the underlying `[]byte` using
`Event.Data()` or decoding it using `event.DataAs()`, which uses a specific
`Decoder` from `datacodec` module to decode the event `data`.

Some formats have built-in support in `datacodec`, like `application/xml`,
`application/json` and `text/plain`. You can use your own encoding implementing
[`datacodec.Encoder` and `datacodec.Decoder`](https://github.com/cloudevents/sdk-go/tree/master/v2/event/datacodec/codec.go) and registering
it with [`datacodec.AddEncoder` and `datacodec.AddDecoder`](https://github.com/cloudevents/sdk-go/tree/master/v2/event/datacodec/codec.go)
Some formats have built-in support in `datacodec`, like `application/xml`,
`application/json` and `text/plain`. You can use your own encoding implementing
[`datacodec.Encoder` and `datacodec.Decoder`](https://github.com/cloudevents/sdk-go/tree/main/v2/event/datacodec/codec.go)
and registering it with
[`datacodec.AddEncoder` and `datacodec.AddDecoder`](https://github.com/cloudevents/sdk-go/tree/main/v2/event/datacodec/codec.go)

## Marshal/Unmarshal event to JSON

Expand All @@ -65,4 +70,4 @@ To unmarshal the Event from JSON:
```go
ev := &event.Event{}
err := json.Unmarshal(bytesArray, ev)
```
```
30 changes: 15 additions & 15 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,24 @@ err := json.Marshal(bytes, &event)

## Supported specification features

| | [v0.3](https://github.com/cloudevents/spec/tree/v0.3) | [v1.0](https://github.com/cloudevents/spec/tree/v1.0) |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
| CloudEvents Core | :heavy_check_mark: | :heavy_check_mark: |
| [AMQP Protocol Binding](https://github.com/cloudevents/sdk-go/tree/master/samples/amqp) | :heavy_check_mark: | :heavy_check_mark: |
| AVRO Event Format | :x: | :x: |
| [HTTP Protocol Binding](https://github.com/cloudevents/sdk-go/tree/master/samples/http) | :heavy_check_mark: | :heavy_check_mark: |
| [JSON Event Format](event_data_structure.md#marshalunmarshal-event-to-json) | :heavy_check_mark: | :heavy_check_mark: |
| [Kafka Protocol Binding](https://github.com/cloudevents/sdk-go/tree/master/samples/kafka) | :heavy_check_mark: | :heavy_check_mark: |
| MQTT Protocol Binding | :x: | :x: |
| [NATS Protocol Binding](https://github.com/cloudevents/sdk-go/tree/master/samples/nats) | :heavy_check_mark: | :heavy_check_mark: |
| [STAN Protocol Binding](https://github.com/cloudevents/sdk-go/tree/master/samples/stan) | :heavy_check_mark: | :heavy_check_mark: |
| Web hook | :x: | :x: |
| | [v0.3](https://github.com/cloudevents/spec/tree/v0.3) | [v1.0](https://github.com/cloudevents/spec/tree/v1.0) |
| --------------------------------------------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- |
| CloudEvents Core | :heavy_check_mark: | :heavy_check_mark: |
| [AMQP Protocol Binding](https://github.com/cloudevents/sdk-go/tree/main/samples/amqp) | :heavy_check_mark: | :heavy_check_mark: |
| AVRO Event Format | :x: | :x: |
| [HTTP Protocol Binding](https://github.com/cloudevents/sdk-go/tree/main/samples/http) | :heavy_check_mark: | :heavy_check_mark: |
| [JSON Event Format](event_data_structure.md#marshalunmarshal-event-to-json) | :heavy_check_mark: | :heavy_check_mark: |
| [Kafka Protocol Binding](https://github.com/cloudevents/sdk-go/tree/main/samples/kafka) | :heavy_check_mark: | :heavy_check_mark: |
| MQTT Protocol Binding | :x: | :x: |
| [NATS Protocol Binding](https://github.com/cloudevents/sdk-go/tree/main/samples/nats) | :heavy_check_mark: | :heavy_check_mark: |
| [STAN Protocol Binding](https://github.com/cloudevents/sdk-go/tree/main/samples/stan) | :heavy_check_mark: | :heavy_check_mark: |
| Web hook | :x: | :x: |

## Go further

_. Check out the
[examples](https://github.com/cloudevents/sdk-go/tree/master/samples) _. Dig
into the [Godoc](https://godoc.org/github.com/cloudevents/sdk-go/v2) _. Learn
about the [architecture and concepts](concepts.md) of the SDK _. How to use the
[examples](https://github.com/cloudevents/sdk-go/tree/main/samples) _. Dig into
the [Godoc](https://godoc.org/github.com/cloudevents/sdk-go/v2) _. Learn about
the [architecture and concepts](concepts.md) of the SDK _. How to use the
[CloudEvent in-memory representation](event_data_structure.md) \*. How to
use/implement a [Protocol Binding](protocol_implementations.md)

0 comments on commit a6f076e

Please sign in to comment.