-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kuma-cp: add support for %KUMA_*% placeholders inside Envoy access lo…
…g format
- Loading branch information
Showing
7 changed files
with
338 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package accesslog | ||
|
||
import ( | ||
accesslog_config "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v2" | ||
accesslog_data "github.com/envoyproxy/go-control-plane/envoy/data/accesslog/v2" | ||
) | ||
|
||
// Placeholder represents a placeholder added to an access log format string | ||
// that must be resolved before configuring Envoy with that format string. | ||
// | ||
// E.g. %KUMA_SOURCE_SERVICE%, %KUMA_DESTINATION_SERVICE% and %KUMA_SOURCE_ADDRESS% | ||
// are examples of such placeholders. | ||
type Placeholder string | ||
|
||
func (f Placeholder) FormatHttpLogEntry(entry *accesslog_data.HTTPAccessLogEntry) (string, error) { | ||
return f.String(), nil | ||
} | ||
|
||
func (f Placeholder) FormatTcpLogEntry(entry *accesslog_data.TCPAccessLogEntry) (string, error) { | ||
return f.String(), nil | ||
} | ||
|
||
func (f Placeholder) ConfigureHttpLog(config *accesslog_config.HttpGrpcAccessLogConfig) error { | ||
// has no effect on HttpGrpcAccessLogConfig | ||
return nil | ||
} | ||
|
||
func (f Placeholder) ConfigureTcpLog(config *accesslog_config.TcpGrpcAccessLogConfig) error { | ||
// has no effect on TcpGrpcAccessLogConfig | ||
return nil | ||
} | ||
|
||
// String returns the canonical representation of this command operator. | ||
func (f Placeholder) String() string { | ||
return CommandOperatorDescriptor(f).String() | ||
} | ||
|
||
// Interpolate returns an access log fragment with all placeholders resolved. | ||
func (f Placeholder) Interpolate(context InterpolationContext) (AccessLogFragment, error) { | ||
value := context.Get(string(f)) | ||
return TextSpan(value), nil // turn placeholder into a text literal | ||
} |
Oops, something went wrong.