From 90733e79f3aba5545d425bba9c60fdc1c8733c2f Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 20 Jul 2021 12:06:18 +0100 Subject: [PATCH] blueprint: add filesystem minsize function --- internal/blueprint/customizations.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/blueprint/customizations.go b/internal/blueprint/customizations.go index 8984360b8..e6b00db5e 100644 --- a/internal/blueprint/customizations.go +++ b/internal/blueprint/customizations.go @@ -200,3 +200,19 @@ func (c *Customizations) GetFilesystems() []FilesystemCustomization { } return c.Filesystem } + +func (c *Customizations) GetFilesystemsMinSize() uint64 { + if c == nil { + return 0 + } + agg := 0 + for _, m := range c.Filesystem { + agg += m.MinSize + } + // This ensures that file system customization `size` is a multiple of + // sector size (512) + if agg%512 != 0 { + agg = (agg/512 + 1) * 512 + } + return uint64(agg) +}