Skip to content

Commit d45484b

Browse files
jjngxRahul Somasundaram
authored andcommitted
Fix error messages (nginx#5542)
1 parent e6eb885 commit d45484b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/configs/annotations.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func parseRateLimitAnnotations(annotations map[string]string, cfgParams *ConfigP
453453
errors := make([]error, 0)
454454
if requestRateLimit, exists := annotations["nginx.org/limit-req-rate"]; exists {
455455
if rate, err := ParseRequestRate(requestRateLimit); err != nil {
456-
errors = append(errors, fmt.Errorf("Ingress %s/%s: Invalid value for nginx.org/limit-req-rate: got %s: %w", context.GetNamespace(), context.GetName(), requestRateLimit, err))
456+
errors = append(errors, fmt.Errorf("ingress %s/%s: invalid value for nginx.org/limit-req-rate: got %s: %w", context.GetNamespace(), context.GetName(), requestRateLimit, err))
457457
} else {
458458
cfgParams.LimitReqRate = rate
459459
}
@@ -463,7 +463,7 @@ func parseRateLimitAnnotations(annotations map[string]string, cfgParams *ConfigP
463463
}
464464
if requestRateZoneSize, exists := annotations["nginx.org/limit-req-zone-size"]; exists {
465465
if size, err := ParseSize(requestRateZoneSize); err != nil {
466-
errors = append(errors, fmt.Errorf("Ingress %s/%s: Invalid value for nginx.org/limit-req-zone-size: got %s: %w", context.GetNamespace(), context.GetName(), requestRateZoneSize, err))
466+
errors = append(errors, fmt.Errorf("ingress %s/%s: invalid value for nginx.org/limit-req-zone-size: got %s: %w", context.GetNamespace(), context.GetName(), requestRateZoneSize, err))
467467
} else {
468468
cfgParams.LimitReqZoneSize = size
469469
}
@@ -498,7 +498,7 @@ func parseRateLimitAnnotations(annotations map[string]string, cfgParams *ConfigP
498498
}
499499
if requestRateLogLevel, exists := annotations["nginx.org/limit-req-log-level"]; exists {
500500
if !slices.Contains([]string{"info", "notice", "warn", "error"}, requestRateLogLevel) {
501-
errors = append(errors, fmt.Errorf("Ingress %s/%s: Invalid value for nginx.org/limit-req-log-level: got %s", context.GetNamespace(), context.GetName(), requestRateLogLevel))
501+
errors = append(errors, fmt.Errorf("ingress %s/%s: invalid value for nginx.org/limit-req-log-level: got %s", context.GetNamespace(), context.GetName(), requestRateLogLevel))
502502
} else {
503503
cfgParams.LimitReqLogLevel = requestRateLogLevel
504504
}

internal/configs/parsing_helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,16 @@ func ParseRequestRate(s string) (string, error) {
250250
match := rateRegexp.FindStringSubmatch(s)
251251

252252
if match == nil {
253-
return "", errors.New("String does not match rate-pattern: ^(\\d+)(r/s|r/m)$")
253+
return "", errors.New("string does not match rate-pattern: ^(\\d+)(r/s|r/m)$")
254254
}
255255

256256
number, err := strconv.Atoi(match[1])
257257
if err != nil {
258-
return "", errors.New("String does not match rate-pattern")
258+
return "", errors.New("string does not match rate-pattern")
259259
}
260260

261261
if number <= 0 {
262-
return "", errors.New("Rate must be >0")
262+
return "", errors.New("rate must be >0")
263263
}
264264

265265
return s, nil

0 commit comments

Comments
 (0)