From 7582e788fe83bc87af7c65beb3fd9b8e4e81e874 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Wed, 29 Nov 2023 13:19:12 +0100 Subject: [PATCH] all: fix golangci-lint errors Fixes "indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)" Signed-off-by: Alexander Yastrebov --- controller/cluster_list.go | 3 +-- pkg/aws/instance_info.go | 45 +++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/controller/cluster_list.go b/controller/cluster_list.go index ce47c6ad..5941f446 100644 --- a/controller/cluster_list.go +++ b/controller/cluster_list.go @@ -82,9 +82,8 @@ func (clusterList *ClusterList) UpdateAvailable(configSource channel.ConfigSourc return true } else if pi < pj { return false - } else { - return pendingUpdate[i].lastProcessed.Before(pendingUpdate[j].lastProcessed) } + return pendingUpdate[i].lastProcessed.Before(pendingUpdate[j].lastProcessed) }) clusterList.pendingUpdate = pendingUpdate } diff --git a/pkg/aws/instance_info.go b/pkg/aws/instance_info.go index 51f17387..948ea859 100644 --- a/pkg/aws/instance_info.go +++ b/pkg/aws/instance_info.go @@ -124,34 +124,33 @@ func (types *InstanceTypes) SyntheticInstanceInfo(instanceTypes []string) (Insta return Instance{}, fmt.Errorf("no instance types provided") } else if len(instanceTypes) == 1 { return types.InstanceInfo(instanceTypes[0]) - } else { - first, err := types.InstanceInfo(instanceTypes[0]) + } + + first, err := types.InstanceInfo(instanceTypes[0]) + if err != nil { + return Instance{}, err + } + + result := Instance{ + InstanceType: "", + VCPU: first.VCPU, + Memory: first.Memory, + InstanceStorageDevices: first.InstanceStorageDevices, + InstanceStorageDeviceSize: first.InstanceStorageDeviceSize, + Architecture: first.Architecture, + } + for _, instanceType := range instanceTypes[1:] { + info, err := types.InstanceInfo(instanceType) if err != nil { return Instance{}, err } - result := Instance{ - InstanceType: first.InstanceType, - VCPU: first.VCPU, - Memory: first.Memory, - InstanceStorageDevices: first.InstanceStorageDevices, - InstanceStorageDeviceSize: first.InstanceStorageDeviceSize, - Architecture: first.Architecture, - } - for _, instanceType := range instanceTypes[1:] { - info, err := types.InstanceInfo(instanceType) - if err != nil { - return Instance{}, err - } - - result.VCPU = min(result.VCPU, info.VCPU) - result.Memory = min(result.Memory, info.Memory) - result.InstanceStorageDeviceSize = min(result.InstanceStorageDeviceSize, info.InstanceStorageDeviceSize) - result.InstanceStorageDevices = min(result.InstanceStorageDevices, info.InstanceStorageDevices) - } - result.InstanceType = "" - return result, nil + result.VCPU = min(result.VCPU, info.VCPU) + result.Memory = min(result.Memory, info.Memory) + result.InstanceStorageDeviceSize = min(result.InstanceStorageDeviceSize, info.InstanceStorageDeviceSize) + result.InstanceStorageDevices = min(result.InstanceStorageDevices, info.InstanceStorageDevices) } + return result, nil } // getCompatibleCPUArchitecture returns a single compatible CPU architecture. It's either `amd64` or `arm64`.