Skip to content

Commit

Permalink
make golangci-lint version 1.60.1 happy
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Schuppert <[email protected]>
  • Loading branch information
stuggi authored and openshift-cherrypick-robot committed Aug 26, 2024
1 parent 176b2d2 commit d442b26
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/common_openstackcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func CreateVIPNetworkList(
)
if err != nil {
if k8s_errors.IsNotFound(err) {
return uniqNetworksList, fmt.Errorf(fmt.Sprintf("OpenStackNet with NameLower %s not found!", netNameLower))
return uniqNetworksList, fmt.Errorf("OpenStackNet with NameLower %s not found", netNameLower)
}
// Error reading the object - requeue the request.
return uniqNetworksList, fmt.Errorf(fmt.Sprintf("Error getting OSNet with labelSelector %v", labelSelector))
return uniqNetworksList, fmt.Errorf("Error getting OSNet with labelSelector %v", labelSelector)
}

if _, value := networkList[netNameLower]; !value && network.Spec.VIP {
Expand Down
10 changes: 5 additions & 5 deletions api/v1beta1/common_openstacknet.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func AddOSNetConfigRefLabel(
}
osnet, err := GetOpenStackNetWithLabel(c, namespace, labelSelector)
if err != nil && k8s_errors.IsNotFound(err) {
return labels, fmt.Errorf(fmt.Sprintf("OpenStackNet %s not found reconcile again in 10 seconds", subnetName))
return labels, fmt.Errorf("OpenStackNet %s not found reconcile again in 10 seconds", subnetName)
} else if err != nil {
return labels, fmt.Errorf(fmt.Sprintf("Failed to get OpenStackNet %s ", subnetName))
return labels, fmt.Errorf("Failed to get OpenStackNet %s ", subnetName)
}

//
Expand Down Expand Up @@ -215,7 +215,7 @@ func GetOsNetCfg(

if err != nil {
if k8s_errors.IsNotFound(err) {
return nil, fmt.Errorf(fmt.Sprintf("%s with name %s not found", osNetCfg.DeepCopy().GroupVersionKind().Kind, osNetCfg.Name))
return nil, fmt.Errorf("%s with name %s not found", osNetCfg.DeepCopy().GroupVersionKind().Kind, osNetCfg.Name)
}
return nil, err
}
Expand All @@ -234,9 +234,9 @@ func ValidateNetworks(namespace string, networks []string) error {
}
osnet, err := GetOpenStackNetWithLabel(webhookClient, namespace, labelSelector)
if err != nil && k8s_errors.IsNotFound(err) {
return fmt.Errorf(fmt.Sprintf("%s %s not found, validate the object network list!", osnet.GetObjectKind().GroupVersionKind().Kind, subnetName))
return fmt.Errorf("%s %s not found, validate the object network list", osnet.GetObjectKind().GroupVersionKind().Kind, subnetName)
} else if err != nil {
return fmt.Errorf(fmt.Sprintf("Failed to get %s %s", osnet.Kind, subnetName))
return fmt.Errorf("Failed to get %s %s", osnet.Kind, subnetName)
}
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/openstackbaremetalset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ func (r *OpenStackBaremetalSet) ValidateCreate() error {
//
_, err := GetOsNetCfg(webhookClient, r.GetNamespace(), r.GetLabels()[shared.OpenStackNetConfigReconcileLabel])
if err != nil {
return fmt.Errorf(fmt.Sprintf("error getting OpenStackNetConfig %s - %s: %s",
return fmt.Errorf("error getting OpenStackNetConfig %s - %s: %w",
r.GetLabels()[shared.OpenStackNetConfigReconcileLabel],
r.Name,
err))
err)
}

//
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/openstackclient_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ func (r *OpenStackClient) ValidateCreate() error {
//
_, err := GetOsNetCfg(webhookClient, r.GetNamespace(), r.GetLabels()[shared.OpenStackNetConfigReconcileLabel])
if err != nil {
return fmt.Errorf(fmt.Sprintf("error getting OpenStackNetConfig %s - %s: %s",
return fmt.Errorf("error getting OpenStackNetConfig %s - %s: %w",
r.GetLabels()[shared.OpenStackNetConfigReconcileLabel],
r.Name,
err))
err)
}

//
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/openstackdeploy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (r *OpenStackDeploy) validateNNCP() error {

nncpReadyCount := 0
for _, nncp := range nncpList.Items {
if nncp.Status.Conditions != nil && len(nncp.Status.Conditions) > 0 {
if len(nncp.Status.Conditions) > 0 {
condition := nmstate.GetCurrentCondition(nncp.Status.Conditions)
if condition != nil {
if condition.Type == nmstateshared.NodeNetworkConfigurationPolicyConditionAvailable &&
Expand All @@ -171,7 +171,7 @@ func (r *OpenStackDeploy) validateNNCP() error {
var nnceError string
var nnce nmstatev1.NodeNetworkConfigurationEnactment
for _, nnce = range nnceList.Items {
if nnce.Status.Conditions != nil && len(nnce.Status.Conditions) > 0 {
if len(nnce.Status.Conditions) > 0 {
condition := nmstate.GetCurrentCondition(nnce.Status.Conditions)

// if the first nnce has condition.Reason == nmstateshared.NodeNetworkConfigurationEnactmentConditionFailedToConfigure
Expand Down Expand Up @@ -199,11 +199,11 @@ func (r *OpenStackDeploy) validateNNCP() error {
} else {
info := "It's recommended to resolve the failures before proceeding with the deployment. If this validation should be skipped add spec.SkipNNCPValidation: true"
openstackdeploylog.Error(
fmt.Errorf(msg),
fmt.Errorf("%s", msg),
info,
"name",
r.Name)
return fmt.Errorf(fmt.Sprintf("%s, %s", msg, info))
return fmt.Errorf("%s, %s", msg, info)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta2/common_openstackcontrolplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func CreateVIPNetworkList(
)
if err != nil {
if k8s_errors.IsNotFound(err) {
return uniqNetworksList, fmt.Errorf(fmt.Sprintf("OpenStackNet with NameLower %s not found!", netNameLower))
return uniqNetworksList, fmt.Errorf("OpenStackNet with NameLower %s not found", netNameLower)
}
// Error reading the object - requeue the request.
return uniqNetworksList, fmt.Errorf(fmt.Sprintf("Error getting OSNet with labelSelector %v", labelSelector))
return uniqNetworksList, fmt.Errorf("Error getting OSNet with labelSelector %v", labelSelector)
}

if _, value := networkList[netNameLower]; !value && network.Spec.VIP {
Expand Down
16 changes: 8 additions & 8 deletions api/v1beta2/common_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func validateAdditionalDisks(newDisks []OpenStackVMSetDisk, currentDisks []OpenS
// validate Disk Name is not 'rootdisk' as this is reserved for the boot disk
//
if disk.Name == "rootdisk" {
return fmt.Errorf(fmt.Sprintf("disk names must not be 'rootdisk' - %v", disk))
return fmt.Errorf("disk names must not be 'rootdisk' - %v", disk)
}

//
// validate Disk Name consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character
//
var validDiskName = regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)
if !validDiskName.MatchString(disk.Name) {
return fmt.Errorf(fmt.Sprintf("disk names must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character - %s", disk.Name))
return fmt.Errorf("disk names must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character - %s", disk.Name)
}

//
Expand All @@ -142,7 +142,7 @@ func validateAdditionalDisks(newDisks []OpenStackVMSetDisk, currentDisks []OpenS
if _, ok := disks[disk.Name]; !ok {
disks[disk.Name] = disk
} else {
return fmt.Errorf(fmt.Sprintf("disk names must be uniq within a VM role - %v : %v", disks[disk.Name], disk))
return fmt.Errorf("disk names must be uniq within a VM role - %v : %v", disks[disk.Name], disk)
}

//
Expand Down Expand Up @@ -189,7 +189,7 @@ func diskSizeChanged(diskName string, diskSize uint32, curDiskSize uint32) error
// validate DiskSize don't change
//
if diskSize != curDiskSize {
return fmt.Errorf(fmt.Sprintf("disk size must not change %s - new %v / current %v", diskName, diskSize, curDiskSize))
return fmt.Errorf("disk size must not change %s - new %v / current %v", diskName, diskSize, curDiskSize)
}

return nil
Expand All @@ -201,7 +201,7 @@ func storageAccessModeChanged(diskName string, accessMode string, curAccessMode
// validate StorageAccessMode don't change
//
if accessMode != curAccessMode {
return fmt.Errorf(fmt.Sprintf("StorageAccessMode must not change %s - new %v / current %v", diskName, accessMode, curAccessMode))
return fmt.Errorf("StorageAccessMode must not change %s - new %v / current %v", diskName, accessMode, curAccessMode)
}

return nil
Expand All @@ -213,7 +213,7 @@ func storageClassChanged(diskName string, storageClass string, curStorageClass s
// validate StorageClass don't change
//
if storageClass != curStorageClass {
return fmt.Errorf(fmt.Sprintf("StorageClass must not change %s - new %v / current %v", diskName, storageClass, curStorageClass))
return fmt.Errorf("StorageClass must not change %s - new %v / current %v", diskName, storageClass, curStorageClass)
}

return nil
Expand All @@ -225,7 +225,7 @@ func storageVolumeModeChanged(diskName string, volumeMode string, curVolumeMode
// validate StorageVolumeMode don't change
//
if volumeMode != curVolumeMode {
return fmt.Errorf(fmt.Sprintf("StorageVolumeMode must not change %s - new %v / current %v", diskName, volumeMode, curVolumeMode))
return fmt.Errorf("StorageVolumeMode must not change %s - new %v / current %v", diskName, volumeMode, curVolumeMode)
}

return nil
Expand All @@ -237,7 +237,7 @@ func baseImageVolumeNameChanged(diskName string, volumeName string, curVolumeNam
// validate BaseImageVolumeName don't change
//
if volumeName != curVolumeName {
return fmt.Errorf(fmt.Sprintf("BaseImageVolumeName must not change %s - new %v / current %v", diskName, volumeName, curVolumeName))
return fmt.Errorf("BaseImageVolumeName must not change %s - new %v / current %v", diskName, volumeName, curVolumeName)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta2/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ func (r *OpenStackControlPlane) ValidateCreate() error {
//
_, err := ospdirectorv1beta1.GetOsNetCfg(webhookClient, r.GetNamespace(), r.GetLabels()[shared.OpenStackNetConfigReconcileLabel])
if err != nil {
return fmt.Errorf(fmt.Sprintf("error getting OpenStackNetConfig %s - %s: %s",
return fmt.Errorf("error getting OpenStackNetConfig %s - %s: %w",
r.GetLabels()[shared.OpenStackNetConfigReconcileLabel],
r.Name,
err))
err)
}

//
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta2/openstackvmset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ func (r *OpenStackVMSet) ValidateCreate() error {
//
_, err := ospdirectorv1beta1.GetOsNetCfg(webhookClient, r.GetNamespace(), r.GetLabels()[shared.OpenStackNetConfigReconcileLabel])
if err != nil {
return fmt.Errorf(fmt.Sprintf("error getting OpenStackNetConfig %s - %s: %s",
return fmt.Errorf("error getting OpenStackNetConfig %s - %s: %w",
r.GetLabels()[shared.OpenStackNetConfigReconcileLabel],
r.Name,
err))
err)
}

//
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstackcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ func (r *OpenStackControlPlaneReconciler) ensureStorageVersionMigration(
)
cond.Reason = shared.ConditionReason(currentCond.Reason)
cond.Type = shared.ConditionType(currentCond.Type)
err := common.WrapErrorForObject(cond.Message, instance, fmt.Errorf(cond.Message))
err := common.WrapErrorForObject(cond.Message, instance, fmt.Errorf("%s", cond.Message))

return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, err
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstacknetattachment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (r *OpenStackNetAttachmentReconciler) getNodeNetworkConfigurationPolicyStat
//
// sync latest status of the nncp object to the osnetattach
//
if networkConfigurationPolicy.Status.Conditions != nil && len(networkConfigurationPolicy.Status.Conditions) > 0 {
if len(networkConfigurationPolicy.Status.Conditions) > 0 {
condition := nmstate.GetCurrentCondition(networkConfigurationPolicy.Status.Conditions)
if condition != nil {
cond.Message = fmt.Sprintf("%s %s: %s", networkConfigurationPolicy.Kind, networkConfigurationPolicy.Name, condition.Message)
Expand Down
8 changes: 4 additions & 4 deletions controllers/openstacknetconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func (r *OpenStackNetConfigReconciler) getNetAttachmentStatus(
//
// sync latest status of the osnetattach object to the osnetconfig
//
if netAttachment.Status.Conditions != nil && len(netAttachment.Status.Conditions) > 0 {
if len(netAttachment.Status.Conditions) > 0 {
condition := netAttachment.Status.Conditions.GetCurrentCondition()

if condition != nil {
Expand All @@ -531,7 +531,7 @@ func (r *OpenStackNetConfigReconciler) getNetAttachmentStatus(
cond.Message = fmt.Sprintf("OpenStackNetAttachment error: %s", condition.Message)
cond.Type = shared.NetConfigError

return fmt.Errorf(cond.Message)
return fmt.Errorf("%s", cond.Message)
}
}
}
Expand Down Expand Up @@ -708,7 +708,7 @@ func (r *OpenStackNetConfigReconciler) getNetStatus(
//
// sync latest status of the osnet object to the osnetconfig
//
if osNet.Status.Conditions != nil && len(osNet.Status.Conditions) > 0 {
if len(osNet.Status.Conditions) > 0 {
condition := osNet.Status.Conditions.GetCurrentCondition()

if condition != nil {
Expand All @@ -722,7 +722,7 @@ func (r *OpenStackNetConfigReconciler) getNetStatus(
cond.Type = shared.NetConfigError
common.LogForObject(r, cond.Message, instance)

return ctrl.Result{}, fmt.Errorf(cond.Message)
return ctrl.Result{}, fmt.Errorf("%s", cond.Message)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/openstackvmset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ func (r *OpenStackVMSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
//
if instance.Spec.RootDisk.DiskSize == 0 {
return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second},
fmt.Errorf(fmt.Sprintf("waiting for runtime object %s %s to be migrated to new API version",
fmt.Errorf("waiting for runtime object %s %s to be migrated to new API version",
instance.Kind,
instance.Name,
))
)
}

//
Expand Down Expand Up @@ -975,7 +975,7 @@ func (r *OpenStackVMSetReconciler) vmCreateInstance(
cond.Reason = shared.CommonCondReasonOSNetError
cond.Type = shared.CommonCondTypeError

return fmt.Errorf(cond.Message)
return fmt.Errorf("%s", cond.Message)
}

vm.Spec.Template.Spec.Domain.Devices.Interfaces = vmset.MergeVMInterfaces(
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func GetDataFromSecret(
cond.Reason = conditionDetails.ConditionNotFoundReason
cond.Type = conditionDetails.ConditionErrorType

return data, ctrl.Result{}, fmt.Errorf(cond.Message)
return data, ctrl.Result{}, fmt.Errorf("%s", cond.Message)
}
data = strings.TrimSuffix(string(val), "\n")
}
Expand Down

0 comments on commit d442b26

Please sign in to comment.