Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error msg to comply with a Go linter #5582

Merged
merged 4 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading