From c0ae7803ea85e9c29d8b83ae0f40e3b9fbeb38c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Sun, 4 Jul 2021 00:15:41 +0200 Subject: [PATCH] pkg/utils: Rename parameter in ParseRelease It was not apparent on first glance that the second parameter represented a release (resp. tag). https://github.com/containers/toolbox/pull/828 --- src/pkg/utils/utils.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go index 44f8a06ef..54a504f60 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -578,7 +578,7 @@ func ShortID(id string) string { return id } -func ParseRelease(distro, str string) (string, error) { +func ParseRelease(distro, release string) (string, error) { if distro == "" { distro = distroDefault } @@ -594,17 +594,13 @@ func ParseRelease(distro, str string) (string, error) { } parseRelease := distroObj.ParseRelease - release, err := parseRelease(str) + release, err := parseRelease(release) return release, err } -func parseReleaseFedora(str string) (string, error) { - var release string - - if strings.HasPrefix(str, "F") || strings.HasPrefix(str, "f") { - release = str[1:] - } else { - release = str +func parseReleaseFedora(release string) (string, error) { + if strings.HasPrefix(release, "F") || strings.HasPrefix(release, "f") { + release = release[1:] } releaseN, err := strconv.Atoi(release) @@ -619,12 +615,12 @@ func parseReleaseFedora(str string) (string, error) { return release, nil } -func parseReleaseRHEL(str string) (string, error) { - if i := strings.IndexRune(str, '.'); i == -1 { +func parseReleaseRHEL(release string) (string, error) { + if i := strings.IndexRune(release, '.'); i == -1 { return "", errors.New("release must have a '.'") } - releaseN, err := strconv.ParseFloat(str, 32) + releaseN, err := strconv.ParseFloat(release, 32) if err != nil { return "", err } @@ -633,7 +629,7 @@ func parseReleaseRHEL(str string) (string, error) { return "", errors.New("release must be a positive number") } - return str, nil + return release, nil } // PathExists wraps around os.Stat providing a nice interface for checking an existence of a path.