diff --git a/release/release.go b/release/release.go index e23648e..0b62a46 100644 --- a/release/release.go +++ b/release/release.go @@ -52,19 +52,20 @@ type Arch struct { // Media contains release details for various platforms type Media struct { - Aliyun *PlatformAliyun `json:"aliyun"` - Aws *PlatformAws `json:"aws"` - Azure *PlatformBase `json:"azure"` - AzureStack *PlatformBase `json:"azurestack"` - Digitalocean *PlatformBase `json:"digitalocean"` - Exoscale *PlatformBase `json:"exoscale"` - Gcp *PlatformGcp `json:"gcp"` - Ibmcloud *PlatformBase `json:"ibmcloud"` - Metal *PlatformBase `json:"metal"` - Openstack *PlatformBase `json:"openstack"` - Qemu *PlatformBase `json:"qemu"` - Vmware *PlatformBase `json:"vmware"` - Vultr *PlatformBase `json:"vultr"` + Aliyun *PlatformAliyun `json:"aliyun"` + Aws *PlatformAws `json:"aws"` + Azure *PlatformBase `json:"azure"` + AzureStack *PlatformBase `json:"azurestack"` + Digitalocean *PlatformBase `json:"digitalocean"` + Exoscale *PlatformBase `json:"exoscale"` + Gcp *PlatformGcp `json:"gcp"` + Ibmcloud *PlatformIBMCloud `json:"ibmcloud"` + Metal *PlatformBase `json:"metal"` + Openstack *PlatformBase `json:"openstack"` + PowerVS *PlatformIBMCloud `json:"powervs"` + Qemu *PlatformBase `json:"qemu"` + Vmware *PlatformBase `json:"vmware"` + Vultr *PlatformBase `json:"vultr"` } // PlatformBase with no cloud images @@ -90,6 +91,12 @@ type PlatformGcp struct { Image *GcpImage `json:"image"` } +// PlatformIBMCloud IBMCloud/PowerVS image detail +type PlatformIBMCloud struct { + PlatformBase + Images map[string]IBMCloudImage `json:"images"` +} + // ImageFormat contains all artifacts for a single OS image type ImageFormat struct { Disk *Artifact `json:"disk,omitempty"` @@ -117,3 +124,10 @@ type GcpImage struct { Family string `json:"family,omitempty"` Name string `json:"name,omitempty"` } + +// IBMCloudImage represents an IBMCloud/PowerVS cloud object - which is an ova image for PowerVS and a qcow for IBMCloud in the cloud object storage bucket +type IBMCloudImage struct { + Object string `json:"object"` + Bucket string `json:"bucket"` + Url string `json:"url"` +} diff --git a/release/translate.go b/release/translate.go index 3dce47a..0de08b6 100644 --- a/release/translate.go +++ b/release/translate.go @@ -149,6 +149,22 @@ func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch { Release: rel.Release, Formats: mapFormats(releaseArch.Media.Ibmcloud.Artifacts), } + ibmcloudObjects := stream.ReplicatedObject{ + Regions: make(map[string]stream.RegionObject), + } + if releaseArch.Media.Ibmcloud.Images != nil { + for region, object := range releaseArch.Media.Ibmcloud.Images { + ri := stream.RegionObject{ + Release: rel.Release, + Object: object.Object, + Bucket: object.Bucket, + Url: object.Url, + } + ibmcloudObjects.Regions[region] = ri + + } + cloudImages.Ibmcloud = &ibmcloudObjects + } } // if releaseArch.Media.Packet != nil { @@ -169,6 +185,29 @@ func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch { } } + if releaseArch.Media.PowerVS != nil { + artifacts["powervs"] = stream.PlatformArtifacts{ + Release: rel.Release, + Formats: mapFormats(releaseArch.Media.PowerVS.Artifacts), + } + powervsObjects := stream.ReplicatedObject{ + Regions: make(map[string]stream.RegionObject), + } + if releaseArch.Media.PowerVS.Images != nil { + for region, object := range releaseArch.Media.PowerVS.Images { + ri := stream.RegionObject{ + Release: rel.Release, + Object: object.Object, + Bucket: object.Bucket, + Url: object.Url, + } + powervsObjects.Regions[region] = ri + + } + cloudImages.PowerVS = &powervsObjects + } + } + if releaseArch.Media.Qemu != nil { artifacts["qemu"] = stream.PlatformArtifacts{ Release: rel.Release, diff --git a/stream/stream.go b/stream/stream.go index c811b83..3fa2a28 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -52,9 +52,11 @@ type Artifact struct { // Images contains images available in cloud providers type Images struct { - Aliyun *ReplicatedImage `json:"aliyun,omitempty"` - Aws *AwsImage `json:"aws,omitempty"` - Gcp *GcpImage `json:"gcp,omitempty"` + Aliyun *ReplicatedImage `json:"aliyun,omitempty"` + Aws *AwsImage `json:"aws,omitempty"` + Gcp *GcpImage `json:"gcp,omitempty"` + Ibmcloud *ReplicatedObject `json:"ibmcloud,omitempty"` + PowerVS *ReplicatedObject `json:"powervs,omitempty"` } // ReplicatedImage represents an image in all regions of an AWS-like cloud @@ -80,3 +82,16 @@ type GcpImage struct { Family string `json:"family,omitempty"` Name string `json:"name,omitempty"` } + +// ReplicatedObject represents an object in all regions of an IBMCloud-like cloud +type ReplicatedObject struct { + Regions map[string]RegionObject `json:"regions,omitempty"` +} + +// RegionObject represents an IBMCloud/PowerVS cloud image +type RegionObject struct { + Release string `json:"release"` + Object string `json:"object"` + Bucket string `json:"bucket"` + Url string `json:"url"` +}