diff --git a/cmd/krel/cmd/validate.go b/cmd/krel/cmd/validate.go index 344d1554826..b9fd64efbe5 100644 --- a/cmd/krel/cmd/validate.go +++ b/cmd/krel/cmd/validate.go @@ -17,6 +17,7 @@ limitations under the License. package cmd import ( + "errors" "fmt" "os" "path/filepath" @@ -65,7 +66,7 @@ The 'validate' subcommand of krel has been developed to: func runValidateReleaseNotes(releaseNotesPath string) (err error) { // Ensure the path is not empty if releaseNotesPath == "" { - return fmt.Errorf("release notes path cannot be empty") + return errors.New("release notes path cannot be empty") } // Check if the directory exists @@ -84,7 +85,7 @@ func runValidateReleaseNotes(releaseNotesPath string) (err error) { // Validate YAML if err := ValidateYamlMap(path); err != nil { - return fmt.Errorf("validating YAML file %s: %v", path, err) + return fmt.Errorf("validating YAML file %s: %w", path, err) } fmt.Printf("YAML file %s is valid.\n", path) @@ -92,7 +93,7 @@ func runValidateReleaseNotes(releaseNotesPath string) (err error) { return nil }) if err != nil { - return fmt.Errorf("validating release notes: %v", err) + return fmt.Errorf("validating release notes: %w", err) } fmt.Println("All release notes are valid.") @@ -137,11 +138,11 @@ func validateTextFieldPunctuation(data *notes.ReleaseNotesMap) error { validPunctuation := regexp.MustCompile(`[.!?]$`) if data == nil { - return fmt.Errorf("the release notes map is nil") + return errors.New("the release notes map is nil") } if data.ReleaseNote.Text == nil { - return fmt.Errorf("the 'text' release notes map field is nil") + return errors.New("the 'text' release notes map field is nil") } text := *data.ReleaseNote.Text