pkg/utils: Use newly introduced API for resolving default distro

https://github.com/containers/toolbox/pull/977
This commit is contained in:
Ondřej Míchal 2022-01-09 16:49:28 +02:00
parent 8b6418d8aa
commit 02f45fd3f2
1 changed files with 4 additions and 10 deletions

View File

@ -249,7 +249,7 @@ func GetContainerNamePrefixForImage(image string) (string, error) {
} }
func getDefaultImageForDistro(distro, release string) string { func getDefaultImageForDistro(distro, release string) string {
if _, supportedDistro := supportedDistros[distro]; !supportedDistro { if !IsDistroSupported(distro) {
distro = "fedora" distro = "fedora"
} }
@ -643,13 +643,10 @@ func ShortID(id string) string {
// 'general.distro' key in a config file or 'fedora') is assumed. // 'general.distro' key in a config file or 'fedora') is assumed.
func ParseRelease(distro, release string) (string, error) { func ParseRelease(distro, release string) (string, error) {
if distro == "" { if distro == "" {
distro = distroDefault distro, _ = ResolveDistro(distro)
if viper.IsSet("general.distro") {
distro = viper.GetString("general.distro")
}
} }
if _, supportedDistro := supportedDistros[distro]; !supportedDistro { if !IsDistroSupported(distro) {
distro = "fedora" distro = "fedora"
} }
@ -796,10 +793,7 @@ func ResolveImageName(distroCLI, imageCLI, releaseCLI string) (string, string, e
distro, image, release := distroCLI, imageCLI, releaseCLI distro, image, release := distroCLI, imageCLI, releaseCLI
if distroCLI == "" { if distroCLI == "" {
distro = distroDefault distro, _ = ResolveDistro(distroCLI)
if viper.IsSet("general.distro") {
distro = viper.GetString("general.distro")
}
} }
if distro != distroDefault && releaseCLI == "" && !viper.IsSet("general.release") { if distro != distroDefault && releaseCLI == "" && !viper.IsSet("general.release") {