From a331da7fcf2537b7709ad31bf10461aeda543456 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Mon, 15 Mar 2021 11:44:45 +0900 Subject: [PATCH] Support TinyGo SDK for extension toolkit (#104) Signed-off-by: Takeshi Yoneda --- Makefile | 4 +- .../envoy.access_loggers/default/.gitignore | 1 + .../envoy.access_loggers/default/go.mod | 8 ++ .../envoy.access_loggers/default/go.sum | 13 +++ .../envoy.access_loggers/default/main.go | 46 +++++++++ .../envoy.access_loggers/default/main_test.go | 36 +++++++ .../envoy.filters.http/default/.gitignore | 1 + .../tinygo/envoy.filters.http/default/go.mod | 8 ++ .../tinygo/envoy.filters.http/default/go.sum | 13 +++ .../tinygo/envoy.filters.http/default/main.go | 98 +++++++++++++++++++ .../envoy.filters.http/default/main_test.go | 53 ++++++++++ .../envoy.filters.network/default/.gitignore | 1 + .../envoy.filters.network/default/go.mod | 8 ++ .../envoy.filters.network/default/go.sum | 13 +++ .../envoy.filters.network/default/main.go | 63 ++++++++++++ .../default/main_test.go | 64 ++++++++++++ go.mod | 3 +- go.sum | 55 +---------- .../{rust => }/entrypoint.sh | 0 images/extension-builders/rust/Dockerfile | 2 +- images/extension-builders/tinygo/Dockerfile | 28 ++++++ images/extension-builders/tinygo/commands.sh | 33 +++++++ pkg/cmd/extension/init/cmd.go | 5 +- pkg/cmd/extension/run/cmd_test.go | 18 +--- .../workspace/config/extension/helpers.go | 2 +- .../workspace/config/extension/types.go | 4 +- .../toolchain/builtin/default_config.go | 7 +- .../toolchain/builtin/default_config_test.go | 3 +- .../toolchain/builtin/example_config_test.go | 4 +- .../default_config/tinygo.toolchain.yaml | 6 ++ .../example_config/tinygo.toolchain.yaml | 56 +++++++++++ test/e2e/e2e_suite_test.go | 7 ++ test/e2e/getenvoy_extension_build_test.go | 4 +- test/e2e/getenvoy_extension_examples_test.go | 1 + test/e2e/getenvoy_extension_init_test.go | 4 +- test/e2e/getenvoy_extension_push_test.go | 1 + test/e2e/getenvoy_extension_run_test.go | 4 +- test/e2e/getenvoy_extension_test_test.go | 1 + 38 files changed, 594 insertions(+), 84 deletions(-) create mode 100644 data/extension/init/templates/tinygo/envoy.access_loggers/default/.gitignore create mode 100644 data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod create mode 100644 data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum create mode 100644 data/extension/init/templates/tinygo/envoy.access_loggers/default/main.go create mode 100644 data/extension/init/templates/tinygo/envoy.access_loggers/default/main_test.go create mode 100644 data/extension/init/templates/tinygo/envoy.filters.http/default/.gitignore create mode 100644 data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod create mode 100644 data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum create mode 100644 data/extension/init/templates/tinygo/envoy.filters.http/default/main.go create mode 100644 data/extension/init/templates/tinygo/envoy.filters.http/default/main_test.go create mode 100644 data/extension/init/templates/tinygo/envoy.filters.network/default/.gitignore create mode 100644 data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod create mode 100644 data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum create mode 100644 data/extension/init/templates/tinygo/envoy.filters.network/default/main.go create mode 100644 data/extension/init/templates/tinygo/envoy.filters.network/default/main_test.go rename images/extension-builders/{rust => }/entrypoint.sh (100%) create mode 100644 images/extension-builders/tinygo/Dockerfile create mode 100755 images/extension-builders/tinygo/commands.sh create mode 100644 pkg/extension/workspace/toolchain/builtin/testdata/default_config/tinygo.toolchain.yaml create mode 100644 pkg/extension/workspace/toolchain/builtin/testdata/example_config/tinygo.toolchain.yaml diff --git a/Makefile b/Makefile index 3f4007f2..4674cc0e 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ ENVOY = standard:1.11.1 HUB ?= docker.io/getenvoy GETENVOY_TAG ?= dev -BUILDERS_LANGS := rust +BUILDERS_LANGS := rust tinygo BUILDERS_TAG ?= latest EXTRA_TAG ?= @@ -139,7 +139,7 @@ builder/$(1): $(if $(USE_DOCKER_BUILDKIT_CACHE),--build-arg BUILDKIT_INLINE_CACHE=1,) \ $(if $(USE_DOCKER_BUILDKIT_CACHE),--cache-from $(call EXTENSION_BUILDER_IMAGE,$(1),$(EXTENSION_BUILDER_IMAGE_LATEST_VERSION)),) \ -t $(call EXTENSION_BUILDER_IMAGE,$(1),$(BUILDERS_TAG)) \ - images/extension-builders/$(1) + -f images/extension-builders/$(1)/Dockerfile images/extension-builders endef $(foreach lang,$(BUILDERS_LANGS),$(eval $(call GEN_BUILD_EXTENSION_BUILDER_IMAGE_TARGET,$(lang)))) diff --git a/data/extension/init/templates/tinygo/envoy.access_loggers/default/.gitignore b/data/extension/init/templates/tinygo/envoy.access_loggers/default/.gitignore new file mode 100644 index 00000000..84c048a7 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.access_loggers/default/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod b/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod new file mode 100644 index 00000000..02297849 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod @@ -0,0 +1,8 @@ +module {{ .Extension.Name }} + +go 1.15 + +require ( + github.com/stretchr/testify v1.6.1 + github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 +) diff --git a/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum b/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum new file mode 100644 index 00000000..4a33c4c1 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY= +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.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/data/extension/init/templates/tinygo/envoy.access_loggers/default/main.go b/data/extension/init/templates/tinygo/envoy.access_loggers/default/main.go new file mode 100644 index 00000000..f00b6f5d --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.access_loggers/default/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +func main() { + proxywasm.SetNewRootContext(newAccessLogger) +} + +type accessLogger struct { + // You'd better embed the default root context + // so that you don't need to reimplement all the methods by yourself. + proxywasm.DefaultRootContext + logMessage string +} + +func newAccessLogger(contextID uint32) proxywasm.RootContext { + return &accessLogger{} +} + +// Override proxywasm.DefaultRootContext +func (l *accessLogger) OnPluginStart(configurationSize int) types.OnPluginStartStatus { + // Read plugin configuration provided in Envoy configuration. + data, err := proxywasm.GetPluginConfiguration(configurationSize) + if err != nil && err != types.ErrorStatusNotFound { + proxywasm.LogCriticalf("failed to load config: %v", err) + return types.OnPluginStartStatusFailed + } + l.logMessage = string(data) + return types.OnPluginStartStatusOK +} + +// Override proxywasm.DefaultRootContext +func (l *accessLogger) OnLog() { + hdr, err := proxywasm.GetHttpRequestHeader(":path") + if err != nil { + proxywasm.LogCritical(err.Error()) + return + } + + proxywasm.LogInfof(":path = %s", hdr) + proxywasm.LogInfof("message = %s", l.logMessage) + +} diff --git a/data/extension/init/templates/tinygo/envoy.access_loggers/default/main_test.go b/data/extension/init/templates/tinygo/envoy.access_loggers/default/main_test.go new file mode 100644 index 00000000..71928db6 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.access_loggers/default/main_test.go @@ -0,0 +1,36 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/tetratelabs/proxy-wasm-go-sdk/proxytest" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +func TestAccessLogger_OnLog(t *testing.T) { + configuration := `this is my log message` + opt := proxytest.NewEmulatorOption(). + WithNewRootContext(newAccessLogger). + WithPluginConfiguration([]byte(configuration)) + + host := proxytest.NewHostEmulator(opt) + // Release the host emulation lock so that other test cases can insert their own host emulation. + defer host.Done() + + // Call OnPluginStart -> the message field of root context is configured. + status := host.StartPlugin() + // Check the status returned by OnPluginStart is OK. + require.Equal(t, types.OnPluginStartStatusOK, status) + + // Call OnLog with the given headers. + host.CallOnLogForAccessLogger(types.Headers{ + {":path", "/this/is/path"}, + }, nil) + + // Check the Envoy logs. + logs := host.GetLogs(types.LogLevelInfo) + require.Contains(t, logs, ":path = /this/is/path") + require.Contains(t, logs, "message = this is my log message") +} diff --git a/data/extension/init/templates/tinygo/envoy.filters.http/default/.gitignore b/data/extension/init/templates/tinygo/envoy.filters.http/default/.gitignore new file mode 100644 index 00000000..84c048a7 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.http/default/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod b/data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod new file mode 100644 index 00000000..02297849 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod @@ -0,0 +1,8 @@ +module {{ .Extension.Name }} + +go 1.15 + +require ( + github.com/stretchr/testify v1.6.1 + github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 +) diff --git a/data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum b/data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum new file mode 100644 index 00000000..4a33c4c1 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY= +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.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/data/extension/init/templates/tinygo/envoy.filters.http/default/main.go b/data/extension/init/templates/tinygo/envoy.filters.http/default/main.go new file mode 100644 index 00000000..18f4dc3a --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.http/default/main.go @@ -0,0 +1,98 @@ +package main + +import ( + "bufio" + "bytes" + "strings" + + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +var ( + requestCounterName = "my_http_filter.request_counter" + counter proxywasm.MetricCounter +) + +func main() { + proxywasm.SetNewRootContext(newRootContext) +} + +type rootContext struct { + // You'd better embed the default root context + // so that you don't need to reimplement all the methods by yourself. + proxywasm.DefaultRootContext + contextID uint32 + additionalHeaders map[string]string +} + +func newRootContext(rootContextID uint32) proxywasm.RootContext { + return &rootContext{contextID: rootContextID, additionalHeaders: map[string]string{"additional": "header"}} +} + +// Override proxywasm.DefaultRootContext +func (ctx *rootContext) OnPluginStart(configurationSize int) types.OnPluginStartStatus { + // Initialize the counter. + counter = proxywasm.DefineCounterMetric(requestCounterName) + + // Read plugin configuration provided in Envoy configuration. + data, err := proxywasm.GetPluginConfiguration(configurationSize) + if err != nil && err != types.ErrorStatusNotFound { + proxywasm.LogCriticalf("failed to load config: %v", err) + return types.OnPluginStartStatusFailed + } + + // Each line in the configuration is in the "KEY=VALUE" format. + scanner := bufio.NewScanner(bytes.NewReader(data)) + for scanner.Scan() { + tokens := strings.Split(scanner.Text(), "=") + ctx.additionalHeaders[tokens[0]] = tokens[1] + } + return types.OnPluginStartStatusOK +} + +// Override proxywasm.DefaultRootContext +func (ctx *rootContext) NewHttpContext(uint32) proxywasm.HttpContext { + return &httpContext{additionalHeaders: ctx.additionalHeaders} +} + +type httpContext struct { + // You'd better embed the default http context + // so that you don't need to reimplement all the methods by yourself. + proxywasm.DefaultHttpContext + additionalHeaders map[string]string +} + +// Override proxywasm.DefaultHttpContext +func (ctx *httpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action { + hs, err := proxywasm.GetHttpRequestHeaders() + if err != nil { + proxywasm.LogCriticalf("failed to get request headers: %v", err) + return types.ActionPause + } + + proxywasm.LogInfo("observing request headers") + for _, h := range hs { + proxywasm.LogInfof("%s: %s", h[0], h[1]) + } + + return types.ActionContinue +} + +// Override proxywasm.DefaultHttpContext +func (ctx *httpContext) OnHttpResponseHeaders(numHeaders int, endOfStream bool) types.Action { + // Set additional headers in the response. + for key, value := range ctx.additionalHeaders { + if err := proxywasm.SetHttpResponseHeader(key, value); err != nil { + proxywasm.LogCriticalf("failed to add header: %v", err) + return types.ActionPause + } + proxywasm.LogInfof("header set: %s=%s", key, value) + } + return types.ActionContinue +} + +// Override proxywasm.DefaultHttpContext +func (ctx *httpContext) OnHttpStreamDone() { + counter.Increment(1) +} diff --git a/data/extension/init/templates/tinygo/envoy.filters.http/default/main_test.go b/data/extension/init/templates/tinygo/envoy.filters.http/default/main_test.go new file mode 100644 index 00000000..0e0efff2 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.http/default/main_test.go @@ -0,0 +1,53 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/tetratelabs/proxy-wasm-go-sdk/proxytest" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +func TestHttpFilter_OnHttpRequestHeaders(t *testing.T) { + configuration := `HELLO=WORLD +ENVOY=ISTIO` + opt := proxytest.NewEmulatorOption(). + WithNewRootContext(newRootContext). + WithPluginConfiguration([]byte(configuration)) + + host := proxytest.NewHostEmulator(opt) + // Release the host emulation lock so that other test cases can insert their own host emulation. + defer host.Done() + + // Call OnPluginStart -> the metric is initialized. + status := host.StartPlugin() + // Check the status returned by OnPluginStart is OK. + require.Equal(t, types.OnPluginStartStatusOK, status) + + // Create http context. + contextID := host.InitializeHttpContext() + + // Call OnHttpRequestHeaders with the given headers. + hs := types.Headers{ + {"key1", "value1"}, + {"key2", "value2"}, + } + action := host.CallOnRequestHeaders(contextID, hs, false) + // Check the action returned by OnRequestHeaders is Continue. + require.Equal(t, types.ActionContinue, action) + + // Call OnHttpResponseHeaders. + action = host.CallOnResponseHeaders(contextID, nil, false) + // Check the action returned by OnResponseHeaders is Continue. + require.Equal(t, types.ActionContinue, action) + + // Check Envoy logs. + logs := host.GetLogs(types.LogLevelInfo) + require.Contains(t, logs, "header set: ENVOY=ISTIO") + require.Contains(t, logs, "header set: HELLO=WORLD") + require.Contains(t, logs, "header set: additional=header") + require.Contains(t, logs, "key2: value2") + require.Contains(t, logs, "key1: value1") + require.Contains(t, logs, "observing request headers") +} diff --git a/data/extension/init/templates/tinygo/envoy.filters.network/default/.gitignore b/data/extension/init/templates/tinygo/envoy.filters.network/default/.gitignore new file mode 100644 index 00000000..84c048a7 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.network/default/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod b/data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod new file mode 100644 index 00000000..02297849 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod @@ -0,0 +1,8 @@ +module {{ .Extension.Name }} + +go 1.15 + +require ( + github.com/stretchr/testify v1.6.1 + github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 +) diff --git a/data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum b/data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum new file mode 100644 index 00000000..4a33c4c1 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum @@ -0,0 +1,13 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0= +github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY= +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.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/data/extension/init/templates/tinygo/envoy.filters.network/default/main.go b/data/extension/init/templates/tinygo/envoy.filters.network/default/main.go new file mode 100644 index 00000000..2d41b560 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.network/default/main.go @@ -0,0 +1,63 @@ +package main + +import ( + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +var ( + connectionCounterName = "my_network_filter.connection_counter" + counter proxywasm.MetricCounter +) + +func main() { + proxywasm.SetNewRootContext(newRootContext) +} + +type rootContext struct { + // You'd better embed the default root context + // so that you don't need to reimplement all the methods by yourself. + proxywasm.DefaultRootContext + config string +} + +func newRootContext(rootContextID uint32) proxywasm.RootContext { + return &rootContext{} +} + +// Override proxywasm.DefaultRootContext +func (ctx *rootContext) OnPluginStart(configurationSize int) types.OnPluginStartStatus { + counter = proxywasm.DefineCounterMetric(connectionCounterName) + + data, err := proxywasm.GetPluginConfiguration(configurationSize) + if err != nil && err != types.ErrorStatusNotFound { + proxywasm.LogCriticalf("failed to load config: %v", err) + return types.OnPluginStartStatusFailed + } + ctx.config = string(data) + return types.OnPluginStartStatusOK +} + +// Override proxywasm.DefaultRootContext +func (ctx *rootContext) NewStreamContext(contextID uint32) proxywasm.StreamContext { + return &streamContext{newConnectionMessage: ctx.config} +} + +type streamContext struct { + // You'd better embed the default stream context + // so that you don't need to reimplement all the methods by yourself. + proxywasm.DefaultStreamContext + newConnectionMessage string +} + +// Override proxywasm.DefaultStreamContext +func (ctx *streamContext) OnNewConnection() types.Action { + proxywasm.LogInfo(ctx.newConnectionMessage) + return types.ActionContinue +} + +// Override proxywasm.DefaultStreamContext +func (ctx *streamContext) OnStreamDone() { + counter.Increment(1) + proxywasm.LogInfof("connection complete!") +} diff --git a/data/extension/init/templates/tinygo/envoy.filters.network/default/main_test.go b/data/extension/init/templates/tinygo/envoy.filters.network/default/main_test.go new file mode 100644 index 00000000..06a95431 --- /dev/null +++ b/data/extension/init/templates/tinygo/envoy.filters.network/default/main_test.go @@ -0,0 +1,64 @@ +package main + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxytest" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" +) + +func TestNetworkFilter_OnNewConnection(t *testing.T) { + configuration := `message: this is new connection!` + opt := proxytest.NewEmulatorOption(). + WithPluginConfiguration([]byte(configuration)). + WithNewRootContext(newRootContext) + + host := proxytest.NewHostEmulator(opt) + // Release the host emulation lock so that other test cases can insert their own host emulation. + defer host.Done() + + // Initialize the plugin and read the config. + status := host.StartPlugin() + // Check the status returned by OnPluginStart is OK. + require.Equal(t, types.OnPluginStartStatusOK, status) + + // OnNewConnection is called. + host.InitializeConnection() + + // Retrieve logs emitted to Envoy. + logs := host.GetLogs(types.LogLevelInfo) + require.Contains(t, logs, configuration) +} + +func TestNetworkFilter_counter(t *testing.T) { + opt := proxytest.NewEmulatorOption(). + WithNewRootContext(newRootContext) + + host := proxytest.NewHostEmulator(opt) + // Release the host emulation lock so that other test cases can insert their own host emulation. + defer host.Done() + + // Initialize the plugin and metric. + status := host.StartPlugin() + // Check the status returned by OnPluginStart is OK. + require.Equal(t, types.OnPluginStartStatusOK, status) + + // Establish the connection. + contextID, action := host.InitializeConnection() + // Check the status returned by OnNewConnection is ActionContinue. + require.Equal(t, types.ActionContinue, action) + + // Call OnDone on contextID -> increment the connection counter. + host.CompleteConnection(contextID) + + // Check Envoy logs. + logs := host.GetLogs(types.LogLevelInfo) + require.Greater(t, len(logs), 0) + require.Contains(t, logs, "connection complete!") + + // Check counter. + value, err := host.GetCounterMetric("my_network_filter.connection_counter") + require.NoError(t, err) + require.Equal(t, uint64(1), value) +} diff --git a/go.mod b/go.mod index e6b5b1b5..68d733a2 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,6 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/onsi/ginkgo v1.12.1 github.com/onsi/gomega v1.10.0 - github.com/opencontainers/go-digest v1.0.0-rc1 github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/selinux v1.8.0 // indirect github.com/otiai10/copy v1.2.0 @@ -33,7 +32,7 @@ require ( github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 github.com/spf13/cobra v0.0.5 - github.com/stretchr/testify v1.4.0 + github.com/stretchr/testify v1.6.1 github.com/tetratelabs/getenvoy-package v0.0.0-20190730071641-da31aed4333e github.com/tetratelabs/log v0.0.0-20190710134534-eb04d1e84fb8 github.com/tetratelabs/multierror v1.1.0 diff --git a/go.sum b/go.sum index fe8c6692..d205728d 100644 --- a/go.sum +++ b/go.sum @@ -50,7 +50,6 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd h1:sjQovDkwrZp8u+gxLtPgKGjk5hCxuy2hrRejBTA9xFU= github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= @@ -69,10 +68,8 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= @@ -128,9 +125,7 @@ github.com/cenkalti/backoff v2.0.0+incompatible h1:5IIPUHhlnUZbcHQsQou5k1Tn58nJk github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 h1:7aWHqerlJ41y6FOsEUvknqgXnGmJyJSbjhAWq5pO4F8= github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -212,9 +207,7 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 h1:ZClxb8laGDf5arXfYcAtECDFgAgHklGI8CxgjHnXKJ4= github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= @@ -226,14 +219,10 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/elazarl/goproxy v0.0.0-20190630181448-f1e96bc0f4c5 h1:Zp2QJezMfAbYc5fLiDUZ8x3vNroDxnufFCOIJjgL5tY= github.com/elazarl/goproxy v0.0.0-20190630181448-f1e96bc0f4c5/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/elazarl/goproxy/ext v0.0.0-20190630181448-f1e96bc0f4c5 h1:/VMZdsbv0B1ugqdqgMx2hJ7pgP6cb9K6RnrciKPbuz8= github.com/elazarl/goproxy/ext v0.0.0-20190630181448-f1e96bc0f4c5/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.9.6+incompatible h1:tfrHha8zJ01ywiOEC1miGY8st1/igzWB8OmvPgoYX7w= github.com/emicklei/go-restful v2.9.6+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -246,10 +235,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM= github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= -github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fluent/fluent-logger-golang v1.3.0/go.mod h1:2/HCT/jTy78yGyeNGQLGQsjF3zzzAuy6Xlk6FCMV5eU= @@ -259,7 +246,6 @@ github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5G github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7 h1:LofdAjjjqCSXMwLGgOgnE+rdPuvX9DxCqaHwKy7i/ko= github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/garyburd/redigo v1.6.0 h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc= github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= @@ -274,10 +260,8 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= -github.com/go-logr/zapr v0.1.1 h1:qXBXPDdNncunGs7XeEpsJt8wCjYBygluzfdLO0G5baE= github.com/go-logr/zapr v0.1.1/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= @@ -294,13 +278,11 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= -github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= @@ -314,9 +296,7 @@ github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nA github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= -github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw= github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= @@ -326,9 +306,7 @@ github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dp github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.6 h1:JSUbVWlaTLMhXeOMyArSUNCdroxZu2j1TcrsOV8Mj7Q= github.com/go-openapi/swag v0.19.6/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= @@ -345,7 +323,6 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -385,7 +362,6 @@ github.com/google/cel-go v0.2.0/go.mod h1:fTCVOuSN/Vn6d49zvRpr3fDAKFyfpLViE0gU+9 github.com/google/cel-spec v0.2.0/go.mod h1:MjQm800JAGhOZXI7vatnVpmIaFTR6L8FHcKk+piiKpI= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -403,10 +379,8 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go v2.0.2+incompatible h1:silFMLAnr330+NRuag/VjIGF7TLp/LBrV2CJKFLWEww= github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= @@ -428,9 +402,7 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -506,7 +478,6 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -537,7 +508,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lestrrat-go/jwx v0.9.0/go.mod h1:iEoxlYfZjvoGpuWwxUz+eR5e6KTJGsaRcy/YNA/UnBk= -github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a h1:weJVJJRzAJBFRlAiJQROKQs8oC9vOxvm4rZmBBk0ONw= @@ -550,7 +520,6 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= @@ -578,14 +547,12 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f h1:2+myh5ml7lgEU/51gbeLHfKGNfgEQQIWrlbdaOsidbQ= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= -github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -596,7 +563,6 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -640,7 +606,6 @@ github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v0.1.1 h1:GlxAyO6x8rfZYN9Tt0Kti5a/cP41iuiO2yYT0IJGY8Y= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700 h1:eNUVfm/RFLIi1G7flU5/ZRTHvd4kcVuzfRnL6OFlzCI= github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= github.com/opencontainers/selinux v1.8.0 h1:+77ba4ar4jsCbL1GLbFL8fFM57w6suPfSS9PDLDY7KM= @@ -665,7 +630,6 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.3.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= -github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= @@ -684,7 +648,6 @@ github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021 h1:0XM1XL/OFFJjXsYXlG30spTkV/E9+gmd5GD1w2HE8xM= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/pquerna/cachecontrol v0.0.0-20180306154005-525d0eb5f91d h1:7gXyC293Lsm2YWgQ+0uaAFFFDO82ruiQSwc3ua+Vtlc= github.com/pquerna/cachecontrol v0.0.0-20180306154005-525d0eb5f91d/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= @@ -721,7 +684,6 @@ github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDa github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/prom2json v1.1.0 h1:/fEL2DK7EEyHVeGMG4TV+gSS9Sw53yYKt//QRL0IIYE= github.com/prometheus/prom2json v1.1.0/go.mod h1:v7OY1795b9fEUZgq4UU2+15YjRv0LfpxKejIQCy3L7o= github.com/prometheus/prom2json v1.2.2 h1:6Byhwq8biAw6H7IXky/XEtys7Uthw0NekOfKDTO8mFI= github.com/prometheus/prom2json v1.2.2/go.mod h1:yIcXOj/TLPdtZ12qRyhswPnu+02sfDoqatDjj0WGSvo= @@ -735,7 +697,6 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= @@ -758,14 +719,12 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.3/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= @@ -790,6 +749,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tetratelabs/getenvoy-package v0.0.0-20190730071641-da31aed4333e h1:P03rR9jXeD2ilkYVsRlDz/EyS2rTg5Nko8T/LzPri5k= github.com/tetratelabs/getenvoy-package v0.0.0-20190730071641-da31aed4333e/go.mod h1:IrGJ2YZz3+qia1dEU9GFg3QieuMUUwiJf5tjG8uhogg= @@ -816,7 +777,6 @@ github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= @@ -876,7 +836,6 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d h1:9FCpayM9Egr1baVnV1SX0H87m+XB0B8S0hAMi99X/3U= golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -1026,7 +985,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0= gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= @@ -1039,7 +997,6 @@ google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEn google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0 h1:yzlyyDW/J0w8yNFJIhiAJy4kq74S+1DOLdawELNxFMA= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1078,12 +1035,10 @@ google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= -gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1095,7 +1050,6 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/d4l3k/messagediff.v1 v1.2.1 h1:70AthpjunwzUiarMHyED52mj9UwtAnE89l1Gmrt3EU0= gopkg.in/d4l3k/messagediff.v1 v1.2.1/go.mod h1:EUzikiKadqXWcD1AzJLagx0j/BeeWGtn++04Xniyg44= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -1116,6 +1070,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1184,12 +1140,9 @@ rsc.io/letsencrypt v0.0.3 h1:H7xDfhkaFFSYEJlKeq38RwX2jYcnTeHuDQyT+mMNMwM= rsc.io/letsencrypt v0.0.3/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY= sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg= sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns= -sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca h1:6dsH6AYQWbyZmtttJNe8Gq1cXOeS1BdV3eW37zHilAQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA= -sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= sigs.k8s.io/testing_frameworks v0.1.2/go.mod h1:ToQrwSC3s8Xf/lADdZp3Mktcql9CG0UAmdJG9th5i0w= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/images/extension-builders/rust/entrypoint.sh b/images/extension-builders/entrypoint.sh similarity index 100% rename from images/extension-builders/rust/entrypoint.sh rename to images/extension-builders/entrypoint.sh diff --git a/images/extension-builders/rust/Dockerfile b/images/extension-builders/rust/Dockerfile index 52fddf0f..e71d0166 100644 --- a/images/extension-builders/rust/Dockerfile +++ b/images/extension-builders/rust/Dockerfile @@ -24,6 +24,6 @@ RUN rustup target add wasm32-unknown-unknown ENV CARGO_HOME= COPY ./entrypoint.sh /usr/local/getenvoy/extension/builder/entrypoint.sh -COPY ./commands.sh /usr/local/getenvoy/extension/builder/commands.sh +COPY ./rust/commands.sh /usr/local/getenvoy/extension/builder/commands.sh ENTRYPOINT ["/usr/local/getenvoy/extension/builder/entrypoint.sh"] CMD ["--help"] diff --git a/images/extension-builders/tinygo/Dockerfile b/images/extension-builders/tinygo/Dockerfile new file mode 100644 index 00000000..c9c7611e --- /dev/null +++ b/images/extension-builders/tinygo/Dockerfile @@ -0,0 +1,28 @@ +# Copyright 2020 Tetrate +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Builder image for Envoy Wasm extensions written in Go. +# + +FROM tinygo/tinygo:0.17.0 + +ENV GOCACHE=/source/build/.gocache +ENV GOMODCACHE=/source/build/.gomodcache +ENV XDG_CACHE_HOME=/source/build/.cache + +COPY ./entrypoint.sh /usr/local/getenvoy/extension/builder/entrypoint.sh +COPY ./tinygo/commands.sh /usr/local/getenvoy/extension/builder/commands.sh +ENTRYPOINT ["/usr/local/getenvoy/extension/builder/entrypoint.sh"] +CMD ["--help"] diff --git a/images/extension-builders/tinygo/commands.sh b/images/extension-builders/tinygo/commands.sh new file mode 100755 index 00000000..f38e1273 --- /dev/null +++ b/images/extension-builders/tinygo/commands.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright 2020 Tetrate +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +extension_build() { + tinygo build -o "$1" -scheduler=none -target wasi main.go + # This is necessary since the created go caches are with read-only permission, + # and without this, the host user cannot delete the build directory with "rm -rf". + chmod -R u+rw "${GOMODCACHE}" +} + +extension_test() { + go test -tags=proxytest -v ./... + # This is necessary since the created go caches are with read-only permission, + # and without this, the host user cannot delete the build directory with "rm -rf". + chmod -R u+rw "${GOMODCACHE}" +} + +extension_clean() { + rm -rf build +} diff --git a/pkg/cmd/extension/init/cmd.go b/pkg/cmd/extension/init/cmd.go index 53dded25..0b617b8c 100644 --- a/pkg/cmd/extension/init/cmd.go +++ b/pkg/cmd/extension/init/cmd.go @@ -35,6 +35,7 @@ var ( // programming languages supported by the `init` command. supportedLanguages = options{ {Value: extension.LanguageRust.String(), DisplayText: "Rust"}, + {Value: extension.LanguageTinyGo.String(), DisplayText: "TinyGo"}, } // Envoy release the extension templates have been developed against. // @@ -54,7 +55,7 @@ var ( // 1. according to command-line options // 2. otherwise, according to the example-specific configuration (.getenvoy/extension/examples//example.yaml) // 3. otherwise, according to extension descriptor (.getenvoy/extension/extension.yaml) - supportedEnvoyVersion = "standard:1.17.0" + defaultSupportedEnvoyVersion = "standard:1.17.0" ) // NewCmd returns a command that generates the initial set of files @@ -98,7 +99,7 @@ Scaffold a new Envoy extension in a language of your choice.`, return err } descriptor.Name = params.Name.Value - descriptor.Runtime.Envoy.Version = supportedEnvoyVersion + descriptor.Runtime.Envoy.Version = defaultSupportedEnvoyVersion outputDir, err = scaffold.NormalizeOutputPath(params.OutputDir.Value) if err != nil { diff --git a/pkg/cmd/extension/run/cmd_test.go b/pkg/cmd/extension/run/cmd_test.go index e7c9061f..8f9e5812 100644 --- a/pkg/cmd/extension/run/cmd_test.go +++ b/pkg/cmd/extension/run/cmd_test.go @@ -23,28 +23,20 @@ import ( "path/filepath" "strings" + "github.com/Masterminds/semver" + "github.com/ghodss/yaml" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - + "github.com/otiai10/copy" "github.com/pkg/errors" - "github.com/spf13/cobra" - "github.com/ghodss/yaml" - - "github.com/otiai10/copy" - - "github.com/Masterminds/semver" - "github.com/tetratelabs/getenvoy/pkg/cmd" "github.com/tetratelabs/getenvoy/pkg/manifest" - "github.com/tetratelabs/getenvoy/pkg/types" - testcontext "github.com/tetratelabs/getenvoy/pkg/test/cmd/extension" - - cmdutil "github.com/tetratelabs/getenvoy/pkg/util/cmd" - manifesttest "github.com/tetratelabs/getenvoy/pkg/test/manifest" + "github.com/tetratelabs/getenvoy/pkg/types" + cmdutil "github.com/tetratelabs/getenvoy/pkg/util/cmd" ) //nolint:lll diff --git a/pkg/extension/workspace/config/extension/helpers.go b/pkg/extension/workspace/config/extension/helpers.go index d31b3e49..64b75a0f 100644 --- a/pkg/extension/workspace/config/extension/helpers.go +++ b/pkg/extension/workspace/config/extension/helpers.go @@ -88,7 +88,7 @@ func (languages languages) Index() map[string]Language { var ( // Languages is a list of valid programming languages. - Languages = languages{LanguageRust} + Languages = languages{LanguageRust, LanguageTinyGo} languageIndex = Languages.Index() ) diff --git a/pkg/extension/workspace/config/extension/types.go b/pkg/extension/workspace/config/extension/types.go index b30c7a3d..88c71ff8 100644 --- a/pkg/extension/workspace/config/extension/types.go +++ b/pkg/extension/workspace/config/extension/types.go @@ -47,8 +47,10 @@ func (l Language) String() string { } const ( - // LanguageRust represens a Rust programming language. + // LanguageRust represents a Rust programming language. LanguageRust Language = "rust" + // LanguageTinyGo represents a TinyGo programming language. + LanguageTinyGo Language = "tinygo" ) // Descriptor represents an extension created by getenvoy toolkit. diff --git a/pkg/extension/workspace/toolchain/builtin/default_config.go b/pkg/extension/workspace/toolchain/builtin/default_config.go index be468385..65a67ffd 100644 --- a/pkg/extension/workspace/toolchain/builtin/default_config.go +++ b/pkg/extension/workspace/toolchain/builtin/default_config.go @@ -36,7 +36,8 @@ var ( return version.Build.Version }() // defaultRustBuildImage represents a full name of the default Rust builder image in a Docker registry. - defaultRustBuildImage = dockerutil.ImageName{Org: defaultBuildImageOrg, Name: "extension-rust-builder", Tag: defaultBuildImageTag}.String() + defaultRustBuildImage = dockerutil.ImageName{Org: defaultBuildImageOrg, Name: "extension-rust-builder", Tag: defaultBuildImageTag}.String() + defaultTinyGoBuildImage = dockerutil.ImageName{Org: defaultBuildImageOrg, Name: "extension-tinygo-builder", Tag: defaultBuildImageTag}.String() ) // defaultConfigFor returns a default toolchain config for a given extension. @@ -57,6 +58,8 @@ func defaultBuildImageFor(language extensionconfig.Language) string { switch language { case extensionconfig.LanguageRust: return defaultRustBuildImage + case extensionconfig.LanguageTinyGo: + return defaultTinyGoBuildImage default: // must be caught by unit tests panic(errors.Errorf("failed to determine default build image for unsupported programming language %q", language)) @@ -69,6 +72,8 @@ func defaultOutputPathFor(language extensionconfig.Language) string { case extensionconfig.LanguageRust: // keep *.wasm file inside Cargo build dir (to be cleaned up automatically) return "target/getenvoy/extension.wasm" + case extensionconfig.LanguageTinyGo: + return "build/extension.wasm" default: // must be caught by unit tests panic(errors.Errorf("failed to determine default output path for unsupported programming language %q", language)) diff --git a/pkg/extension/workspace/toolchain/builtin/default_config_test.go b/pkg/extension/workspace/toolchain/builtin/default_config_test.go index aab2f20b..3ce88c65 100644 --- a/pkg/extension/workspace/toolchain/builtin/default_config_test.go +++ b/pkg/extension/workspace/toolchain/builtin/default_config_test.go @@ -18,11 +18,10 @@ import ( "fmt" "io/ioutil" - "github.com/pkg/errors" - . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" + "github.com/pkg/errors" "github.com/tetratelabs/getenvoy/pkg/extension/workspace/config" "github.com/tetratelabs/getenvoy/pkg/extension/workspace/config/extension" diff --git a/pkg/extension/workspace/toolchain/builtin/example_config_test.go b/pkg/extension/workspace/toolchain/builtin/example_config_test.go index 93d61eed..c5c9d7d7 100644 --- a/pkg/extension/workspace/toolchain/builtin/example_config_test.go +++ b/pkg/extension/workspace/toolchain/builtin/example_config_test.go @@ -21,12 +21,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" - - . "github.com/tetratelabs/getenvoy/pkg/extension/workspace/toolchain/builtin" - "github.com/pkg/errors" "github.com/tetratelabs/getenvoy/pkg/extension/workspace/config/extension" + . "github.com/tetratelabs/getenvoy/pkg/extension/workspace/toolchain/builtin" ) var _ = Describe("ExampleConfig()", func() { diff --git a/pkg/extension/workspace/toolchain/builtin/testdata/default_config/tinygo.toolchain.yaml b/pkg/extension/workspace/toolchain/builtin/testdata/default_config/tinygo.toolchain.yaml new file mode 100644 index 00000000..6e991355 --- /dev/null +++ b/pkg/extension/workspace/toolchain/builtin/testdata/default_config/tinygo.toolchain.yaml @@ -0,0 +1,6 @@ +kind: BuiltinToolchain +container: + image: getenvoy/extension-tinygo-builder:latest +build: + output: + wasmFile: build/extension.wasm diff --git a/pkg/extension/workspace/toolchain/builtin/testdata/example_config/tinygo.toolchain.yaml b/pkg/extension/workspace/toolchain/builtin/testdata/example_config/tinygo.toolchain.yaml new file mode 100644 index 00000000..d9f49164 --- /dev/null +++ b/pkg/extension/workspace/toolchain/builtin/testdata/example_config/tinygo.toolchain.yaml @@ -0,0 +1,56 @@ +# +# Configuration for the built-in toolchain. +# +kind: BuiltinToolchain + +# +# Configuration of the default build container. +# + +## container: +## # Builder image. +## image: getenvoy/extension-tinygo-builder:latest +## # Docker cli options. +## options: [] + +# +# Configuration of the 'build' command. +# +# If omitted, configuration of the default build container will be used instead. +# + +## build: +## container: +## # Builder image. +## image: getenvoy/extension-tinygo-builder:latest +## # Docker cli options. +## options: [] +## output: +## # Output *.wasm file. +## wasmFile: build/extension.wasm + +# +# Configuration of the 'test' command. +# +# If omitted, configuration of the default build container will be used instead. +# + +## test: +## container: +## # Builder image. +## image: getenvoy/extension-tinygo-builder:latest +## # Docker cli options. +## options: [] + +# +# Configuration of the 'clean' command. +# +# If omitted, configuration of the default build container will be used instead. +# + +## clean: +## container: +## # Builder image. +## image: getenvoy/extension-tinygo-builder:latest +## # Docker cli options. +## options: [] diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index aab68c92..74d629d2 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -58,3 +58,10 @@ var _ = AfterEach(func() { Expect(os.RemoveAll(tempDir)).To(Succeed()) } }) + +func CleanUpExtensionDir(dir string) { + Expect(os.Chdir(dir)).To(Succeed()) + clean := GetEnvoy("extension clean") + _, _, err := clean.Exec() + Expect(err).To(Succeed()) +} diff --git a/test/e2e/getenvoy_extension_build_test.go b/test/e2e/getenvoy_extension_build_test.go index 9719c9c1..f5385789 100644 --- a/test/e2e/getenvoy_extension_build_test.go +++ b/test/e2e/getenvoy_extension_build_test.go @@ -22,10 +22,9 @@ import ( . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" - e2e "github.com/tetratelabs/getenvoy/test/e2e/util" - workspaces "github.com/tetratelabs/getenvoy/pkg/extension/workspace" toolchains "github.com/tetratelabs/getenvoy/pkg/extension/workspace/toolchain" + e2e "github.com/tetratelabs/getenvoy/test/e2e/util" ) var _ = Describe("getenvoy extension build", func() { @@ -46,6 +45,7 @@ var _ = Describe("getenvoy extension build", func() { func(given testCase) { By("choosing the output directory") outputDir := filepath.Join(tempDir, "new") + defer CleanUpExtensionDir(outputDir) By("running `extension init` command") _, _, err := GetEnvoy("extension init"). diff --git a/test/e2e/getenvoy_extension_examples_test.go b/test/e2e/getenvoy_extension_examples_test.go index 41cb8cc2..56b14069 100644 --- a/test/e2e/getenvoy_extension_examples_test.go +++ b/test/e2e/getenvoy_extension_examples_test.go @@ -43,6 +43,7 @@ var _ = Describe("getenvoy extension examples", func() { func(given testCase) { By("choosing the output directory") outputDir := filepath.Join(tempDir, "new") + defer CleanUpExtensionDir(outputDir) By("running `extension init` command") _, _, err := GetEnvoy("extension init"). diff --git a/test/e2e/getenvoy_extension_init_test.go b/test/e2e/getenvoy_extension_init_test.go index c37bfc4d..0dd4e0f7 100644 --- a/test/e2e/getenvoy_extension_init_test.go +++ b/test/e2e/getenvoy_extension_init_test.go @@ -22,9 +22,8 @@ import ( . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" - e2e "github.com/tetratelabs/getenvoy/test/e2e/util" - workspaces "github.com/tetratelabs/getenvoy/pkg/extension/workspace" + e2e "github.com/tetratelabs/getenvoy/test/e2e/util" ) var _ = Describe("getenvoy extension init", func() { @@ -84,6 +83,7 @@ var _ = Describe("getenvoy extension init", func() { func(given testCase) { By("choosing the output directory") outputDir := tempDir + defer CleanUpExtensionDir(outputDir) By("changing to the output directory") err := os.Chdir(outputDir) diff --git a/test/e2e/getenvoy_extension_push_test.go b/test/e2e/getenvoy_extension_push_test.go index d51ff46e..a39ee30a 100644 --- a/test/e2e/getenvoy_extension_push_test.go +++ b/test/e2e/getenvoy_extension_push_test.go @@ -104,6 +104,7 @@ var _ = Describe("getenvoy extension push", func() { func(given testCase) { By("choosing the output directory") outputDir := filepath.Join(tempDir, "new") + defer CleanUpExtensionDir(outputDir) By("running `extension init` command") _, _, err := GetEnvoy("extension init"). diff --git a/test/e2e/getenvoy_extension_run_test.go b/test/e2e/getenvoy_extension_run_test.go index ef5c0d33..dc93de46 100644 --- a/test/e2e/getenvoy_extension_run_test.go +++ b/test/e2e/getenvoy_extension_run_test.go @@ -99,6 +99,7 @@ var _ = Describe("getenvoy extension run", func() { func(given testCase) { By("choosing the output directory") outputDir := filepath.Join(tempDir, "extension") + defer CleanUpExtensionDir(outputDir) By("running `extension init` command") _, _, err := GetEnvoy("extension init"). @@ -114,7 +115,7 @@ var _ = Describe("getenvoy extension run", func() { Expect(err).NotTo(HaveOccurred()) By("running `extension run` command") - _, stderr, cancel, errs := GetEnvoy("extension run"). + _, stderr, cancel, errs := GetEnvoy("extension run --envoy-options '-l trace'"). Args(e2e.Env.GetBuiltinContainerOptions()...). Start() @@ -135,6 +136,7 @@ var _ = Describe("getenvoy extension run", func() { // fail the test if `getenvoy extension run` exits with an error or unexpectedly go func() { + defer GinkgoRecover() select { case e := <-errs: Expect(e).NotTo(HaveOccurred(), "getenvoy command exited unexpectedly") diff --git a/test/e2e/getenvoy_extension_test_test.go b/test/e2e/getenvoy_extension_test_test.go index 5cc1f2c8..9bdc2ea5 100644 --- a/test/e2e/getenvoy_extension_test_test.go +++ b/test/e2e/getenvoy_extension_test_test.go @@ -43,6 +43,7 @@ var _ = Describe("getenvoy extension test", func() { func(given testCase) { By("choosing the output directory") outputDir := filepath.Join(tempDir, "new") + defer CleanUpExtensionDir(outputDir) By("running `extension init` command") _, _, err := GetEnvoy("extension init").