Skip to content

Commit

Permalink
version: Output RHEL CoreOS bootimage version
Browse files Browse the repository at this point in the history
There are a lot of reasons to want to know the RHCOS bootimage version
associated with an installer - the installer pins it today, but doesn't
make the information easy to find particularly in a CI/development
environment.

This is a very small step towards something like:
#1399
  • Loading branch information
cgwalters committed Jun 13, 2019
1 parent 98e9958 commit d3cab5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/openshift-install/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"

"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/version"
)

Expand All @@ -28,5 +29,8 @@ func runVersionCmd(cmd *cobra.Command, args []string) error {
if image, err := bootstrap.DefaultReleaseImage(); err == nil {
fmt.Printf("release image %s\n", image)
}
if rhcosver, err := rhcos.FetchVersion(); err == nil {
fmt.Printf("Red Hat Enterprise Linux CoreOS bootimage %s\n", rhcosver)
}
return nil
}
12 changes: 12 additions & 0 deletions pkg/rhcos/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/pkg/errors"
)

// metadata is a subset of the `meta.json` generated
// by https://github.com/coreos/coreos-assembler
type metadata struct {
AMIs map[string]struct {
HVM string `json:"hvm"`
Expand All @@ -23,6 +25,7 @@ type metadata struct {
OSTreeVersion string `json:"ostree-version"`
}

// fetchRHCOSBuild retrieves the pinned RHEL CoreOS metadata.
func fetchRHCOSBuild(ctx context.Context) (*metadata, error) {
file, err := data.Assets.Open("rhcos.json")
if err != nil {
Expand All @@ -42,3 +45,12 @@ func fetchRHCOSBuild(ctx context.Context) (*metadata, error) {

return meta, nil
}

// FetchVersion retrives the pinned RHCOS version.
func FetchVersion() (string, error) {
meta, err := fetchRHCOSBuild(context.TODO())
if err != nil {
return "", err
}
return meta.OSTreeVersion, nil
}

0 comments on commit d3cab5e

Please sign in to comment.