Skip to content

Commit

Permalink
Add digest reference to KubeVirt image description
Browse files Browse the repository at this point in the history
In the current design, the KubeVirt image is presumed to be a fully-
qualified reference, including a container digest.  But that implies that
the user should reference the image by digest, when we'd prefer that they
reference it by stream-specific tag.

Define the existing "image" field to contain the preferred form of
fully-qualified reference for the image, which might involve either a
tag or a digest.  We should still record the unique identifier of the
current image (as we do for GCP images), so add a "digest-ref" field
which always contains a fully-qualified reference with digest.
  • Loading branch information
bgilbert committed Apr 15, 2022
1 parent a1904f9 commit ef74682
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 ef74682

Please sign in to comment.