Skip to content

Commit db99b4a

Browse files
committed
Fix permission, showcase config in access logger
Signed-off-by: Takeshi Yoneda <[email protected]>
1 parent b3c33e1 commit db99b4a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (l *accessLogger) OnLog() {
4040
return
4141
}
4242

43-
proxywasm.LogInfof("OnLog: :path = %s", hdr)
43+
proxywasm.LogInfof(":path = %s", hdr)
4444
proxywasm.LogInfof("message = %s", l.logMessage)
4545

4646
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,27 @@ import (
1010
)
1111

1212
func TestAccessLogger_OnLog(t *testing.T) {
13+
configuration := `this is my log message`
1314
opt := proxytest.NewEmulatorOption().
14-
WithNewRootContext(newAccessLogger)
15+
WithNewRootContext(newAccessLogger).
16+
WithPluginConfiguration([]byte(configuration))
17+
1518
host := proxytest.NewHostEmulator(opt)
1619
// Release the host emulation lock so that other test cases can insert their own host emulation.
1720
defer host.Done()
1821

22+
// Call OnPluginStart -> the message field of root context is configured.
23+
status := host.StartPlugin()
24+
// Check the status returned by OnPluginStart is OK.
25+
require.Equal(t, types.OnPluginStartStatusOK, status)
26+
1927
// Call OnLog with the given headers.
2028
host.CallOnLogForAccessLogger(types.Headers{
2129
{":path", "/this/is/path"},
2230
}, nil)
2331

2432
// Check the Envoy logs.
2533
logs := host.GetLogs(types.LogLevelInfo)
26-
require.Contains(t, logs, "OnLog: :path = /this/is/path")
34+
require.Contains(t, logs, ":path = /this/is/path")
35+
require.Contains(t, logs, "message = this is my log message")
2736
}

images/extension-builders/tinygo/commands.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ extension_build() {
1818
tinygo build -o "$1" -scheduler=none -target wasi main.go
1919
# This is necessary since the created go caches are with read-only permission,
2020
# and without this, the host user cannot delete the build directory with "rm -rf".
21-
chmod -R a+rw build/
21+
chmod -R u+rw build/
2222
}
2323

2424
extension_test() {
2525
go test -tags=proxytest -v ./...
2626
# This is necessary since the created go caches are with read-only permission,
2727
# and without this, the host user cannot delete the build directory with "rm -rf".
28-
chmod -R a+rw build/
28+
chmod -R u+rw build/
2929
}
3030

3131
extension_clean() {

0 commit comments

Comments
 (0)