Merge fe8e7989f9
into de1a4c463c
This commit is contained in:
commit
5f44ba9fcc
2 changed files with 8 additions and 6 deletions
|
@ -32,7 +32,7 @@ var logAnnotations = parser.Annotation{
|
|||
Group: "log",
|
||||
Annotations: parser.AnnotationFields{
|
||||
enableAccessLogAnnotation: {
|
||||
Validator: parser.ValidateBool,
|
||||
Validator: parser.ValidateOptions([]string{"true", "false", "default"}, true, true),
|
||||
Scope: parser.AnnotationScopeLocation,
|
||||
Risk: parser.AnnotationRiskLow,
|
||||
Documentation: `This configuration setting allows you to control if this location should generate an access_log`,
|
||||
|
@ -53,8 +53,8 @@ type log struct {
|
|||
|
||||
// Config contains the configuration to be used in the Ingress
|
||||
type Config struct {
|
||||
Access bool `json:"accessLog"`
|
||||
Rewrite bool `json:"rewriteLog"`
|
||||
Access string `json:"accessLog"`
|
||||
Rewrite bool `json:"rewriteLog"`
|
||||
}
|
||||
|
||||
// Equal tests for equality between two Config types
|
||||
|
@ -84,9 +84,9 @@ func (l log) Parse(ing *networking.Ingress) (interface{}, error) {
|
|||
var err error
|
||||
config := &Config{}
|
||||
|
||||
config.Access, err = parser.GetBoolAnnotation(enableAccessLogAnnotation, ing, l.annotationConfig.Annotations)
|
||||
config.Access, err = parser.GetStringAnnotation(enableAccessLogAnnotation, ing, l.annotationConfig.Annotations)
|
||||
if err != nil {
|
||||
config.Access = true
|
||||
config.Access = "default"
|
||||
}
|
||||
|
||||
config.Rewrite, err = parser.GetBoolAnnotation(enableRewriteLogAnnotation, ing, l.annotationConfig.Annotations)
|
||||
|
|
|
@ -1132,7 +1132,9 @@ stream {
|
|||
|
||||
log_by_lua_file /etc/nginx/lua/nginx/ngx_conf_log_block.lua;
|
||||
|
||||
{{ if not $location.Logs.Access }}
|
||||
{{ if $location.Logs.Access == "true" }}
|
||||
access_log on;
|
||||
{{ else if $location.Logs.Access == "false" }}
|
||||
access_log off;
|
||||
{{ end }}
|
||||
|
||||
|
|
Loading…
Reference in a new issue