Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zfspv) Add golint check to travis #175

Merged
merged 5 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ install:
fi
- make bootstrap
- make format
- make golint
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
&& chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.4.0/minikube-linux-amd64
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods \
# targets or for development purposes
EXTERNAL_TOOLS=\
golang.org/x/tools/cmd/cover \
github.com/golang/lint/golint \
golang.org/x/lint/golint \
github.com/axw/gocov/gocov \
gopkg.in/matm/v1/gocov-html \
github.com/onsi/ginkgo/ginkgo \
Expand Down Expand Up @@ -242,7 +242,7 @@ deploy-images:
.PHONY: golint
golint:
@echo "--> Running golint"
@echo "Consider these linter recommendations:"
@golint $(PACKAGES)
@golint -set_exit_status $(PACKAGES)
@echo "Completed golint no recommendations !!"
@echo "--------------------------------"
@echo ""
1 change: 1 addition & 0 deletions changelogs/unreleased/175-vaniisgh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add golint to travis & fix linting
8 changes: 8 additions & 0 deletions deploy/operators/centos7/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -417,6 +419,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -637,6 +641,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down Expand Up @@ -804,6 +810,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down
8 changes: 8 additions & 0 deletions deploy/operators/centos8/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -417,6 +419,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -637,6 +641,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down Expand Up @@ -804,6 +810,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down
4 changes: 4 additions & 0 deletions deploy/yamls/zfssnapshot-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down Expand Up @@ -363,6 +365,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down
4 changes: 4 additions & 0 deletions deploy/yamls/zfsvolume-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -396,6 +398,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down
8 changes: 8 additions & 0 deletions deploy/zfs-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -417,6 +419,8 @@ spec:
- volumeType
type: object
status:
description: VolStatus string that specifies the current state of the
volume provisioning request.
properties:
state:
description: State specifies the current state of the volume provisioning
Expand Down Expand Up @@ -637,6 +641,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down Expand Up @@ -804,6 +810,8 @@ spec:
- volumeType
type: object
status:
description: SnapStatus string that reflects if the snapshot was cretaed
successfully
properties:
state:
type: string
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/openebs.io/zfs/v1/zfssnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ type ZFSSnapshot struct {
Status SnapStatus `json:"status"`
}

// ZFSSnapshotList is a list of ZFSSnapshot resources
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfssnapshots

// ZFSSnapshotList is a list of ZFSSnapshot resources
type ZFSSnapshotList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ZFSSnapshot `json:"items"`
}

// SnapStatus string that reflects if the snapshot was cretaed successfully
type SnapStatus struct {
State string `json:"state,omitempty"`
}
4 changes: 2 additions & 2 deletions pkg/apis/openebs.io/zfs/v1/zfsvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ type MountInfo struct {
MountOptions []string `json:"mountOptions"`
}

// ZFSVolumeList is a list of ZFSVolume resources
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfsvolumes

// ZFSVolumeList is a list of ZFSVolume resources
type ZFSVolumeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Expand Down Expand Up @@ -202,6 +201,7 @@ type VolumeInfo struct {
Shared string `json:"shared,omitempty"`
}

// VolStatus string that specifies the current state of the volume provisioning request.
type VolStatus struct {
// State specifies the current state of the volume provisioning request.
// The state "Pending" means that the volume creation request has not
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/openebs.io/zfs/v1alpha1/zfssnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ type ZFSSnapshot struct {
Status SnapStatus `json:"status"`
}

// ZFSSnapshotList is a list of ZFSSnapshot resources
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfssnapshots

// ZFSSnapshotList is a list of ZFSSnapshot resources
type ZFSSnapshotList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ZFSSnapshot `json:"items"`
}

// SnapStatus string that reflects if the snapshot was cretaed successfully
type SnapStatus struct {
State string `json:"state,omitempty"`
}
4 changes: 2 additions & 2 deletions pkg/apis/openebs.io/zfs/v1alpha1/zfsvolume.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ type MountInfo struct {
MountOptions []string `json:"mountOptions"`
}

// ZFSVolumeList is a list of ZFSVolume resources
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=zfsvolumes

// ZFSVolumeList is a list of ZFSVolume resources
type ZFSVolumeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Expand Down Expand Up @@ -194,6 +193,7 @@ type VolumeInfo struct {
FsType string `json:"fsType,omitempty"`
}

// VolStatus string that specifies the current state of the volume provisioning request.
type VolStatus struct {
// State specifies the current state of the volume provisioning request.
// The state "Pending" means that the volume creation request has not
Expand Down
9 changes: 5 additions & 4 deletions pkg/client/k8s/v1alpha1/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ type ClientsetGetter interface {
Get() (*kubernetes.Clientset, error)
}

type clientset struct{}
// ClientsetStruct is used to export a kuberneter Clientset
type ClientsetStruct struct{}

// Clientset returns a pointer to clientset struct
func Clientset() *clientset {
return &clientset{}
func Clientset() *ClientsetStruct {
return &ClientsetStruct{}
}

// Get returns a new instance of kubernetes clientset
func (c *clientset) Get() (*kubernetes.Clientset, error) {
func (c *ClientsetStruct) Get() (*kubernetes.Clientset, error) {
config, err := Config().Get()
if err != nil {
return nil, errors.Wrap(err, "failed to get kubernetes clientset")
Expand Down
12 changes: 7 additions & 5 deletions pkg/client/k8s/v1alpha1/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ limitations under the License.
package v1alpha1

import (
"strings"

"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
)

// ConfigMapGetter abstracts fetching of ConfigMap instance from kubernetes
Expand All @@ -29,18 +30,19 @@ type ConfigMapGetter interface {
Get(options metav1.GetOptions) (*corev1.ConfigMap, error)
}

type configmap struct {
// Configmap is used to initialise a kubernetes Configmap struct
type Configmap struct {
namespace string // namespace where this configmap exists
name string // name of this configmap
}

// ConfigMap returns a new instance of configmap
func ConfigMap(namespace, name string) *configmap {
return &configmap{namespace: namespace, name: name}
func ConfigMap(namespace, name string) *Configmap {
return &Configmap{namespace: namespace, name: name}
}

// Get returns configmap instance from kubernetes cluster
func (c *configmap) Get(options metav1.GetOptions) (cm *corev1.ConfigMap, err error) {
func (c *Configmap) Get(options metav1.GetOptions) (cm *corev1.ConfigMap, err error) {
if len(strings.TrimSpace(c.name)) == 0 {
return nil, errors.Errorf("missing config map name: failed to get config map from namespace %s", c.namespace)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/client/k8s/v1alpha1/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ limitations under the License.
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// test if configmap implements ConfigMapGetter interface
var _ ConfigMapGetter = &configmap{}
var _ ConfigMapGetter = &Configmap{}

func TestConfigMapGet(t *testing.T) {
tests := map[string]struct {
Expand Down
9 changes: 5 additions & 4 deletions pkg/client/k8s/v1alpha1/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ type DynamicProvider interface {
Provide() (k8sdynamic.Interface, error)
}

type dynamic struct{}
//DynamicStruct is used to initialise a kuberenets dynamic interface
type DynamicStruct struct{}

// Dynamic returns a new instance of dynamic
func Dynamic() *dynamic {
return &dynamic{}
func Dynamic() *DynamicStruct {
return &DynamicStruct{}
}

// Provide provides a kubernetes dynamic client capable of invoking operations
// against kubernetes resources
func (d *dynamic) Provide() (k8sdynamic.Interface, error) {
func (d *DynamicStruct) Provide() (k8sdynamic.Interface, error) {
config, err := Config().Get()
if err != nil {
return nil, errors.Wrap(err, "failed to provide dynamic client")
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/k8s/v1alpha1/dynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// test if dynamic implements DynamicProvider interface
var _ DynamicProvider = &dynamic{}
var _ DynamicProvider = &DynamicStruct{}

func TestDynamicProvider(t *testing.T) {
tests := map[string]struct {
Expand Down
12 changes: 7 additions & 5 deletions pkg/client/k8s/v1alpha1/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ type NamespaceGetter interface {
type NamespaceLister interface {
List(options metav1.ListOptions) (*corev1.NamespaceList, error)
}
type namespace struct{}

// NamespaceStruct is used to initialise kubernetes namespace instnaces
type NamespaceStruct struct{}

// Namespace returns a pointer to the namespace struct
func Namespace() *namespace {
return &namespace{}
func Namespace() *NamespaceStruct {
return &NamespaceStruct{}
}

// Get returns a namespace instance from kubernetes cluster
func (ns *namespace) Get(name string, options metav1.GetOptions) (*corev1.Namespace, error) {
func (ns *NamespaceStruct) Get(name string, options metav1.GetOptions) (*corev1.Namespace, error) {
cs, err := Clientset().Get()
if err != nil {
return nil, errors.Wrapf(err, "failed to get namespace: %s", name)
Expand All @@ -48,7 +50,7 @@ func (ns *namespace) Get(name string, options metav1.GetOptions) (*corev1.Namesp
}

// List returns a slice of namespaces defined in a Kubernetes cluster
func (ns *namespace) List(options metav1.ListOptions) (*corev1.NamespaceList, error) {
func (ns *NamespaceStruct) List(options metav1.ListOptions) (*corev1.NamespaceList, error) {
cs, err := Clientset().Get()
if err != nil {
return nil, errors.Wrapf(err, "failed to get namespaces")
Expand Down
Loading