Skip to content

Commit 40f2929

Browse files
paulyeo21Kwangu Paul Yeo
andauthored
Envoy custom logging format (#609)
* Add format field for virtual node and gateway * Allow json/text to be nullable * Use array of attribute structs for json format * Import local SDK and consume new models * Remove max length * Check in auto-generated file * Make functions void since no error possible * Add unit tests for conversion files * Use aws.String * Consume new SDK v1.44.79 * Dont download go modules directly * Cleanup tls test suite and add longer timeout * Skip tls cert validation failure test Co-authored-by: Kwangu Paul Yeo <[email protected]>
1 parent f9c5ea5 commit 40f2929

14 files changed

+337
-62
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ COPY go.mod go.sum ./
1010
# uncomment if using vendor
1111
# COPY ./vendor ./vendor
1212

13-
ENV GOPROXY=direct
1413
RUN go mod download
1514

1615
COPY . ./

apis/appmesh/v1beta2/virtualgateway_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ type VirtualGatewayFileAccessLog struct {
190190
// +kubebuilder:validation:MinLength=1
191191
// +kubebuilder:validation:MaxLength=255
192192
Path string `json:"path"`
193+
// Structured access log output format
194+
// +optional
195+
Format *LoggingFormat `json:"format,omitempty"`
193196
}
194197

195198
// VirtualGatewayAccessLog refers to https://docs.aws.amazon.com/app-mesh/latest/userguide/virtual_gateways.html

apis/appmesh/v1beta2/virtualnode_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,34 @@ type ServiceDiscovery struct {
347347
DNS *DNSServiceDiscovery `json:"dns,omitempty"`
348348
}
349349

350+
type JsonFormatRef struct {
351+
// The name of the field in the JSON object
352+
// +kubebuilder:validation:MinLength=1
353+
Key string `json:"key"`
354+
// The format string
355+
// +kubebuilder:validation:MinLength=1
356+
Value string `json:"value"`
357+
}
358+
359+
// Format specifies the structure of the access log output
360+
type LoggingFormat struct {
361+
// Output specified fields as a JSON object
362+
// +optional
363+
Json []*JsonFormatRef `json:"json,omitempty"`
364+
// Custom format string
365+
// +optional
366+
Text *string `json:"text,omitempty"`
367+
}
368+
350369
// FileAccessLog refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_FileAccessLog.html
351370
type FileAccessLog struct {
352371
// The file path to write access logs to.
353372
// +kubebuilder:validation:MinLength=1
354373
// +kubebuilder:validation:MaxLength=255
355374
Path string `json:"path"`
375+
// Structured access log output format
376+
// +optional
377+
Format *LoggingFormat `json:"format,omitempty"`
356378
}
357379

358380
// AccessLog refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_AccessLog.html

apis/appmesh/v1beta2/zz_generated.deepcopy.go

Lines changed: 58 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/appmesh.k8s.aws_virtualgateways.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,31 @@ spec:
514514
description: The file object to send virtual gateway access
515515
logs to.
516516
properties:
517+
format:
518+
description: Structured access log output format
519+
properties:
520+
json:
521+
description: Output specified fields as a JSON object
522+
items:
523+
properties:
524+
key:
525+
description: The name of the field in the JSON
526+
object
527+
minLength: 1
528+
type: string
529+
value:
530+
description: The format string
531+
minLength: 1
532+
type: string
533+
required:
534+
- key
535+
- value
536+
type: object
537+
type: array
538+
text:
539+
description: Custom format string
540+
type: string
541+
type: object
517542
path:
518543
description: The file path to write access logs to.
519544
maxLength: 255

config/crd/bases/appmesh.k8s.aws_virtualnodes.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,31 @@ spec:
890890
description: The file object to send virtual node access logs
891891
to.
892892
properties:
893+
format:
894+
description: Structured access log output format
895+
properties:
896+
json:
897+
description: Output specified fields as a JSON object
898+
items:
899+
properties:
900+
key:
901+
description: The name of the field in the JSON
902+
object
903+
minLength: 1
904+
type: string
905+
value:
906+
description: The format string
907+
minLength: 1
908+
type: string
909+
required:
910+
- key
911+
- value
912+
type: object
913+
type: array
914+
text:
915+
description: Custom format string
916+
type: string
917+
type: object
893918
path:
894919
description: The file path to write access logs to.
895920
maxLength: 255

config/helm/appmesh-controller/crds/crds.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,31 @@ spec:
13131313
file:
13141314
description: The file object to send virtual gateway access logs to.
13151315
properties:
1316+
format:
1317+
description: Structured access log output format
1318+
properties:
1319+
json:
1320+
description: Output specified fields as a JSON object
1321+
items:
1322+
properties:
1323+
key:
1324+
description: The name of the field in the JSON
1325+
object
1326+
minLength: 1
1327+
type: string
1328+
value:
1329+
description: The format string
1330+
minLength: 1
1331+
type: string
1332+
required:
1333+
- key
1334+
- value
1335+
type: object
1336+
type: array
1337+
text:
1338+
description: Custom format string
1339+
type: string
1340+
type: object
13161341
path:
13171342
description: The file path to write access logs to.
13181343
maxLength: 255
@@ -2206,6 +2231,31 @@ spec:
22062231
file:
22072232
description: The file object to send virtual node access logs to.
22082233
properties:
2234+
format:
2235+
description: Structured access log output format
2236+
properties:
2237+
json:
2238+
description: Output specified fields as a JSON object
2239+
items:
2240+
properties:
2241+
key:
2242+
description: The name of the field in the JSON
2243+
object
2244+
minLength: 1
2245+
type: string
2246+
value:
2247+
description: The format string
2248+
minLength: 1
2249+
type: string
2250+
required:
2251+
- key
2252+
- value
2253+
type: object
2254+
type: array
2255+
text:
2256+
description: Custom format string
2257+
type: string
2258+
type: object
22092259
path:
22102260
description: The file path to write access logs to.
22112261
maxLength: 255

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/aws/aws-app-mesh-controller-for-k8s
33
go 1.16
44

55
require (
6-
github.com/aws/aws-sdk-go v1.44.17
6+
github.com/aws/aws-sdk-go v1.44.79
77
github.com/docker/docker v20.10.17+incompatible // indirect
88
github.com/evanphx/json-patch v4.11.0+incompatible
99
github.com/garyburd/redigo v1.6.3 // indirect

0 commit comments

Comments
 (0)