Skip to content

Commit fc1912e

Browse files
authored
Retarget SDK to upstream Go toolchain 1.24 (#1)
* bugfix: fix Errorf without a format string Signed-off-by: Matt Leon <[email protected]> * feat: rework API to support full upstream Go compiler v1.24 Signed-off-by: Matt Leon <[email protected]> * chore: byte slice conversion functions to stdlib implementations Signed-off-by: Matt Leon <[email protected]> * Revert "more updates" This reverts commit 33c01aa. Signed-off-by: Matt Leon <[email protected]> * Revert "Deletes unnecessary components: part 2 (tetratelabs#453)" This reverts commit f4829de. Signed-off-by: Matt Leon <[email protected]> * Revert "Deletes unnecessary components (tetratelabs#452)" This reverts commit cbcb260. Signed-off-by: Matt Leon <[email protected]> * Revert "Updates README to reflect the project direction (tetratelabs#451)" This reverts commit 1d2249f. Signed-off-by: Matt Leon <[email protected]> * owners: update for full Go version maintainer Signed-off-by: Matt Leon <[email protected]> * doc: update OVERVIEW for full Go compiler features and limitations Signed-off-by: Matt Leon <[email protected]> * doc: modernize README with full Go instructions Signed-off-by: Matt Leon <[email protected]> * chore: update issue template to ask which compiler is in use Signed-off-by: Matt Leon <[email protected]> * chore: update Makefile with full Go instructions Signed-off-by: Matt Leon <[email protected]> * chore: update workflows with full go sdk version 1.24 Signed-off-by: Matt Leon <[email protected]> * chore: update required go.mod versions Signed-off-by: Matt Leon <[email protected]> * chore: fix lint errors Signed-off-by: Matt Leon <[email protected]> * doc: document alpha status in README Signed-off-by: Matt Leon <[email protected]> * chore: update references from tetratelabs repo to proxy-wasm repo Signed-off-by: Matt Leon <[email protected]> * doc: update docs with feedback on PR#1 - Add CLA and community guidelines to CONTRIBUTING.md - Rename workflows - Remove e2e tests from workflows - Clarify difference from tetratelabs/proxy-wasm-go-sdk Signed-off-by: Matt Leon <[email protected]> * ci: rename workflow to "Presubmit checks" Signed-off-by: Matt Leon <[email protected]> * doc: update overview with review comments Signed-off-by: Matt Leon <[email protected]> * doc: replace tabs with spaces Signed-off-by: Matt Leon <[email protected]> * doc: replace tabs with spaces in README.md Signed-off-by: Matt Leon <[email protected]> * ci: fix workflow file syntax Signed-off-by: Matt Leon <[email protected]> * chore: fix import ordering post rename Signed-off-by: Matt Leon <[email protected]> * chore: add martijneken to CODEOWNERS Signed-off-by: Matt Leon <[email protected]> --------- Signed-off-by: Matt Leon <[email protected]>
1 parent 33c01aa commit fc1912e

File tree

113 files changed

+1854
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1854
-701
lines changed

Diff for: .github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @leonm1 @martijneken

Diff for: .github/ISSUE_TEMPLATE/bug-error-report.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Bug / Error report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- PLEASE FILL IN THE FOLLOWINGS for EVERY ISSUE you make. -->
11+
12+
## Describe the bug / error
13+
14+
## What is your Envoy/Istio version?
15+
16+
## What is the SDK version?
17+
18+
## What compiler are you using, and what is the version?
19+
20+
## URL or snippet of your code including Envoy configuration
21+
22+
## Additional context (Optional)

Diff for: .github/workflows/workflow.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Presubmit checks
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
schedule:
10+
- cron: '0 0 * * *'
11+
12+
env:
13+
GO_VERSION: 1.24.0-rc.1
14+
15+
jobs:
16+
style:
17+
name: Code style check
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: install Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ${{ env.GO_VERSION }}
24+
25+
- name: checkout
26+
uses: actions/checkout@v3
27+
28+
- name: run lint
29+
run: make lint
30+
31+
- name: run format check
32+
run: make check
33+
34+
sdk-tests:
35+
name: SDK tests
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: install Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: ${{ env.GO_VERSION }}
42+
43+
- name: checkout
44+
uses: actions/checkout@v3
45+
46+
- name: run tests
47+
run: make test
48+
49+
examples:
50+
name: Examples Tests
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
56+
- name: Build cache
57+
uses: actions/cache@v3
58+
with:
59+
path: |
60+
~/go/pkg/mod
61+
~/go/bin
62+
key: examples-${{ hashFiles('**/go.mod', '**/go.sum') }}-{{ env.GO_VERSION }}
63+
64+
- name: Install Go
65+
uses: actions/setup-go@v5
66+
with:
67+
go-version: ${{ env.GO_VERSION }}
68+
69+
- name: Build examples
70+
run: make build.examples
71+
72+
- name: Test examples
73+
run: make test.examples

Diff for: Makefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
goimports := golang.org/x/tools/cmd/[email protected]
2-
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
2+
golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
33

44

55
.PHONY: build.example
66
build.example:
77
@find ./examples -type f -name "main.go" | grep ${name}\
88
| xargs -I {} bash -c 'dirname {}' \
9-
| xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go'
9+
| xargs -I {} bash -c 'cd {} && env GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o main.wasm ./main.go'
1010

1111

1212
.PHONY: build.examples
1313
build.examples:
1414
@find ./examples -mindepth 1 -type f -name "main.go" \
1515
| xargs -I {} bash -c 'dirname {}' \
16-
| xargs -I {} bash -c 'cd {} && tinygo build -o main.wasm -scheduler=none -target=wasi ./main.go'
16+
| xargs -I {} bash -c 'cd {} && env GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o main.wasm ./main.go'
1717

1818
.PHONY: test
1919
test:
@@ -26,6 +26,14 @@ test.examples:
2626
| xargs -I {} bash -c 'dirname {}' \
2727
| xargs -I {} bash -c 'cd {} && go test ./...'
2828

29+
.PHONY: test.e2e
30+
test.e2e:
31+
@go test -v ./e2e -count=1
32+
33+
.PHONY: test.e2e.single
34+
test.e2e.single:
35+
@go test -v ./e2e -run '/${name}' -count=1
36+
2937
.PHONY: run
3038
run:
3139
@envoy -c ./examples/${name}/envoy.yaml --concurrency 2 --log-format '%v'

Diff for: README.md

+98-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,98 @@
1-
> [!WARNING]
2-
> We are no longer recommending this SDK or Wasm in general for anyone due to the fundamental memory issue of TinyGo (See [the detailed explanation](https://github.com/tetratelabs/proxy-wasm-go-sdk/issues/450#issuecomment-2253729297) by a long-time community member)
3-
> as well as [the project state of Proxy-Wasm in general](https://github.com/envoyproxy/envoy/issues/35420).
4-
> If you are not in a position where you have to run untrusted binaries (like for example, you run Envoy proxies while your client gives you the binaries to run), we recommend using other extension mechanism
5-
> such as Lua or External Processing which should be comparable or better or worse depending on the use case.
6-
>
7-
> If you are already using this SDK, but still want to continue using Wasm for some reason instead of Lua or External Processing,
8-
> we strongly recommend migrating to the Rust or C++ SDK due to the memory issue of TinyGo described in the link above.
9-
>
10-
> We keep this repository open and not archived for the existing users, but we cannot provide any support or guarantee for the future development of this SDK.
11-
> However, at any time, we may decide to archive this repository if we see no reason to keep it open.
1+
# WebAssembly for Proxies (Go SDK) [![Build](https://github.com/proxy-wasm/proxy-wasm-go-sdk/workflows/Test/badge.svg)](https://github.com/proxy-wasm/proxy-wasm-go-sdk/actions) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
2+
3+
The Go SDK for
4+
[Proxy-Wasm](https://github.com/proxy-wasm/spec), enabling developers to write Proxy-Wasm plugins in Go.
5+
6+
Note: This SDK targets the upstream Go compiler, version 1.24 or later. This is different than the forked github.com/tetratelabs/proxy-wasm-go-sdk, which targets the TinyGo compiler.
7+
8+
## Project Status
9+
10+
This SDK is based off of github.com/tetratelabs/proxy-wasm-go-sdk; however, it is effectively a new SDK targeting a completely different toolchain. It relies on the not-yet-released Go 1.24 and hasn't seen extensive prod testing by end-users. This SDK is an alpha product.
11+
12+
## Getting Started
13+
14+
- [examples](examples) directory contains the example codes on top of this SDK.
15+
- [OVERVIEW.md](doc/OVERVIEW.md) the overview of Proxy-Wasm, the API of this SDK, and the things you should know when writing plugins.
16+
17+
## Requirements
18+
19+
- \[Required] [Go](https://go.dev/): v1.24+ - This SDK leverages Go 1.24's support for [WASI](https://github.com/WebAssembly/WASI) (WebAssembly System Interface) reactors. You can grab a release candidate from the [Go unstable releases page](https://go.dev/dl/#unstable). A stable release of Go 1.24 is [expected in February 2025](https://tip.golang.org/doc/go1.24).
20+
- \[Required] A host environment supporting this toolchain - This SDK leverages additional host imports added to the proxy-wasm-cpp-host in [PR#427](https://github.com/proxy-wasm/proxy-wasm-cpp-host/pull/427). This has yet to be merged, let alone make its way downstream to Envoy, ATS, nginx, or managed environments.
21+
- \[Optional] [Envoy](https://www.envoyproxy.io) - To run end-to-end tests, you need to have an Envoy binary. You can use [func-e](https://func-e.io) as an easy way to get started with Envoy or follow [the official instruction](https://www.envoyproxy.io/docs/envoy/latest/start/install).
22+
23+
## Installation
24+
25+
```
26+
go get github.com/proxy-wasm/proxy-wasm-go-sdk
27+
```
28+
29+
## Minimal Example Plugin
30+
31+
A minimal plugin:
32+
33+
```go
34+
package main
35+
36+
import (
37+
"github.com/proxy-wasm/proxy-wasm-go-sdk/proxywasm"
38+
"github.com/proxy-wasm/proxy-wasm-go-sdk/proxywasm/types"
39+
)
40+
41+
func init() {
42+
proxywasm.SetVMContext(&vmContext{})
43+
}
44+
type vmContext struct {
45+
types.DefaultVMContext
46+
}
47+
type pluginContext struct {
48+
types.DefaultPluginContext
49+
}
50+
func (*context) NewPluginContext(contextID uint32) types.PluginContext {
51+
return &context{}
52+
}
53+
func main() {}
54+
```
55+
56+
It can be compiled with `env GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o my-plugin.wasm main.go`.
57+
58+
## Build and run Examples
59+
60+
```bash
61+
# Build all examples.
62+
make build.examples
63+
64+
# Build a specific example using the `go` tool.
65+
cd examples/helloworld
66+
env GOOS=wasp1 GOARCH=wasm go build -buildmode=c-shared -o main.wasm main.go
67+
68+
# Test the built wasm module using `go test`.
69+
go test
70+
71+
# Build and test a specific example from the repo root using `make`.
72+
make build.example name=helloworld
73+
make run name=helloworld
74+
```
75+
76+
## Compatible Envoy builds
77+
78+
Envoy is the first host side implementation of Proxy-Wasm ABI,
79+
and we run end-to-end tests with multiple versions of Envoy and Envoy-based [istio/proxy](https://github.com/istio/proxy) in order to verify Proxy-Wasm Go SDK works as expected.
80+
81+
Please refer to [workflow.yaml](.github/workflows/workflow.yaml) for which version is used for End-to-End tests.
82+
83+
## Build tags
84+
85+
The following build tags can be used to customize the behavior of the built plugin. Build tags [can be specified in the `go build` command via the `-tags` flag](https://pkg.go.dev/cmd/go#:~:text=tags):
86+
87+
- `proxywasm_timing`: Enables logging of time spent in invocation of the plugin's exported functions. This can be useful for debugging performance issues.
88+
89+
## Contributing
90+
91+
We welcome contributions from the community! See [CONTRIBUTING.md](doc/CONTRIBUTING.md) for how to contribute to this repository.
92+
93+
## External links
94+
95+
- [WebAssembly for Proxies (ABI specification)](https://github.com/proxy-wasm/spec)
96+
- [WebAssembly for Proxies (C++ SDK)](https://github.com/proxy-wasm/proxy-wasm-cpp-sdk)
97+
- [WebAssembly for Proxies (Rust SDK)](https://github.com/proxy-wasm/proxy-wasm-rust-sdk)
98+
- [WebAssembly for Proxies (AssemblyScript SDK)](https://github.com/solo-io/proxy-runtime)

Diff for: doc/CONTRIBUTING.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing
2+
3+
We welcome contributions from the community. Please read the following guidelines carefully to maximize the chances of your PR being merged.
4+
5+
## Coding Style
6+
7+
The code is linted using a stringent golang-ci. To run this linter (and a few others) use run `make check`. To format your files, you can run `make format`.
8+
9+
## Running tests
10+
11+
```
12+
# Run local tests without running envoy processes.
13+
make test
14+
15+
# Run all e2e tests.
16+
# This requires you to have Envoy binary locally.
17+
make test.e2e
18+
19+
# Run e2e tests for a specific example.
20+
# This requires you to have Envoy binary locally.
21+
make test.e2e.single name=helloworld
22+
```
23+
24+
## Contributor License Agreement
25+
26+
Contributions to this project must be accompanied by a Contributor License
27+
Agreement. You (or your employer) retain the copyright to your contribution;
28+
this simply gives us permission to use and redistribute your contributions as
29+
part of the project. Head over to <https://cla.developers.google.com/> to see
30+
your current agreements on file or to sign a new one.
31+
32+
You generally only need to submit a CLA once, so if you've already submitted one
33+
(even if it was for a different project), you probably don't need to do it
34+
again.
35+
36+
## Code reviews
37+
38+
All submissions, including submissions by project members, require review. We
39+
use GitHub pull requests for this purpose. Consult
40+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
41+
information on using pull requests.
42+
43+
## Community Guidelines
44+
45+
This project follows [Google's Open Source Community
46+
Guidelines](https://opensource.google/conduct/).

0 commit comments

Comments
 (0)