Skip to content

Commit

Permalink
Add KubeVirt platform artifact and image information
Browse files Browse the repository at this point in the history
Artifact: KubeVirt containerDisks have a normal qcow2 image as base,
similar configured like for OpenStack.

Image: KubeVirt consumes directly a qcow2 disk inside a container which
is described in the images section. It is based on the qcow2 from the
base artifacts for kubevirt.

Signed-off-by: Roman Mohr <rmohr@redhat.com>
  • Loading branch information
rmohr committed Mar 14, 2022
1 parent 5f15aed commit 4701eed
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
11 changes: 11 additions & 0 deletions release/fixtures/fcos-release.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@
}
}
},
"kubevirt": {
"artifacts": {
"qcow2.xz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/33.20201201.3.0/x86_64/fedora-coreos-33.20201201.3.0-kubevirt.x86_64.qcow2.xz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/33.20201201.3.0/x86_64/fedora-coreos-33.20201201.3.0-kubevirt.x86_64.qcow2.xz.sig",
"sha256": "2be55c5aa1f53eb9a869826dacbab75706ee6bd59185b935ac9be546cc132a85"
}
}
}
},
"qemu": {
"artifacts": {
"qcow2.xz": {
Expand Down
6 changes: 6 additions & 0 deletions release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Media struct {
Exoscale *PlatformBase `json:"exoscale"`
Gcp *PlatformGcp `json:"gcp"`
Ibmcloud *PlatformIBMCloud `json:"ibmcloud"`
KubeVirt *PlatformKubeVirt `json:"kubevirt"`
Metal *PlatformBase `json:"metal"`
Nutanix *PlatformBase `json:"nutanix"`
Openstack *PlatformBase `json:"openstack"`
Expand Down Expand Up @@ -98,6 +99,11 @@ type PlatformIBMCloud struct {
Images map[string]IBMCloudImage `json:"images"`
}

// PlatformKubeVirt containerDisk metadata
type PlatformKubeVirt struct {
PlatformBase
}

// ImageFormat contains all artifacts for a single OS image
type ImageFormat struct {
Disk *Artifact `json:"disk,omitempty"`
Expand Down
17 changes: 17 additions & 0 deletions stream/fixtures/fcos-stream.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
}
}
},
"kubevirt": {
"release": "33.20201201.3.0",
"formats": {
"qcow2.xz": {
"disk": {
"location": "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/33.20201201.3.0/x86_64/fedora-coreos-33.20201201.3.0-kubevirt.x86_64.qcow2.xz",
"signature": "https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/33.20201201.3.0/x86_64/fedora-coreos-33.20201201.3.0-kubevirt.x86_64.qcow2.xz.sig",
"sha256": "2be55c5aa1f53eb9a869826dacbab75706ee6bd59185b935ac9be546cc132a85"
}
}
}
},
"qemu": {
"release": "33.20201201.3.0",
"formats": {
Expand Down Expand Up @@ -372,6 +384,11 @@
"project": "fedora-coreos-cloud",
"family": "fedora-coreos-stable",
"name": "fedora-coreos-33-20201201-3-0-gcp-x86-64"
},
"kubevirt": {
"registry": "quay.io/openshift-release-dev/rhcos",
"image": "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773",
"digest": "sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773"
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ type Artifact struct {
UncompressedSha256 string `json:"uncompressed-sha256,omitempty"`
}

type KubeVirtContainerDisk struct {
Registry string `json:"registry,omitempty"`
Digest string `json:"digest,omitempty"`
Image string `json:"image,omitempty"`
}

// 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"`
Ibmcloud *ReplicatedObject `json:"ibmcloud,omitempty"`
PowerVS *ReplicatedObject `json:"powervs,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"`
KubeVirt *KubeVirtContainerDisk `json:"kubevirt,omitempty"`
}

// ReplicatedImage represents an image in all regions of an AWS-like cloud
Expand Down
9 changes: 9 additions & 0 deletions stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@ func TestParseFCS(t *testing.T) {
_, err = stream.QueryDisk("nonarch", "", "nosuchthing")
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "does not have architecture 'nonarch'")

disk, err := stream.GetKubeVirtContainerDisk("x86_64")
assert.Nil(t, err)
assert.Equal(t, disk.Image, "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773")
assert.Equal(t, disk.Digest, "sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773")
assert.Equal(t, disk.Registry, "quay.io/openshift-release-dev/rhcos")
_, err = stream.GetKubeVirtContainerDisk("unknown")
assert.NotNil(t, err)
assert.Equal(t, stream.Architectures["x86_64"].Artifacts["kubevirt"].Formats["qcow2.xz"].Disk.Sha256, "2be55c5aa1f53eb9a869826dacbab75706ee6bd59185b935ac9be546cc132a85")
}
14 changes: 14 additions & 0 deletions stream/stream_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ func (st *Stream) GetAwsRegionImage(archname, region string) (*AwsRegionImage, e
return &regionVal, nil
}

// GetKubeVirtContainerDisk returns the containerdisk infos for a particular
// architecture.
func (st *Stream) GetKubeVirtContainerDisk(archname string) (*KubeVirtContainerDisk, error) {
starch, err := st.GetArchitecture(archname)
if err != nil {
return nil, err
}
containerDisk := starch.Images.KubeVirt
if containerDisk == nil {
return nil, fmt.Errorf("%s: No containerDisk", st.FormatPrefix(archname))
}
return containerDisk, nil
}

// GetAMI returns the AWS machine image for a particular architecture and region.
func (st *Stream) GetAMI(archname, region string) (string, error) {
regionVal, err := st.GetAwsRegionImage(archname, region)
Expand Down

0 comments on commit 4701eed

Please sign in to comment.