Skip to content

Commit

Permalink
Add RHELCoreOSExtensions with Azure image URL
Browse files Browse the repository at this point in the history
This contains just a URL for now because that's all
the current RHCOS cosa metadata has.  I'm trying
to add e.g. the Azure Blob storage md5 information as
well as the full size+sha256, but in practice this
data is just the uncompressed VHD; anyone who wants
to do "offline" verification outside of Azure can
replicate that.

For FCOS we may end up uploading the image too,
though we hope there to end up in the Marketplace.

For now, let's stick this off an explicit extension area.

Closes: coreos#13
  • Loading branch information
cgwalters committed Feb 11, 2021
1 parent 5c41fa7 commit 5314745
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PKGS := arch release stream fedoracoreos
PKGS := arch release stream stream/rhcos release/relrhcos fedoracoreos

build:
for pkg in $(PKGS); do (cd $$pkg && go build -mod=vendor); done
Expand Down
9 changes: 7 additions & 2 deletions release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// with streams instead.
package release

import (
"github.com/coreos/stream-metadata-go/release/relrhcos"
)

// Index models the release index:
// https://github.com/coreos/fedora-coreos-tracker/tree/master/metadata/release-index
type Index struct {
Expand Down Expand Up @@ -41,8 +45,9 @@ type Metadata struct {

// Arch release details
type Arch struct {
Commit string `json:"commit"`
Media Media `json:"media"`
Commit string `json:"commit"`
Media Media `json:"media"`
RHELCoreOSExtensions *relrhcos.Extensions `json:"rhel-coreos-extensions,omitempty"`
}

// Media contains release details for various platforms
Expand Down
14 changes: 14 additions & 0 deletions release/relrhcos/rhcos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package relrhcos

// Extensions is data specific to Red Hat Enterprise Linux CoreOS
type Extensions struct {
AzureImage *AzureImage `json:"azure-image,omitempty"`
}

// AzureImage represents an Azure cloud image.
type AzureImage struct {
// URL to an image already stored in Azure infrastructure
// that can be copied into an image gallery. Avoid creating VMs directly
// from this URL as that may lead to performance limitations.
URL string `json:"url,omitempty"`
}
28 changes: 20 additions & 8 deletions release/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package release

import (
"github.com/coreos/stream-metadata-go/stream"
"github.com/coreos/stream-metadata-go/stream/rhcos"
)

func mapArtifact(ra *Artifact) *stream.Artifact {
Expand Down Expand Up @@ -33,6 +34,11 @@ func mapFormats(m map[string]ImageFormat) map[string]stream.ImageFormat {
func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch {
artifacts := make(map[string]stream.PlatformArtifacts)
cloudImages := stream.Images{}
var rhcosExt *rhcos.Extensions
relRHCOSExt := releaseArch.RHELCoreOSExtensions
if relRHCOSExt != nil {
rhcosExt = &rhcos.Extensions{}
}
if releaseArch.Media.Aws != nil {
artifacts["aws"] = stream.PlatformArtifacts{
Release: rel.Release,
Expand All @@ -57,12 +63,17 @@ func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch {
Formats: mapFormats(releaseArch.Media.Azure.Artifacts),
}

// Not enabled right now
// if az := releaseArch.Media.Azure.Images; az != nil && az.Global != nil && az.Global.Image != nil {
// azureImage := StreamCloudImage{}
// azureImage.Image = fmt.Sprintf("Fedora:CoreOS:%s:latest", rel.Stream)
// cloudImages.Azure = &azureImage
// }
if relRHCOSExt != nil {
az := relRHCOSExt.AzureImage
if az != nil {
rhcosExt.AzureImage = &rhcos.AzureImage{
Release: rel.Release,
URL: az.URL,
}
}
}
// In the future this is where we'd also add FCOS Marketplace data.
// See https://github.com/coreos/stream-metadata-go/issues/13
}

if releaseArch.Media.Aliyun != nil {
Expand Down Expand Up @@ -169,8 +180,9 @@ func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch {
}

return stream.Arch{
Artifacts: artifacts,
Images: cloudImages,
Artifacts: artifacts,
Images: cloudImages,
RHELCoreOSExtensions: rhcosExt,
}
}

Expand Down
16 changes: 16 additions & 0 deletions stream/rhcos/rhcos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package rhcos

// Extensions is data specific to Red Hat Enterprise Linux CoreOS
type Extensions struct {
AzureImage *AzureImage `json:"azure-image,omitempty"`
}

// AzureImage represents an Azure cloud image.
type AzureImage struct {
// Release is the source release version
Release string `json:"release"`
// SourceManagedImage is the URL to an image already stored in Azure infrastructure
// that can be copied into an image gallery. Avoid creating VMs directly
// from this URL as that may lead to performance limitations.
URL string `json:"url,omitempty"`
}
6 changes: 6 additions & 0 deletions stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// this API to find cloud images, bare metal disk images, etc.
package stream

import (
"github.com/coreos/stream-metadata-go/stream/rhcos"
)

// Stream contains artifacts available in a stream
type Stream struct {
Stream string `json:"stream"`
Expand All @@ -19,6 +23,8 @@ type Metadata struct {
type Arch struct {
Artifacts map[string]PlatformArtifacts `json:"artifacts"`
Images Images `json:"images,omitempty"`
// RHELCoreOSExtensions is data specific to Red Hat Enterprise Linux CoreOS
RHELCoreOSExtensions *rhcos.Extensions `json:"rhel-coreos-extensions,omitempty"`
}

// PlatformArtifacts contains images for a platform
Expand Down

0 comments on commit 5314745

Please sign in to comment.