-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a Protobuf event formatter
Further features may be added later, e.g. convenience methods. Signed-off-by: Jon Skeet <jonskeet@google.com>
- Loading branch information
Showing
10 changed files
with
2,682 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
# Copyright 2021 Cloud Native Foundation. | ||
# Licensed under the Apache 2.0 license. | ||
# See LICENSE file in the project root for full license information. | ||
|
||
set -e | ||
PROTOBUF_VERSION=3.19.3 | ||
|
||
# Generates the classes for the protobuf event format | ||
|
||
case "$OSTYPE" in | ||
linux*) | ||
PROTOBUF_PLATFORM=linux-x86_64 | ||
PROTOC=tmp/bin/protoc | ||
;; | ||
win* | msys* | cygwin*) | ||
PROTOBUF_PLATFORM=win64 | ||
PROTOC=tmp/bin/protoc.exe | ||
;; | ||
darwin*) | ||
PROTOBUF_PLATFORM=osx-x86_64 | ||
PROTOC=tmp/bin/protoc | ||
;; | ||
*) | ||
echo "Unknown OSTYPE: $OSTYPE" | ||
exit 1 | ||
esac | ||
|
||
# Clean up previous generation results | ||
rm -f src/CloudNative.CloudEvents.Protobuf/*.g.cs | ||
rm -f test/CloudNative.CloudEvents.UnitTests/Protobuf/*.g.cs | ||
|
||
rm -rf tmp | ||
mkdir tmp | ||
cd tmp | ||
|
||
echo "- Downloading protobuf@$PROTOBUF_VERSION" | ||
curl -sSL \ | ||
https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-$PROTOBUF_PLATFORM.zip \ | ||
--output protobuf.zip | ||
unzip -q protobuf.zip | ||
|
||
echo "- Downloading schema" | ||
# TODO: Use the 1.0.2 branch when it exists. | ||
mkdir cloudevents | ||
curl -sSL https://raw.githubusercontent.com/cloudevents/spec/main/cloudevents/formats/cloudevents.proto -o cloudevents/ProtoSchema.proto | ||
|
||
cd .. | ||
|
||
# Schema proto | ||
$PROTOC \ | ||
-I tmp/include \ | ||
-I tmp/cloudevents \ | ||
--csharp_out=src/CloudNative.CloudEvents.Protobuf \ | ||
--csharp_opt=file_extension=.g.cs \ | ||
tmp/cloudevents/ProtoSchema.proto | ||
|
||
# Test protos | ||
$PROTOC \ | ||
-I tmp/include \ | ||
-I test/CloudNative.CloudEvents.UnitTests/Protobuf \ | ||
--csharp_out=test/CloudNative.CloudEvents.UnitTests/Protobuf \ | ||
--csharp_opt=file_extension=.g.cs \ | ||
test/CloudNative.CloudEvents.UnitTests/Protobuf/*.proto | ||
|
||
echo "Generated code." | ||
rm -rf tmp |
23 changes: 23 additions & 0 deletions
23
src/CloudNative.CloudEvents.Protobuf/CloudNative.CloudEvents.Protobuf.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks> | ||
<Description>Support for the Protobuf event format in for CloudNative.CloudEvents</Description> | ||
<PackageTags>cncf;cloudnative;cloudevents;events;protobuf</PackageTags> | ||
<LangVersion>8.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<Version>2.0.0-local.1</Version> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Google.Protobuf" Version="3.19.3" /> | ||
|
||
<!-- Be explicit about not including these files in the package. --> | ||
<None Include="README.md" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CloudNative.CloudEvents\CloudNative.CloudEvents.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.