Skip to content

Commit

Permalink
Merge pull request #46 from bgilbert/kubevirt
Browse files Browse the repository at this point in the history
Add digest reference to KubeVirt image description
  • Loading branch information
cgwalters authored Apr 15, 2022
2 parents a1904f9 + ef74682 commit f3a1ef6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
9 changes: 8 additions & 1 deletion release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type PlatformIBMCloud struct {
// PlatformKubeVirt containerDisk metadata
type PlatformKubeVirt struct {
PlatformBase
Image *CloudImage `json:"image"`
Image *ContainerImage `json:"image"`
}

// ImageFormat contains all artifacts for a single OS image
Expand All @@ -127,6 +127,13 @@ type CloudImage struct {
Image string `json:"image"`
}

// ContainerImage represents a tagged container image
type ContainerImage struct {
// Preferred way to reference the image, which might be by tag or digest
Image string `json:"image"`
DigestRef string `json:"digest-ref"`
}

// GcpImage represents a GCP cloud image
type GcpImage struct {
Project string `json:"project"`
Expand Down
7 changes: 4 additions & 3 deletions release/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ func (releaseArch *Arch) toStreamArch(rel *Release) stream.Arch {
Formats: mapFormats(releaseArch.Media.KubeVirt.Artifacts),
}
if releaseArch.Media.KubeVirt.Image != nil {
cloudImages.KubeVirt = &stream.SingleImage{
Release: rel.Release,
Image: releaseArch.Media.KubeVirt.Image.Image,
cloudImages.KubeVirt = &stream.ContainerImage{
Release: rel.Release,
Image: releaseArch.Media.KubeVirt.Image.Image,
DigestRef: releaseArch.Media.KubeVirt.Image.DigestRef,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion stream/fixtures/fcos-stream.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@
},
"kubevirt": {
"release": "33.20211201.3.0",
"image": "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773"
"image": "quay.io/openshift-release-dev/rhcos:latest",
"digest-ref": "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773"
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Images struct {
Aws *AwsImage `json:"aws,omitempty"`
Gcp *GcpImage `json:"gcp,omitempty"`
Ibmcloud *ReplicatedObject `json:"ibmcloud,omitempty"`
KubeVirt *SingleImage `json:"kubevirt,omitempty"`
KubeVirt *ContainerImage `json:"kubevirt,omitempty"`
PowerVS *ReplicatedObject `json:"powervs,omitempty"`
}

Expand All @@ -72,6 +72,14 @@ type SingleImage struct {
Image string `json:"image"`
}

// ContainerImage represents a tagged container image
type ContainerImage struct {
Release string `json:"release"`
// Preferred way to reference the image, which might be by tag or digest
Image string `json:"image"`
DigestRef string `json:"digest-ref"`
}

// AwsImage is a typedef for backwards compatibility.
type AwsImage = ReplicatedImage

Expand Down
6 changes: 5 additions & 1 deletion stream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func TestParseFCS(t *testing.T) {
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "does not have architecture 'nonarch'")

assert.Equal(t, stream.Architectures["x86_64"].Images.KubeVirt.Image, "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773")
assert.Equal(t, stream.Architectures["x86_64"].Images.KubeVirt, &ContainerImage{
Release: "33.20211201.3.0",
Image: "quay.io/openshift-release-dev/rhcos@latest",
DigestRef: "quay.io/openshift-release-dev/rhcos@sha256:67a81539946ec0397196c145394553b8e0241acf27b14ae9de43bc56e167f773",
})
assert.Equal(t, stream.Architectures["x86_64"].Artifacts["kubevirt"].Formats["qcow2.xz"].Disk.Sha256, "2be55c5aa1f53eb9a869826dacbab75706ee6bd59185b935ac9be546cc132a85")
}

0 comments on commit f3a1ef6

Please sign in to comment.