diff --git a/Makefile b/Makefile index e564de9..1e19b27 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/release/release.go b/release/release.go index ec2f8a3..9c6bc8a 100644 --- a/release/release.go +++ b/release/release.go @@ -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 { @@ -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 diff --git a/release/relrhcos/rhcos.go b/release/relrhcos/rhcos.go new file mode 100644 index 0000000..8e2d520 --- /dev/null +++ b/release/relrhcos/rhcos.go @@ -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"` +} diff --git a/release/translate.go b/release/translate.go index eaf6cd2..7e19b41 100644 --- a/release/translate.go +++ b/release/translate.go @@ -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 { @@ -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, @@ -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 { @@ -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, } } diff --git a/stream/rhcos/rhcos.go b/stream/rhcos/rhcos.go new file mode 100644 index 0000000..4ef3da8 --- /dev/null +++ b/stream/rhcos/rhcos.go @@ -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"` +} diff --git a/stream/stream.go b/stream/stream.go index c2de9d3..e3f100c 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -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"` @@ -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