@@ -44,7 +44,6 @@ type Distro struct {
44
44
ContainerNamePrefix string
45
45
ImageBasename string
46
46
ParseRelease ParseReleaseFunc
47
- ReleaseFormat string
48
47
Registry string
49
48
Repository string
50
49
RepositoryNeedsRelease bool
@@ -61,10 +60,6 @@ const (
61
60
ContainerNameRegexp = "[a-zA-Z0-9][a-zA-Z0-9_.-]*"
62
61
)
63
62
64
- var (
65
- ErrUnsupportedDistro = errors .New ("linux distribution is not supported" )
66
- )
67
-
68
63
var (
69
64
containerNamePrefixDefault = "fedora-toolbox"
70
65
103
98
"fedora-toolbox" ,
104
99
"fedora-toolbox" ,
105
100
parseReleaseFedora ,
106
- "<release>/f<release>" ,
107
101
"registry.fedoraproject.org" ,
108
102
"" ,
109
103
false ,
@@ -112,7 +106,6 @@ var (
112
106
"rhel-toolbox" ,
113
107
"toolbox" ,
114
108
parseReleaseRHEL ,
115
- "<major.minor>" ,
116
109
"registry.access.redhat.com" ,
117
110
"ubi8" ,
118
111
false ,
@@ -253,8 +246,8 @@ func getDefaultImageForDistro(distro, release string) string {
253
246
panic ("distro not specified" )
254
247
}
255
248
256
- if ! IsDistroSupported ( distro ) {
257
- distro = distroDefault
249
+ if _ , supportedDistro := supportedDistros [ distro ]; ! supportedDistro {
250
+ distro = "fedora"
258
251
}
259
252
260
253
distroObj , supportedDistro := supportedDistros [distro ]
@@ -418,20 +411,6 @@ func GetMountOptions(target string) (string, error) {
418
411
return mountOptions , nil
419
412
}
420
413
421
- // GetReleaseFormat returns the format string signifying supported release
422
- // version formats.
423
- //
424
- // distro should be value found under ID in os-release.
425
- //
426
- // If distro is unsupported an empty string is returned.
427
- func GetReleaseFormat (distro string ) string {
428
- if ! IsDistroSupported (distro ) {
429
- return ""
430
- }
431
-
432
- return supportedDistros [distro ].ReleaseFormat
433
- }
434
-
435
414
func GetRuntimeDirectory (targetUser * user.User ) (string , error ) {
436
415
gid , err := strconv .Atoi (targetUser .Gid )
437
416
if err != nil {
@@ -488,14 +467,6 @@ func HumanDuration(duration int64) string {
488
467
return units .HumanDuration (time .Since (time .Unix (duration , 0 ))) + " ago"
489
468
}
490
469
491
- // IsDistroSupported signifies if a distribution has a toolbx image for it.
492
- //
493
- // distro should be value found under ID in os-release.
494
- func IsDistroSupported (distro string ) bool {
495
- _ , ok := supportedDistros [distro ]
496
- return ok
497
- }
498
-
499
470
// ImageReferenceCanBeID checks if 'image' might be the ID of an image
500
471
func ImageReferenceCanBeID (image string ) bool {
501
472
matched , err := regexp .MatchString ("^[a-f0-9]{6,64}$" , image )
@@ -640,18 +611,16 @@ func ShortID(id string) string {
640
611
return id
641
612
}
642
613
643
- // ParseRelease assesses if the requested version of a distribution is in
644
- // the correct format.
645
- //
646
- // If distro is an empty string, a default value (value under the
647
- // 'general.distro' key in a config file or 'fedora') is assumed.
648
614
func ParseRelease (distro , release string ) (string , error ) {
649
615
if distro == "" {
650
- distro , _ = ResolveDistro (distro )
616
+ distro = distroDefault
617
+ if viper .IsSet ("general.distro" ) {
618
+ distro = viper .GetString ("general.distro" )
619
+ }
651
620
}
652
621
653
- if ! IsDistroSupported ( distro ) {
654
- distro = distroDefault
622
+ if _ , supportedDistro := supportedDistros [ distro ]; ! supportedDistro {
623
+ distro = "fedora"
655
624
}
656
625
657
626
distroObj , supportedDistro := supportedDistros [distro ]
@@ -756,33 +725,6 @@ func ResolveContainerName(container, image, release string) (string, error) {
756
725
return container , nil
757
726
}
758
727
759
- // ResolveDistro assess if the requested distribution is supported and provides
760
- // a default value if none is requested.
761
- //
762
- // If distro is empty, and the "general.distro" key in a config file is set,
763
- // the value is read from the config file. If the key is not set, the default
764
- // value ('fedora') is used instead.
765
- func ResolveDistro (distro string ) (string , error ) {
766
- logrus .Debug ("Resolving distribution" )
767
- logrus .Debugf ("Distribution: %s" , distro )
768
-
769
- if distro == "" {
770
- distro = distroDefault
771
- if viper .IsSet ("general.distro" ) {
772
- distro = viper .GetString ("general.distro" )
773
- }
774
- }
775
-
776
- if ! IsDistroSupported (distro ) {
777
- return "" , ErrUnsupportedDistro
778
- }
779
-
780
- logrus .Debug ("Resolved distribution" )
781
- logrus .Debugf ("Distribution: %s" , distro )
782
-
783
- return distro , nil
784
- }
785
-
786
728
// ResolveImageName standardizes the name of an image.
787
729
//
788
730
// If no image name is specified then the base image will reflect the platform of the host (even the version).
@@ -797,7 +739,10 @@ func ResolveImageName(distroCLI, imageCLI, releaseCLI string) (string, string, e
797
739
distro , image , release := distroCLI , imageCLI , releaseCLI
798
740
799
741
if distroCLI == "" {
800
- distro , _ = ResolveDistro (distroCLI )
742
+ distro = distroDefault
743
+ if viper .IsSet ("general.distro" ) {
744
+ distro = viper .GetString ("general.distro" )
745
+ }
801
746
}
802
747
803
748
if distro != distroDefault && releaseCLI == "" && ! viper .IsSet ("general.release" ) {
0 commit comments