ci: fix all linter errors found in golangci-lint

Fixing all the linter errors found in golang-ci
lint v1.46.2

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2022-06-01 15:47:19 +05:30
committed by mergify[bot]
parent 9e5cad173d
commit 1952a9b4b3
56 changed files with 348 additions and 195 deletions

View File

@ -119,7 +119,8 @@ func ExecCommandWithTimeout(
args ...string) (
string,
string,
error) {
error,
) {
var (
sanitizedArgs = StripSecretInArgs(args)
stdoutBuf bytes.Buffer

View File

@ -139,7 +139,8 @@ func GetMappedID(key, value, id string) string {
// fetchMappedClusterIDAndMons returns monitors and clusterID info after checking cluster mapping.
func fetchMappedClusterIDAndMons(ctx context.Context,
clusterID, clusterMappingConfigFile, csiConfigFile string) (string, string, error) {
clusterID, clusterMappingConfigFile, csiConfigFile string,
) (string, string, error) {
var mons string
clusterMappingInfo, err := getClusterMappingInfo(clusterID, clusterMappingConfigFile)
if err != nil {

View File

@ -187,9 +187,9 @@ func generateNewEncryptionPassphrase() (string, error) {
}
// VolumeMapper returns file name and it's path to where encrypted device should be open.
func VolumeMapper(volumeID string) (mapperFile, mapperFilePath string) {
mapperFile = mapperFilePrefix + volumeID
mapperFilePath = path.Join(mapperFilePathPrefix, mapperFile)
func VolumeMapper(volumeID string) (string, string) {
mapperFile := mapperFilePrefix + volumeID
mapperFilePath := path.Join(mapperFilePathPrefix, mapperFile)
return mapperFile, mapperFilePath
}
@ -248,7 +248,7 @@ func IsDeviceOpen(ctx context.Context, device string) (bool, error) {
// DeviceEncryptionStatus looks to identify if the passed device is a LUKS mapping
// and if so what the device is and the mapper name as used by LUKS.
// If not, just returns the original device and an empty string.
func DeviceEncryptionStatus(ctx context.Context, devicePath string) (mappedDevice, mapper string, err error) {
func DeviceEncryptionStatus(ctx context.Context, devicePath string) (string, string, error) {
if !strings.HasPrefix(devicePath, mapperFilePathPrefix) {
return devicePath, "", nil
}
@ -274,7 +274,7 @@ func DeviceEncryptionStatus(ctx context.Context, devicePath string) (mappedDevic
return "", "", fmt.Errorf("device encryption status output for %s is badly formatted: %s",
devicePath, lines[i])
}
if strings.Compare(kv[0], "device") == 0 {
if kv[0] == "device" {
return strings.TrimSpace(kv[1]), mapPath, nil
}
}

View File

@ -141,7 +141,8 @@ type TopologyConstrainedPool struct {
// GetTopologyFromRequest extracts TopologyConstrainedPools and passed in accessibility constraints
// from a CSI CreateVolume request.
func GetTopologyFromRequest(
req *csi.CreateVolumeRequest) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) {
req *csi.CreateVolumeRequest,
) (*[]TopologyConstrainedPool, *csi.TopologyRequirement, error) {
var topologyPools []TopologyConstrainedPool
// check if parameters have pool configuration pertaining to topology
@ -171,7 +172,8 @@ func GetTopologyFromRequest(
// MatchPoolAndTopology returns the topology map, if the passed in pool matches any
// passed in accessibility constraints.
func MatchPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
accessibilityRequirements *csi.TopologyRequirement, poolName string) (string, string, map[string]string, error) {
accessibilityRequirements *csi.TopologyRequirement, poolName string,
) (string, string, map[string]string, error) {
var topologyPool []TopologyConstrainedPool
if topologyPools == nil || accessibilityRequirements == nil {
@ -199,7 +201,8 @@ func MatchPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
// The return variables are, image poolname, data poolname, and topology map of
// matched requirement.
func FindPoolAndTopology(topologyPools *[]TopologyConstrainedPool,
accessibilityRequirements *csi.TopologyRequirement) (string, string, map[string]string, error) {
accessibilityRequirements *csi.TopologyRequirement,
) (string, string, map[string]string, error) {
if topologyPools == nil || accessibilityRequirements == nil {
return "", "", nil, nil
}

View File

@ -260,7 +260,8 @@ func GenerateVolID(
cr *Credentials,
locationID int64,
pool, clusterID, objUUID string,
volIDVersion uint16) (string, error) {
volIDVersion uint16,
) (string, error) {
var err error
if locationID == InvalidPoolID {

View File

@ -99,7 +99,7 @@ func (ci CSIIdentifier) ComposeCSIID() (string, error) {
/*
DecomposeCSIID composes a CSIIdentifier from passed in string.
*/
func (ci *CSIIdentifier) DecomposeCSIID(composedCSIID string) (err error) {
func (ci *CSIIdentifier) DecomposeCSIID(composedCSIID string) error {
bytesToProcess := uint16(len(composedCSIID))
// if length is less that expected constant elements, then bail out!