Skip to content

Commit

Permalink
(bugbash) Fix Staticcheck warnings (#571)
Browse files Browse the repository at this point in the history
* Fix ST1019 static check
* Fix SA6005 staticcheck
* Fix S1008 staticcheck
* Fix S1021 staticcheck
* Fixed error in test file

Signed-off-by: Sahil Raja <[email protected]>
  • Loading branch information
rajaSahil authored and kmova committed May 6, 2021
1 parent 4c37bc8 commit 76542d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
20 changes: 9 additions & 11 deletions integration_tests/k8s/k8sapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
apis "github.com/openebs/node-disk-manager/pkg/apis/openebs/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
rbacv1beta1 "k8s.io/api/rbac/v1beta1"
apiextensionsV1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -43,7 +42,7 @@ const k8sReconcileTime = 10 * time.Second
// with their status
func (c K8sClient) ListPodStatus() (map[string]string, error) {
pods := make(map[string]string)
podList := &v1.PodList{}
podList := &corev1.PodList{}
podList, err := c.ClientSet.CoreV1().Pods(Namespace).List(metav1.ListOptions{})
if err != nil {
return nil, err
Expand All @@ -58,7 +57,7 @@ func (c K8sClient) ListPodStatus() (map[string]string, error) {
// their status
func (c K8sClient) ListNodeStatus() (map[string]string, error) {
nodes := make(map[string]string)
nodeList := &v1.NodeList{}
nodeList := &corev1.NodeList{}
nodeList, err := c.ClientSet.CoreV1().Nodes().List(metav1.ListOptions{})
if err != nil {
return nil, err
Expand All @@ -78,8 +77,7 @@ func (c K8sClient) ListBlockDevices() (*apis.BlockDeviceList, error) {
},
}

var err error
err = c.RunTimeClient.List(context.TODO(), bdList)
err := c.RunTimeClient.List(context.TODO(), bdList)
if err != nil {
return nil, fmt.Errorf("cannot list blockdevices. Error :%v", err)
}
Expand Down Expand Up @@ -152,37 +150,37 @@ func NewBDC(bdcName string) *apis.BlockDeviceClaim {
}

// CreateNamespace creates a namespace
func (c K8sClient) CreateNamespace(namespace v1.Namespace) error {
func (c K8sClient) CreateNamespace(namespace corev1.Namespace) error {
err := c.RunTimeClient.Create(context.Background(), &namespace)
return err
}

// DeleteNamespace deletes a namespace
func (c K8sClient) DeleteNamespace(namespace v1.Namespace) error {
func (c K8sClient) DeleteNamespace(namespace corev1.Namespace) error {
err := c.RunTimeClient.Delete(context.Background(), &namespace)
return err
}

// CreateConfigMap creates a config map
func (c K8sClient) CreateConfigMap(configMap v1.ConfigMap) error {
func (c K8sClient) CreateConfigMap(configMap corev1.ConfigMap) error {
err := c.RunTimeClient.Create(context.Background(), &configMap)
return err
}

// DeleteConfigMap deletes the config map
func (c K8sClient) DeleteConfigMap(configMap v1.ConfigMap) error {
func (c K8sClient) DeleteConfigMap(configMap corev1.ConfigMap) error {
err := c.RunTimeClient.Delete(context.Background(), &configMap)
return err
}

// CreateServiceAccount creates a service account
func (c K8sClient) CreateServiceAccount(serviceAccount v1.ServiceAccount) error {
func (c K8sClient) CreateServiceAccount(serviceAccount corev1.ServiceAccount) error {
err := c.RunTimeClient.Create(context.Background(), &serviceAccount)
return err
}

// DeleteServiceAc[2050]:4589616count deletes the service account
func (c K8sClient) DeleteServiceAccount(serviceAccount v1.ServiceAccount) error {
func (c K8sClient) DeleteServiceAccount(serviceAccount corev1.ServiceAccount) error {
err := c.RunTimeClient.Delete(context.Background(), &serviceAccount)
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/spdk/spdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (di *DeviceIdentifier) GetSPDKSuperBlockSignature() (string, error) {
spdk = (*C.struct_spdk_bs_super_block)(C.CBytes(buf))
defer C.free(unsafe.Pointer(spdk))

var ptr *C.char
ptr = (*C.char)(C.get_signature(spdk))
ptr := (*C.char)(C.get_signature(spdk))
return C.GoString(ptr), nil
}
5 changes: 1 addition & 4 deletions pkg/sysfs/syspath.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,5 @@ func (s Device) GetDeviceType(devType string) (string, error) {
}

func isDM(devName string) bool {
if devName[0:3] == "dm-" {
return true
}
return false
return devName[0:3] == "dm-"
}
2 changes: 1 addition & 1 deletion pkg/util/strutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Contains(s []string, k string) bool {
// in array else it returns false. This function is not case sensitive.
func ContainsIgnoredCase(s []string, k string) bool {
for _, e := range s {
if strings.ToLower(e) == strings.ToLower(k) {
if strings.EqualFold(e,k) {
return true
}
}
Expand Down

0 comments on commit 76542d9

Please sign in to comment.