Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apis/metal3.io/v1alpha1/baremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,13 +1098,14 @@ func (image *Image) GetChecksum() (checksum, checksumType string, err error) {
return "", "", errors.New("image is not provided")
}

if image.DiskFormat != nil && *image.DiskFormat == "live-iso" {
// Checksum is not required for live-iso
if image.IsOCI() {
if image.Checksum != "" {
return "", "", errors.New("spec.image.checksum must be empty for OCI images (oci:// images have embedded checksums)")
}
return "", "", nil
}

// Checksum is not required for OCI images as they have embedded checksums
if image.IsOCI() && image.Checksum == "" {
if image.DiskFormat != nil && *image.DiskFormat == "live-iso" {
return "", "", nil
}

Expand Down
20 changes: 19 additions & 1 deletion apis/metal3.io/v1alpha1/baremetalhost_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,25 @@ func TestGetImageChecksum(t *testing.T) {
},
},
},
Expected: true,
Expected: false,
ExpectedType: "",
},
{
Scenario: "OCI image with live-iso format and checksum",
Host: BareMetalHost{
ObjectMeta: metav1.ObjectMeta{
Name: "myhost",
Namespace: "myns",
},
Spec: BareMetalHostSpec{
Image: &Image{
URL: "oci://example.com/image:latest",
Checksum: "sha256hash",
DiskFormat: ptr.To("live-iso"),
},
},
},
Expected: false,
ExpectedType: "",
},
{
Expand Down