Merge pull request #2107 from Sujeev-Uthayakumar/feature/match-string-ordering

Make naming consistent with regexp.MatchString
This commit is contained in:
Christian Goll
2026-02-02 15:08:50 +01:00
committed by GitHub
6 changed files with 7 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- New --partwipe flag for profile and node set
- Updated arguments for `ValidString` to match `regexp.MatchString`
## v4.6.5, 2026-01-12

View File

@@ -51,3 +51,4 @@
- Adrian Reber <areber@redhat.com>
- Karker Said <said.karker@gmail.com> [@kosmolito](https://github.com/kosmolito)
- Jason Scott <jsco2t@outlook.com> @jsco2t
- Sujeev Uthayakumar <sujeev.uthayakumar@gmail.com> [@Sujeev-Uthayakumar](https://github.com/Sujeev-Uthayakumar)

View File

@@ -12,7 +12,7 @@ import (
)
func ValidName(name string) bool {
if !util.ValidString(name, "^[\\w\\-\\.\\:]+$") {
if !util.ValidString("^[\\w\\-\\.\\:]+$", name) {
wwlog.Warn("Image name has illegal characters: %s", name)
return false
}

View File

@@ -961,7 +961,7 @@ func BuildOverlayIndir(nodeData node.Node, allNodes []node.Node, overlayNames []
return fmt.Errorf("output must a be a directory: %s", outputDir)
}
if !util.ValidString(strings.Join(overlayNames, ""), "^[a-zA-Z0-9-._:]+$") {
if !util.ValidString("^[a-zA-Z0-9-._:]+$", strings.Join(overlayNames, "")) {
return fmt.Errorf("overlay names contains illegal characters: %v", overlayNames)
}

View File

@@ -27,7 +27,7 @@ func legacyKernelVersionFile(kernelName string) string {
return ""
}
if !util.ValidString(kernelName, "^[a-zA-Z0-9-._]+$") {
if !util.ValidString("^[a-zA-Z0-9-._]+$", kernelName) {
return ""
}

View File

@@ -129,8 +129,8 @@ func ReadFile(path string) ([]string, error) {
return lines, nil
}
func ValidString(pattern string, expr string) bool {
if b, _ := regexp.MatchString(expr, pattern); b {
func ValidString(pattern string, s string) bool {
if b, _ := regexp.MatchString(pattern, s); b {
return true
}
return false