Skip to content

Commit

Permalink
fix golint-issues
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Sch <sebassch@gmail.com>
  • Loading branch information
SchSeba committed Dec 1, 2022
1 parent df8d202 commit 376ff8b
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
4 changes: 1 addition & 3 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ func InitNicIDMapFromConfigMap(client kubernetes.Interface, namespace string) er
}

func InitNicIDMapFromList(idList []string) {
for _, v := range idList {
NicIDMap = append(NicIDMap, v)
}
NicIDMap = append(NicIDMap, idList...)
}

func IsSupportedVendor(vendorID string) bool {
Expand Down
8 changes: 4 additions & 4 deletions cmd/sriov-network-config-daemon/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"errors"
"flag"
"fmt"
"os"

"github.com/golang/glog"
"github.com/spf13/cobra"

sriovv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/generic"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/systemd"
"github.com/spf13/cobra"
"os"

"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/version"
)
Expand Down Expand Up @@ -111,7 +112,6 @@ func runServiceCmd(cmd *cobra.Command, args []string) {
glog.Errorf("sriov-config-service failed to create generic plugin %v", err)
return
}

} else if nodeStateSpec.PlatformType == utils.VirtualOpenStack {
// Openstack support
metaData, networkData, err := utils.GetOpenstackData(false)
Expand Down
4 changes: 4 additions & 0 deletions controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var webhooks = map[string](string){
constants.OperatorWebHookName: constants.OperatorWebHookPath,
}

const (
machineConfigCRDName = "MachineConfig"
)

var namespace = os.Getenv("NAMESPACE")

func GetImagePullSecrets() []string {
Expand Down
7 changes: 4 additions & 3 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package controllers
import (
"context"
"fmt"
machinev1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
"os"

appsv1 "k8s.io/api/apps/v1"
Expand All @@ -35,6 +34,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

machinev1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
apply "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/apply"
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
Expand Down Expand Up @@ -311,7 +312,7 @@ func (r *SriovOperatorConfigReconciler) deleteK8sResource(in *uns.Unstructured)

func (r *SriovOperatorConfigReconciler) syncK8sResource(cr *sriovnetworkv1.SriovOperatorConfig, in *uns.Unstructured) error {
switch in.GetKind() {
case "ClusterRole", "ClusterRoleBinding", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", "MachineConfig":
case "ClusterRole", "ClusterRoleBinding", "MutatingWebhookConfiguration", "ValidatingWebhookConfiguration", machineConfigCRDName:
default:
// set owner-reference only for namespaced objects
if err := controllerutil.SetControllerReference(cr, in, r.Scheme); err != nil {
Expand Down Expand Up @@ -361,7 +362,7 @@ func (r *SriovOperatorConfigReconciler) syncSystemdService(cr *sriovnetworkv1.Sr

// Sync machine config
for _, obj := range objs {
if obj.GetKind() == "MachineConfig" && len(cr.Spec.ConfigDaemonNodeSelector) > 0 {
if obj.GetKind() == machineConfigCRDName && len(cr.Spec.ConfigDaemonNodeSelector) > 0 {
scheme := kscheme.Scheme
mc := &machinev1.ControllerConfig{}
err = scheme.Convert(obj, mc, nil)
Expand Down
3 changes: 1 addition & 2 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ type Daemon struct {
}

const (
rdmaScriptsPath = "/bindata/scripts/enable-rdma.sh"
udevScriptsPath = "/bindata/scripts/load-udev.sh"
annoKey = "sriovnetwork.openshift.io/state"
annoIdle = "Idle"
Expand Down Expand Up @@ -219,7 +218,7 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error) error {
} else {
glog.V(0).Infof("Run(): start daemon.")
}
if dn.useSystemdService == true {
if dn.useSystemdService {
glog.V(0).Info("Run(): daemon running in systemd mode")
}
// Only watch own SriovNetworkNodeState CR
Expand Down
1 change: 1 addition & 0 deletions pkg/daemon/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package daemon

import (
"fmt"

"github.com/golang/glog"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
Expand Down
5 changes: 3 additions & 2 deletions pkg/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package host

import (
"fmt"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
"os"
"strings"

"github.com/golang/glog"

"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
)

const (
Expand Down Expand Up @@ -138,7 +139,7 @@ func (h *HostManager) TryEnableRdma() (bool, error) {
}

if isUbuntuSystem {

return h.enableRDMAOnUbuntuMachine()
}

osName, err := h.getOSPrettyName()
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/generic/generic_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package generic

import (
"bytes"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
"os/exec"
"reflect"
"strconv"
Expand All @@ -13,6 +12,7 @@ import (

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/virtual/virtual_plugin.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package virtual

import (
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
"reflect"

"github.com/golang/glog"
sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/consts"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
)
Expand Down
5 changes: 3 additions & 2 deletions pkg/systemd/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package systemd
import (
"bytes"
"fmt"
"github.com/golang/glog"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
"strings"

"github.com/golang/glog"
"gopkg.in/yaml.v3"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils_virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func getOpenstackDataFromConfigDrive(useHostPath bool) (metaData *OSPMetaData, n
networkData = &OSPNetworkData{}
glog.Infof("reading OpenStack meta_data from config-drive")
var metadataf *os.File
ospMetaDataFilePath := ospNetworkDataFile
ospMetaDataFilePath := ospMetaDataFile
if useHostPath {
ospMetaDataFilePath = ospHostMetaDataFile
}
Expand Down

0 comments on commit 376ff8b

Please sign in to comment.