Skip to content

Commit

Permalink
Support RHEL hosts by creating containers based on UBI
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryMichal authored and debarshiray committed Jan 12, 2021
1 parent 6fa2184 commit 21d25f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions completion/bash/toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __toolbox_containers() {

__toolbox_distros() {
echo "fedora"
echo "rhel"
}

__toolbox_images() {
Expand Down
25 changes: 25 additions & 0 deletions src/pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ var (
"f%s",
true,
},
"rhel": {
"rhel-toolbox",
"ubi",
parseReleaseRHEL,
"registry.access.redhat.com",
"ubi8",
false,
},
}
)

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 21d25f8

Please sign in to comment.