diff --git a/cmd/openshift-install/version.go b/cmd/openshift-install/version.go index 9c1db18d0a7..e841729dd14 100644 --- a/cmd/openshift-install/version.go +++ b/cmd/openshift-install/version.go @@ -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" ) @@ -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 } diff --git a/pkg/rhcos/builds.go b/pkg/rhcos/builds.go index c0a75165e36..6a351fdc02d 100644 --- a/pkg/rhcos/builds.go +++ b/pkg/rhcos/builds.go @@ -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"` @@ -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 { @@ -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 +}