Skip to content

Commit

Permalink
pkg/utils: Rename parameter in ParseRelease
Browse files Browse the repository at this point in the history
It was not apparent on first glance that the second parameter
represented a release (resp. tag).

containers#828
  • Loading branch information
HarryMichal committed Jul 8, 2021
1 parent 2e5b6ae commit c0ae780
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand All @@ -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
}
Expand All @@ -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.
Expand Down

0 comments on commit c0ae780

Please sign in to comment.