Skip to content

Commit

Permalink
gadget: remove LaidOutVolume.Size
Browse files Browse the repository at this point in the history
As it was not used anymore.
  • Loading branch information
alfonsosanchezbeato authored and MiguelPires committed May 24, 2023
1 parent 7812317 commit 803c868
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
10 changes: 1 addition & 9 deletions gadget/layout.go
Expand Up @@ -58,8 +58,6 @@ const NonMBRStartOffset = 1 * quantity.OffsetMiB
// structures within it
type LaidOutVolume struct {
*Volume
// Size is the total size of the volume
Size quantity.Size
// LaidOutStructure is a list of structures within the volume, sorted
// by their start offsets
LaidOutStructure []LaidOutStructure
Expand Down Expand Up @@ -280,12 +278,7 @@ func LayoutVolume(volume *Volume, opts *LayoutOptions) (*LaidOutVolume, error) {
return nil, err
}

farthestEnd := quantity.Offset(0)
for idx, ps := range structures {
if end := ps.StartOffset + quantity.Offset(ps.VolumeStructure.Size); end > farthestEnd {
farthestEnd = end
}

for idx := range structures {
// Set appropriately label and type details
// TODO: set this in layoutVolumeStructures in the future.
setOnDiskLabelAndTypeInLaidOuts(structures, opts.EncType)
Expand Down Expand Up @@ -314,7 +307,6 @@ func LayoutVolume(volume *Volume, opts *LayoutOptions) (*LaidOutVolume, error) {

vol := &LaidOutVolume{
Volume: volume,
Size: quantity.Size(farthestEnd),
LaidOutStructure: structures,
}
return vol, nil
Expand Down
14 changes: 0 additions & 14 deletions gadget/layout_test.go
Expand Up @@ -62,7 +62,6 @@ func (p *layoutTestSuite) TestVolumeSize(c *C) {
{Offset: asOffsetPtr(quantity.OffsetMiB), Size: 2 * quantity.SizeMiB},
},
},
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{{
OnDiskStructure: gadget.OnDiskStructure{
Size: 2 * quantity.SizeMiB,
Expand Down Expand Up @@ -105,7 +104,6 @@ volumes:

c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 501 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -166,7 +164,6 @@ volumes:
}
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 502 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -226,7 +223,6 @@ volumes:

c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 1101 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -294,7 +290,6 @@ volumes:

c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 1300 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -361,7 +356,6 @@ volumes:

c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 1200 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -447,7 +441,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 1200 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -629,7 +622,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -684,7 +676,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -736,7 +727,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -782,7 +772,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down Expand Up @@ -829,7 +818,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 2 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
// MBR
Expand Down Expand Up @@ -889,7 +877,6 @@ volumes:
c.Assert(err, IsNil)
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: vol,
Size: 3 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
// mbr
Expand Down Expand Up @@ -1411,7 +1398,6 @@ func (p *layoutTestSuite) TestLayoutWithMinSize(c *C) {
// Check StartOffset and Size is well defined even if using min-size
c.Assert(v, DeepEquals, &gadget.LaidOutVolume{
Volume: &vol,
Size: 5 * quantity.SizeMiB,
LaidOutStructure: []gadget.LaidOutStructure{
{
OnDiskStructure: gadget.OnDiskStructure{
Expand Down

0 comments on commit 803c868

Please sign in to comment.