-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
606 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package api | ||
|
||
type AccessLogServer struct { | ||
API string `json:"api" yaml:"api"` | ||
Kind string `json:"kind" yaml:"kind"` | ||
Metadata Metadata `json:"metadata" yaml:"metadata"` | ||
Spec AccessLogServerSpec `json:"spec" yaml:"spec"` | ||
} | ||
type AccessLogServerSpec struct { | ||
Address string `json:"address" yaml:"address"` | ||
Port int64 `json:"port" yaml:"port"` | ||
AdditionalRequestHeadersToLog []string `json:"additionalRequestHeadersToLog" yaml:"additionalRequestHeadersToLog"` | ||
AdditionalResponseHeadersToLog []string `json:"additionalResponseHeadersToLog" yaml:"additionalResponseHeadersToLog"` | ||
} |
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,82 @@ | ||
package envoy | ||
|
||
import ( | ||
core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" | ||
|
||
alf "github.com/envoyproxy/go-control-plane/envoy/config/accesslog/v3" | ||
api "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3" | ||
als "github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3" | ||
"github.com/envoyproxy/go-control-plane/pkg/wellknown" | ||
"github.com/golang/protobuf/ptypes" | ||
) | ||
|
||
type AccessLogServer struct{} | ||
|
||
func newAccessLogServer() *AccessLogServer { | ||
return &AccessLogServer{} | ||
} | ||
|
||
func (c *AccessLogServer) updateListenersWithAccessLogServer(cache *WorkQueueCache, params AccessLogServerParams) error { | ||
// update listener | ||
for listenerKey := range cache.listeners { | ||
ll := cache.listeners[listenerKey].(*api.Listener) | ||
for filterchainID := range ll.FilterChains { | ||
for filterID := range ll.FilterChains[filterchainID].Filters { | ||
// get manager | ||
manager, err := getManager((ll.FilterChains[filterchainID].Filters[filterID].ConfigType).(*api.Filter_TypedConfig)) | ||
if err != nil { | ||
return err | ||
} | ||
accessLogConfig, err := c.getAccessLoggerConfig(params) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
manager.AccessLog = accessLogConfig | ||
|
||
// update manager in cache | ||
pbst, err := ptypes.MarshalAny(&manager) | ||
if err != nil { | ||
return err | ||
} | ||
ll.FilterChains[filterchainID].Filters[filterID].ConfigType = &api.Filter_TypedConfig{ | ||
TypedConfig: pbst, | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *AccessLogServer) getAccessLoggerConfig(params AccessLogServerParams) ([]*alf.AccessLog, error) { | ||
if params.Name != "" { | ||
alsConfig := &als.HttpGrpcAccessLogConfig{ | ||
CommonConfig: &als.CommonGrpcAccessLogConfig{ | ||
TransportApiVersion: core.ApiVersion_V3, | ||
LogName: params.Name, | ||
GrpcService: &core.GrpcService{ | ||
TargetSpecifier: &core.GrpcService_EnvoyGrpc_{ | ||
EnvoyGrpc: &core.GrpcService_EnvoyGrpc{ | ||
ClusterName: params.Name, | ||
}, | ||
}, | ||
}, | ||
}, | ||
AdditionalRequestHeadersToLog: params.AdditionalRequestHeadersToLog, | ||
AdditionalResponseHeadersToLog: params.AdditionalResponseHeadersToLog, | ||
} | ||
alsConfigPbst, err := ptypes.MarshalAny(alsConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []*alf.AccessLog{{ | ||
Name: wellknown.HTTPGRPCAccessLog, | ||
ConfigType: &alf.AccessLog_TypedConfig{ | ||
TypedConfig: alsConfigPbst, | ||
}, | ||
}}, nil | ||
} | ||
return nil, nil | ||
} |
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,7 @@ | ||
api: proxy.in4it.io/v1 | ||
kind: accessLogServer | ||
metadata: | ||
name: accessLogServerExample | ||
spec: | ||
address: "localhost" | ||
port: 9001 |
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
Oops, something went wrong.