Skip to content

Commit 5c46136

Browse files
authored
Switch extension config file based on languages (#125)
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent aef7e79 commit 5c46136

File tree

42 files changed

+486
-67
lines changed

Some content is hidden

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

42 files changed

+486
-67
lines changed

data/example/init/templates/envoy.access_loggers/default/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| ----------------- | ------------------------ | ----------------------------------------------------------------------- |
77
| `example.yaml` | `Example` descriptor | Describes runtime requirements, e.g. a specific version of `Envoy` |
88
| `envoy.tmpl.yaml` | `Envoy` bootstrap config | Provides `Envoy` config that demoes extension in action |
9-
| `extension.json` | `Extension` config | Provides configuration for extension itself |
9+
| `${EXTENSION_CONFIG_FILE_NAME}` | `Extension` config | Provides configuration for extension itself |
1010

1111
## Components
1212

data/example/init/templates/envoy.filters.http/default/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| ----------------- | ------------------------ | ----------------------------------------------------------------------- |
77
| `example.yaml` | `Example` descriptor | Describes runtime requirements, e.g. a specific version of `Envoy` |
88
| `envoy.tmpl.yaml` | `Envoy` bootstrap config | Provides `Envoy` config that demoes extension in action |
9-
| `extension.json` | `Extension` config | Provides configuration for extension itself |
9+
| `${EXTENSION_CONFIG_FILE_NAME}` | `Extension` config | Provides configuration for extension itself |
1010

1111
## Components
1212

data/example/init/templates/envoy.filters.http/default/extension.json

Whitespace-only changes.

data/example/init/templates/envoy.filters.network/default/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| ----------------- | ------------------------ | ----------------------------------------------------------------------- |
77
| `example.yaml` | `Example` descriptor | Describes runtime requirements, e.g. a specific version of `Envoy` |
88
| `envoy.tmpl.yaml` | `Envoy` bootstrap config | Provides `Envoy` config that demoes extension in action |
9-
| `extension.json` | `Extension` config | Provides configuration for extension itself |
9+
| `${EXTENSION_CONFIG_FILE_NAME}` | `Extension` config | Provides configuration for extension itself |
1010

1111
## Components
1212

data/example/init/templates/envoy.filters.network/default/extension.json

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# We recommend to use json as the configuration format,
2+
# however, some languages (e.g. TinyGo) does not support ready-to-use json library as of now.
3+
# As a temporary alternative, we use ".txt" format.

data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go 1.15
44

55
require (
66
github.com/stretchr/testify v1.6.1
7-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0
7+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1
88
)

data/extension/init/templates/tinygo/envoy.access_loggers/default/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
55
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
66
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
77
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
8-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0=
9-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
8+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1 h1:m8O4nWCyb+8VlAxVxppobGNnC1N9CoAQBmMfRjTq/hU=
9+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
1010
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1212
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

data/extension/init/templates/tinygo/envoy.access_loggers/default/main.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package main
22

33
import (
4+
"bufio"
5+
"bytes"
6+
"strings"
7+
48
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
59
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
610
)
@@ -28,7 +32,20 @@ func (l *accessLogger) OnPluginStart(configurationSize int) types.OnPluginStartS
2832
proxywasm.LogCriticalf("failed to load config: %v", err)
2933
return types.OnPluginStartStatusFailed
3034
}
31-
l.logMessage = string(data)
35+
36+
// Ignore comment lines starting with "#" in the configuration.
37+
// Note that we recommend to use json as the configuration format,
38+
// however, some languages (e.g. TinyGo) does not support ready-to-use json library as of now.
39+
// As a temporary alternative, we use ".txt" format for the plugin configuration.
40+
var lines []string
41+
scanner := bufio.NewScanner(bytes.NewReader(data))
42+
for scanner.Scan() {
43+
line := scanner.Text()
44+
if !strings.HasPrefix(line, "#") {
45+
lines = append(lines, line)
46+
}
47+
}
48+
l.logMessage = strings.Join(lines, "\n")
3249
return types.OnPluginStartStatusOK
3350
}
3451

data/extension/init/templates/tinygo/envoy.access_loggers/default/main_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
func TestAccessLogger_OnLog(t *testing.T) {
13-
configuration := `this is my log message`
13+
configuration := `# this is comment line, and should be ignored.
14+
this is my log message`
1415
opt := proxytest.NewEmulatorOption().
1516
WithNewRootContext(newAccessLogger).
1617
WithPluginConfiguration([]byte(configuration))

data/extension/init/templates/tinygo/envoy.filters.http/default/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go 1.15
44

55
require (
66
github.com/stretchr/testify v1.6.1
7-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0
7+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1
88
)

data/extension/init/templates/tinygo/envoy.filters.http/default/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
55
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
66
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
77
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
8-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0=
9-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
8+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1 h1:m8O4nWCyb+8VlAxVxppobGNnC1N9CoAQBmMfRjTq/hU=
9+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
1010
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1212
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

data/extension/init/templates/tinygo/envoy.filters.http/default/main.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,21 @@ func (ctx *rootContext) OnPluginStart(configurationSize int) types.OnPluginStart
4242
return types.OnPluginStartStatusFailed
4343
}
4444

45-
// Each line in the configuration is in the "KEY=VALUE" format.
45+
// Read the configuration.
46+
// Note that we recommend to use json as the configuration format,
47+
// however, some languages (e.g. TinyGo) does not support ready-to-use json library as of now.
48+
// As a temporary alternative, we use ".txt" format for the plugin configuration.
4649
scanner := bufio.NewScanner(bytes.NewReader(data))
4750
for scanner.Scan() {
48-
tokens := strings.Split(scanner.Text(), "=")
49-
ctx.additionalHeaders[tokens[0]] = tokens[1]
51+
// Ignore comment lines starting with "#".
52+
line := scanner.Text()
53+
if strings.HasPrefix(line, "#") {
54+
continue
55+
}
56+
// Each line in the configuration is in the "KEY=VALUE" format.
57+
if tokens := strings.Split(scanner.Text(), "="); len(tokens) == 2 {
58+
ctx.additionalHeaders[tokens[0]] = tokens[1]
59+
}
5060
}
5161
return types.OnPluginStartStatusOK
5262
}

data/extension/init/templates/tinygo/envoy.filters.http/default/main_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
func TestHttpFilter_OnHttpRequestHeaders(t *testing.T) {
13-
configuration := `HELLO=WORLD
13+
configuration := `# this is comment line, and should be ignored.
14+
HELLO=WORLD
1415
ENVOY=ISTIO`
1516
opt := proxytest.NewEmulatorOption().
1617
WithNewRootContext(newRootContext).

data/extension/init/templates/tinygo/envoy.filters.network/default/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ go 1.15
44

55
require (
66
github.com/stretchr/testify v1.6.1
7-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0
7+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1
88
)

data/extension/init/templates/tinygo/envoy.filters.network/default/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
55
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
66
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
77
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
8-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0 h1:9CUaOB8CZInfG/VRCjOEOkzS4JLkri/weqogwmrl2a0=
9-
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.0/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
8+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1 h1:m8O4nWCyb+8VlAxVxppobGNnC1N9CoAQBmMfRjTq/hU=
9+
github.com/tetratelabs/proxy-wasm-go-sdk v0.1.1/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
1010
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1111
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1212
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=

data/extension/init/templates/tinygo/envoy.filters.network/default/main.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package main
22

33
import (
4+
"bufio"
5+
"bytes"
6+
"strings"
7+
48
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
59
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
610
)
@@ -34,7 +38,20 @@ func (ctx *rootContext) OnPluginStart(configurationSize int) types.OnPluginStart
3438
proxywasm.LogCriticalf("failed to load config: %v", err)
3539
return types.OnPluginStartStatusFailed
3640
}
37-
ctx.config = string(data)
41+
42+
// Ignore comment lines starting with "#" in the extension.txt.
43+
// Note that we recommend to use json as the configuration format,
44+
// however, some languages (e.g. TinyGo) does not support ready-to-use json library as of now.
45+
// As a temporary alternative, we use ".txt" format for the plugin configuration.
46+
var lines []string
47+
scanner := bufio.NewScanner(bytes.NewReader(data))
48+
for scanner.Scan() {
49+
line := scanner.Text()
50+
if !strings.HasPrefix(line, "#") {
51+
lines = append(lines, line)
52+
}
53+
}
54+
ctx.config = strings.Join(lines, "\n")
3855
return types.OnPluginStartStatusOK
3956
}
4057

data/extension/init/templates/tinygo/envoy.filters.network/default/main_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
)
1010

1111
func TestNetworkFilter_OnNewConnection(t *testing.T) {
12-
configuration := `message: this is new connection!`
12+
configuration := `# this is comment line, and should be ignored.
13+
message: this is new connection!`
1314
opt := proxytest.NewEmulatorOption().
1415
WithPluginConfiguration([]byte(configuration)).
1516
WithNewRootContext(newRootContext)
@@ -28,7 +29,7 @@ func TestNetworkFilter_OnNewConnection(t *testing.T) {
2829

2930
// Retrieve logs emitted to Envoy.
3031
logs := host.GetLogs(types.LogLevelInfo)
31-
require.Contains(t, logs, configuration)
32+
require.Contains(t, logs, "message: this is new connection!")
3233
}
3334

3435
func TestNetworkFilter_counter(t *testing.T) {

pkg/cmd/extension/example/cmd_add_test.go

+52-2
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,17 @@ Run 'getenvoy extension examples add --help' for usage.
131131
Done!
132132
`))
133133
By("verifying file system")
134-
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/README.md")).To(BeAnExistingFile())
134+
readmePath := filepath.Join(tempDir, ".getenvoy/extension/examples/default/README.md")
135+
Expect(readmePath).To(BeAnExistingFile())
135136
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/envoy.tmpl.yaml")).To(BeAnExistingFile())
136137
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/example.yaml")).To(BeAnExistingFile())
137138
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/extension.json")).To(BeAnExistingFile())
139+
// Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.json".
140+
data, err := ioutil.ReadFile(readmePath)
141+
Expect(err).ToNot(HaveOccurred())
142+
readme := string(data)
143+
Expect(readme).To(ContainSubstring("extension.json"))
144+
Expect(readme).NotTo(ContainSubstring("EXTENSION_CONFIG_FILE_NAME"))
138145
})
139146

140147
It("should create example setup with a given --name", func() {
@@ -160,10 +167,17 @@ Done!
160167
Done!
161168
`))
162169
By("verifying file system")
163-
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/advanced/README.md")).To(BeAnExistingFile())
170+
readmePath := filepath.Join(tempDir, ".getenvoy/extension/examples/advanced/README.md")
171+
Expect(readmePath).To(BeAnExistingFile())
164172
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/advanced/envoy.tmpl.yaml")).To(BeAnExistingFile())
165173
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/advanced/example.yaml")).To(BeAnExistingFile())
166174
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/advanced/extension.json")).To(BeAnExistingFile())
175+
// Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.json".
176+
data, err := ioutil.ReadFile(readmePath)
177+
Expect(err).ToNot(HaveOccurred())
178+
readme := string(data)
179+
Expect(readme).To(ContainSubstring("extension.json"))
180+
Expect(readme).NotTo(ContainSubstring("${EXTENSION_CONFIG_FILE_NAME}"))
167181
})
168182

169183
It("should fail if such example already exists", func() {
@@ -186,6 +200,42 @@ Done!
186200
Run 'getenvoy extension examples add --help' for usage.
187201
`))
188202
})
203+
204+
It("should create 'default' example setup when no --name is omitted for TinyGo", func() {
205+
By("simulating a workspace without any examples")
206+
err := copy.Copy("testdata/workspace4", tempDir)
207+
Expect(err).NotTo(HaveOccurred())
208+
209+
By("changing to a workspace dir")
210+
chdir(tempDir)
211+
212+
By("running command")
213+
c.SetArgs([]string{"extension", "examples", "add"})
214+
err = cmdutil.Execute(c)
215+
Expect(err).ToNot(HaveOccurred())
216+
217+
By("verifying command output")
218+
Expect(stdout.String()).To(BeEmpty())
219+
Expect(stderr.String()).To(Equal(`Scaffolding a new example setup:
220+
* .getenvoy/extension/examples/default/README.md
221+
* .getenvoy/extension/examples/default/envoy.tmpl.yaml
222+
* .getenvoy/extension/examples/default/example.yaml
223+
* .getenvoy/extension/examples/default/extension.txt
224+
Done!
225+
`))
226+
By("verifying file system")
227+
readmePath := filepath.Join(tempDir, ".getenvoy/extension/examples/default/README.md")
228+
Expect(readmePath).To(BeAnExistingFile())
229+
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/envoy.tmpl.yaml")).To(BeAnExistingFile())
230+
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/example.yaml")).To(BeAnExistingFile())
231+
Expect(filepath.Join(tempDir, ".getenvoy/extension/examples/default/extension.txt")).To(BeAnExistingFile())
232+
// Check README substitution: ${EXTENSION_CONFIG_FILE_NAME} must be replaced with "extension.txt".
233+
data, err := ioutil.ReadFile(readmePath)
234+
Expect(err).ToNot(HaveOccurred())
235+
readme := string(data)
236+
Expect(readme).To(ContainSubstring("extension.txt"))
237+
Expect(readme).NotTo(ContainSubstring("${EXTENSION_CONFIG_FILE_NAME}"))
238+
})
189239
})
190240

191241
Context("outside of a workspace directory", func() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Envoy Wasm extension created with getenvoy toolkit.
3+
#
4+
kind: Extension
5+
6+
name: me.filters.http.my_http_filter
7+
8+
category: envoy.filters.http
9+
language: tinygo
10+
11+
# Runtime the extension is being developed against.
12+
runtime:
13+
envoy:
14+
version: standard:1.17.0

pkg/cmd/extension/run/cmd_test.go

+37
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,43 @@ Run 'getenvoy extension run --help' for usage.
700700
Done!
701701
docker stderr
702702
envoy stderr
703+
`))
704+
705+
By("verifying Envoy config")
706+
bootstrap := envoyCaptured.readFileToJSON("envoy.tmpl.yaml")
707+
Expect(bootstrap).NotTo(BeEmpty())
708+
})
709+
710+
It("should create default example if missing for TinyGo", func() {
711+
By("simulating a workspace without 'default' example")
712+
tempDir, err := ioutil.TempDir("", "")
713+
Expect(err).NotTo(HaveOccurred())
714+
defer func() {
715+
Expect(os.RemoveAll(tempDir)).To(Succeed())
716+
}()
717+
err = copy.Copy("testdata/workspace_tinygo", tempDir)
718+
Expect(err).NotTo(HaveOccurred())
719+
720+
By("changing to a workspace dir")
721+
workspaceDir := chdir(tempDir)
722+
723+
By("running command")
724+
c.SetArgs([]string{"extension", "run"})
725+
err = cmdutil.Execute(c)
726+
Expect(err).ToNot(HaveOccurred())
727+
728+
By("verifying command output")
729+
Expect(stdout.String()).To(Equal(fmt.Sprintf(`%s/docker run -u 1001:1002 --rm -t -v %s:/source -w /source --init getenvoy/extension-tinygo-builder:latest build --output-file build/extension.wasm
730+
%s/builds/standard/1.17.0/%s/bin/envoy -c %s/envoy.tmpl.yaml
731+
`, dockerDir, workspaceDir, getenvoyHomeDir, platform, envoyCaptured.cwd())))
732+
Expect(stderr.String()).To(Equal(`Scaffolding a new example setup:
733+
* .getenvoy/extension/examples/default/README.md
734+
* .getenvoy/extension/examples/default/envoy.tmpl.yaml
735+
* .getenvoy/extension/examples/default/example.yaml
736+
* .getenvoy/extension/examples/default/extension.txt
737+
Done!
738+
docker stderr
739+
envoy stderr
703740
`))
704741

705742
By("verifying Envoy config")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Envoy Wasm extension created with getenvoy toolkit.
3+
#
4+
kind: Extension
5+
6+
name: mycompany.filters.http.mytest
7+
8+
category: envoy.filters.http
9+
language: tinygo
10+
11+
# Runtime the extension is being developed against.
12+
runtime:
13+
envoy:
14+
version: standard:1.17.0

pkg/extension/example/init/registry/global.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func globalRegistry() registry {
3535
}
3636

3737
// Get returns an example template registered in a global registry for a given
38-
// extension category and name.
39-
func Get(category extension.Category, name string) (*Entry, error) {
40-
return globalRegistry().Get(category, name)
38+
// extension category, name and language.
39+
func Get(descriptor *extension.Descriptor, name string) (*Entry, error) {
40+
return globalRegistry().Get(descriptor, name)
4141
}

0 commit comments

Comments
 (0)