Skip to content

Commit

Permalink
Fix error msg to comply with a Go linter (nginx#5582)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjngx authored and ssrahul96 committed Jun 20, 2024
1 parent 6ad91bd commit 7aef14a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/k8s/secrets/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ func ValidateCASecret(secret *api_v1.Secret) error {

block, _ := pem.Decode(secret.Data[CAKey])
if block == nil {
return fmt.Errorf("The data field %s must hold a valid CERTIFICATE PEM block", CAKey)
return fmt.Errorf("the data field %s must hold a valid CERTIFICATE PEM block", CAKey)
}
if block.Type != "CERTIFICATE" {
return fmt.Errorf("The data field %s must hold a valid CERTIFICATE PEM block, but got '%s'", CAKey, block.Type)
return fmt.Errorf("the data field %s must hold a valid CERTIFICATE PEM block, but got '%s'", CAKey, block.Type)
}

_, err := x509.ParseCertificate(block.Bytes)
Expand Down Expand Up @@ -112,11 +112,11 @@ func ValidateOIDCSecret(secret *api_v1.Secret) error {
// ValidateHtpasswdSecret validates the secret. If it is valid, the function returns nil.
func ValidateHtpasswdSecret(secret *api_v1.Secret) error {
if secret.Type != SecretTypeHtpasswd {
return fmt.Errorf("Htpasswd secret must be of the type %v", SecretTypeHtpasswd)
return fmt.Errorf("htpasswd secret must be of the type %v", SecretTypeHtpasswd)
}

if _, exists := secret.Data[HtpasswdFileKey]; !exists {
return fmt.Errorf("Htpasswd secret must have the data field %v", HtpasswdFileKey)
return fmt.Errorf("htpasswd secret must have the data field %v", HtpasswdFileKey)
}

// we don't validate the contents of secret.Data[HtpasswdFileKey], because invalid contents will not make NGINX
Expand Down Expand Up @@ -149,7 +149,7 @@ func ValidateSecret(secret *api_v1.Secret) error {
return ValidateHtpasswdSecret(secret)
}

return fmt.Errorf("Secret is of the unsupported type %v", secret.Type)
return fmt.Errorf("secret is of the unsupported type %v", secret.Type)
}

var clientSecretValueFmtRegexp = regexp.MustCompile(`^([^"$\\\s]|\\[^$])*$`)
Expand Down

0 comments on commit 7aef14a

Please sign in to comment.