From 610c25cb7994543b61c9879450f41e744bc5f309 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Sun, 12 Nov 2023 13:27:39 +0200 Subject: [PATCH] Minor cleanup in Migration#Load Use if-with-a-short-statement to reduce the length of this function. Signed-off-by: Arik Hadas --- pkg/settings/migration.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/pkg/settings/migration.go b/pkg/settings/migration.go index ff9cfdc5c..954fea8c7 100644 --- a/pkg/settings/migration.go +++ b/pkg/settings/migration.go @@ -53,28 +53,22 @@ type Migration struct { // Load settings. func (r *Migration) Load() (err error) { - r.MaxInFlight, err = getPositiveEnvLimit(MaxVmInFlight, 20) - if err != nil { + if r.MaxInFlight, err = getPositiveEnvLimit(MaxVmInFlight, 20); err != nil { return liberr.Wrap(err) } - r.HookRetry, err = getPositiveEnvLimit(HookRetry, 3) - if err != nil { + if r.HookRetry, err = getPositiveEnvLimit(HookRetry, 3); err != nil { return liberr.Wrap(err) } - r.ImporterRetry, err = getPositiveEnvLimit(ImporterRetry, 3) - if err != nil { + if r.ImporterRetry, err = getPositiveEnvLimit(ImporterRetry, 3); err != nil { return liberr.Wrap(err) } - r.PrecopyInterval, err = getPositiveEnvLimit(PrecopyInterval, 60) - if err != nil { + if r.PrecopyInterval, err = getPositiveEnvLimit(PrecopyInterval, 60); err != nil { return liberr.Wrap(err) } - r.SnapshotRemovalTimeout, err = getPositiveEnvLimit(SnapshotRemovalTimeout, 120) - if err != nil { + if r.SnapshotRemovalTimeout, err = getPositiveEnvLimit(SnapshotRemovalTimeout, 120); err != nil { return liberr.Wrap(err) } - r.SnapshotStatusCheckRate, err = getPositiveEnvLimit(SnapshotStatusCheckRate, 10) - if err != nil { + if r.SnapshotStatusCheckRate, err = getPositiveEnvLimit(SnapshotStatusCheckRate, 10); err != nil { return liberr.Wrap(err) } if virtV2vImage, ok := os.LookupEnv(VirtV2vImage); ok { @@ -90,12 +84,10 @@ func (r *Migration) Load() (err error) { r.VirtV2vImageWarm = DefaultVirtV2vImage } r.VirtV2vDontRequestKVM = getEnvBool(VirtV2vDontRequestKVM, false) - r.CDIExportTokenTTL, err = getPositiveEnvLimit(CDIExportTokenTTL, 0) - if err != nil { + if r.CDIExportTokenTTL, err = getPositiveEnvLimit(CDIExportTokenTTL, 0); err != nil { return liberr.Wrap(err) } - r.FileSystemOverhead, err = getNonNegativeEnvLimit(FileSystemOverhead, 10) - if err != nil { + if r.FileSystemOverhead, err = getNonNegativeEnvLimit(FileSystemOverhead, 10); err != nil { return liberr.Wrap(err) }