Skip to content

Commit

Permalink
Minor cleanup in Migration#Load
Browse files Browse the repository at this point in the history
Use if-with-a-short-statement to reduce the length of this function.

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Nov 12, 2023
1 parent 5745ee2 commit 610c25c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions pkg/settings/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down

0 comments on commit 610c25c

Please sign in to comment.