Skip to content

Commit

Permalink
rhel: fix crash when PartitionType() is requested
Browse files Browse the repository at this point in the history
This commit fixes a crash in when the rhel ImageType.PartitionType()
is called, here the BasePartitionTables function pointer is sometimes
not initialized (e.g. in the `centos9/edge-commit` image type).
  • Loading branch information
mvo5 authored and achilleas-k committed Nov 7, 2024
1 parent 5134c8b commit fb51dd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/distro/rhel/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,8 @@ func TestOsCustomizationsRHSM(t *testing.T) {
})
}
}

func TestPartitionTypeNotCrashing(t *testing.T) {
it := &ImageType{}
assert.Equal(t, it.PartitionType(), "")
}
4 changes: 4 additions & 0 deletions pkg/distro/rhel/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ func (t *ImageType) getDefaultInstallerConfig() (*distro.InstallerConfig, error)
}

func (t *ImageType) PartitionType() string {
if t.BasePartitionTables == nil {
return ""
}

basePartitionTable, exists := t.BasePartitionTables(t)
if !exists {
return ""
Expand Down

0 comments on commit fb51dd3

Please sign in to comment.