Skip to content

Commit 9dd5578

Browse files
committed
fix review comments
1 parent 1338f6e commit 9dd5578

File tree

8 files changed

+171
-80
lines changed

8 files changed

+171
-80
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,20 @@ type NginxLogging struct {
298298
// +kubebuilder:default=info
299299
AgentLevel *AgentLogLevel `json:"agentLevel,omitempty"`
300300

301-
// LogFormats defines custom log formats that can be used in access logs.
301+
// LogFormat defines custom log format that can be used in access logs.
302302
// Each log format must have a unique name.
303+
// https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
303304
//
304305
// +optional
305-
LogFormat *LogFormat `json:"logFormat,omitempty"`
306+
LogFormat *NginxLogFormat `json:"logFormat,omitempty"`
306307

307-
// AccessLogs defines the access log settings, including the log file path, format, and optional parameters.
308+
// AccessLog defines the access log settings, including the log file path and format name.
309+
// For now only path /dev/stdout can be used.
310+
// Path can be set to "OFF" to disable logging.
311+
// https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
308312
//
309313
// +optional
310-
AccessLog *AccessLog `json:"accessLog,omitempty"`
314+
AccessLog *NginxAccessLog `json:"accessLog,omitempty"`
311315
}
312316

313317
// NginxErrorLogLevel type defines the log level of error logs for NGINX.
@@ -363,15 +367,33 @@ const (
363367
AgentLogLevelFatal AgentLogLevel = "fatal"
364368
)
365369

366-
// LogFormat defines a custom log format for NGINX.
367-
type LogFormat struct {
368-
Name *string `json:"name,omitempty"`
370+
// NginxLogFormat defines a custom log format for NGINX.
371+
// https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
372+
type NginxLogFormat struct {
373+
// Name specifies the name of the log format.
374+
//
375+
// +optional
376+
Name *string `json:"name,omitempty"`
377+
378+
// Format specifies the log format string.
379+
//
380+
// +optional
369381
Format *string `json:"format,omitempty"`
370382
}
371383

372-
// AccessLog defines the configuration for an NGINX access log. For now only path /dev/stdout is used.
373-
type AccessLog struct {
374-
Path *string `json:"path,omitempty"`
384+
// NginxAccessLog defines the configuration for an NGINX access log.
385+
// For now only path /dev/stdout can be used.
386+
// Path can be set to "OFF" to disable logging.
387+
// https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
388+
type NginxAccessLog struct {
389+
// Path specifies the log file path. Or "OFF" to disable logging.
390+
//
391+
// +optional
392+
Path *string `json:"path,omitempty"`
393+
394+
// Format specifies the log format name to be used.
395+
//
396+
// +optional
375397
Format *string `json:"format,omitempty"`
376398
}
377399

apis/v1alpha2/zz_generated.deepcopy.go

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

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8017,12 +8017,18 @@ spec:
80178017
description: Logging defines logging related settings for NGINX.
80188018
properties:
80198019
accessLog:
8020-
description: AccessLogs defines the access log settings, including
8021-
the log file path, format, and optional parameters.
8020+
description: |-
8021+
AccessLog defines the access log settings, including the log file path and format name.
8022+
For now only path /dev/stdout can be used.
8023+
Path can be set to "OFF" to disable logging.
8024+
https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
80228025
properties:
80238026
format:
8027+
description: Format specifies the log format name to be used.
80248028
type: string
80258029
path:
8030+
description: Path specifies the log file path. Or "OFF" to
8031+
disable logging.
80268032
type: string
80278033
type: object
80288034
agentLevel:
@@ -8056,12 +8062,15 @@ spec:
80568062
type: string
80578063
logFormat:
80588064
description: |-
8059-
LogFormats defines custom log formats that can be used in access logs.
8065+
LogFormat defines custom log format that can be used in access logs.
80608066
Each log format must have a unique name.
8067+
https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
80618068
properties:
80628069
format:
8070+
description: Format specifies the log format string.
80638071
type: string
80648072
name:
8073+
description: Name specifies the name of the log format.
80658074
type: string
80668075
type: object
80678076
type: object

deploy/crds.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8604,12 +8604,18 @@ spec:
86048604
description: Logging defines logging related settings for NGINX.
86058605
properties:
86068606
accessLog:
8607-
description: AccessLogs defines the access log settings, including
8608-
the log file path, format, and optional parameters.
8607+
description: |-
8608+
AccessLog defines the access log settings, including the log file path and format name.
8609+
For now only path /dev/stdout can be used.
8610+
Path can be set to "OFF" to disable logging.
8611+
https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
86098612
properties:
86108613
format:
8614+
description: Format specifies the log format name to be used.
86118615
type: string
86128616
path:
8617+
description: Path specifies the log file path. Or "OFF" to
8618+
disable logging.
86138619
type: string
86148620
type: object
86158621
agentLevel:
@@ -8643,12 +8649,15 @@ spec:
86438649
type: string
86448650
logFormat:
86458651
description: |-
8646-
LogFormats defines custom log formats that can be used in access logs.
8652+
LogFormat defines custom log format that can be used in access logs.
86478653
Each log format must have a unique name.
8654+
https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
86488655
properties:
86498656
format:
8657+
description: Format specifies the log format string.
86508658
type: string
86518659
name:
8660+
description: Name specifies the name of the log format.
86528661
type: string
86538662
type: object
86548663
type: object

internal/controller/provisioner/objects.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,14 +1448,14 @@ func DetermineNginxImageName(
14481448
return fmt.Sprintf("%s:%s", image, tag), pullPolicy
14491449
}
14501450

1451-
func addLogFormatToNginxConfig(logging *ngfAPIv1alpha2.NginxLogging) *ngfAPIv1alpha2.LogFormat {
1452-
logFormat := &ngfAPIv1alpha2.LogFormat{}
1451+
func addLogFormatToNginxConfig(logging *ngfAPIv1alpha2.NginxLogging) *ngfAPIv1alpha2.NginxLogFormat {
1452+
logFormat := &ngfAPIv1alpha2.NginxLogFormat{}
14531453
if logging == nil {
14541454
return logFormat
14551455
}
14561456

14571457
if logging.LogFormat != nil {
1458-
logFormat = &ngfAPIv1alpha2.LogFormat{
1458+
logFormat = &ngfAPIv1alpha2.NginxLogFormat{
14591459
Name: logging.LogFormat.Name,
14601460
Format: logging.LogFormat.Format,
14611461
}
@@ -1464,14 +1464,14 @@ func addLogFormatToNginxConfig(logging *ngfAPIv1alpha2.NginxLogging) *ngfAPIv1al
14641464
return logFormat
14651465
}
14661466

1467-
func addAccessLogsToNginxConfig(logging *ngfAPIv1alpha2.NginxLogging) *ngfAPIv1alpha2.AccessLog {
1468-
accessLog := &ngfAPIv1alpha2.AccessLog{}
1467+
func addAccessLogsToNginxConfig(logging *ngfAPIv1alpha2.NginxLogging) *ngfAPIv1alpha2.NginxAccessLog {
1468+
accessLog := &ngfAPIv1alpha2.NginxAccessLog{}
14691469
if logging == nil {
14701470
return accessLog
14711471
}
14721472

14731473
if logging.AccessLog != nil {
1474-
accessLog = &ngfAPIv1alpha2.AccessLog{
1474+
accessLog = &ngfAPIv1alpha2.NginxAccessLog{
14751475
Path: logging.AccessLog.Path,
14761476
Format: logging.AccessLog.Format,
14771477
}

internal/controller/state/dataplane/configuration.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,10 +1262,8 @@ func buildLogFormat(srcLogSettings *ngfAPIv1alpha2.NginxLogging) *LogFormat {
12621262
func buildAccessLog(srcLogSettings *ngfAPIv1alpha2.NginxLogging) *AccessLog {
12631263
var accessLog AccessLog
12641264
// Current API exposes a singular *string AccessLog path (no format yet) – only /dev/stdout or "off".
1265-
if srcLogSettings.AccessLog != nil &&
1266-
srcLogSettings.AccessLog.Path != nil &&
1267-
*srcLogSettings.AccessLog.Path != "" {
1268-
if strings.ToLower(*srcLogSettings.AccessLog.Path) == "off" {
1265+
if srcLogSettings.AccessLog != nil {
1266+
if srcLogSettings.AccessLog.Path != nil && strings.ToLower(*srcLogSettings.AccessLog.Path) == "off" {
12691267
accessLog = AccessLog{Path: "off"}
12701268
} else {
12711269
// only "/dev/stdout" is supported for now

0 commit comments

Comments
 (0)