diff --git a/completion/bash/toolbox b/completion/bash/toolbox index 6ae13189c..9ea387326 100644 --- a/completion/bash/toolbox +++ b/completion/bash/toolbox @@ -7,6 +7,7 @@ __toolbox_containers() { __toolbox_distros() { echo "fedora" + echo "rhel" } __toolbox_images() { diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go index 16a835c1e..60df79c1a 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -101,6 +101,14 @@ var ( "f%s", true, }, + "rhel": { + "rhel-toolbox", + "ubi", + parseReleaseRHEL, + "registry.access.redhat.com", + "ubi8", + false, + }, } ) @@ -600,6 +608,23 @@ func parseReleaseFedora(str string) (string, error) { return release, nil } +func parseReleaseRHEL(str string) (string, error) { + if i := strings.IndexRune(str, '.'); i == -1 { + return "", errors.New("release must have a '.'") + } + + releaseN, err := strconv.ParseFloat(str, 32) + if err != nil { + return "", err + } + + if releaseN <= 0 { + return "", errors.New("release must be a positive number") + } + + return str, nil +} + // PathExists wraps around os.Stat providing a nice interface for checking an existence of a path. func PathExists(path string) bool { if _, err := os.Stat(path); !os.IsNotExist(err) {