diff --git a/.golangci.yml b/.golangci.yml index ba85f7f08..85e7b7224 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,3 +14,12 @@ linters: - varcheck - deadcode - misspell + +issues: + exclude-use-default: false + exclude: + # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok + - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked + + # EXC0003 golint: False positive when tests are defined in package 'test' + - func name will be used as test\.Test.* by other packages, and that stutters; consider calling this \ No newline at end of file diff --git a/cmd/virtual-kubelet/internal/commands/root/tracing_register.go b/cmd/virtual-kubelet/internal/commands/root/tracing_register.go index a183126ac..1303456e2 100644 --- a/cmd/virtual-kubelet/internal/commands/root/tracing_register.go +++ b/cmd/virtual-kubelet/internal/commands/root/tracing_register.go @@ -19,7 +19,7 @@ import ( "go.opencensus.io/trace" ) -type TracingExporterOptions struct { +type TracingExporterOptions struct { // nolint: golint Tags map[string]string ServiceName string } diff --git a/cmd/virtual-kubelet/internal/provider/mock/mock.go b/cmd/virtual-kubelet/internal/provider/mock/mock.go index 5ed05434d..1c44c9ca1 100644 --- a/cmd/virtual-kubelet/internal/provider/mock/mock.go +++ b/cmd/virtual-kubelet/internal/provider/mock/mock.go @@ -328,7 +328,7 @@ func (p *MockProvider) GetPods(ctx context.Context) ([]*v1.Pod, error) { return pods, nil } -func (p *MockProvider) ConfigureNode(ctx context.Context, n *v1.Node) { +func (p *MockProvider) ConfigureNode(ctx context.Context, n *v1.Node) { // nolint:golint ctx, span := trace.StartSpan(ctx, "mock.ConfigureNode") // nolint:staticcheck,ineffassign defer span.End() diff --git a/cmd/virtual-kubelet/internal/provider/store.go b/cmd/virtual-kubelet/internal/provider/store.go index f711513f1..2601d6a66 100644 --- a/cmd/virtual-kubelet/internal/provider/store.go +++ b/cmd/virtual-kubelet/internal/provider/store.go @@ -13,7 +13,7 @@ type Store struct { ls map[string]InitFunc } -func NewStore() *Store { +func NewStore() *Store { // nolint:golint return &Store{ ls: make(map[string]InitFunc), } @@ -71,4 +71,4 @@ type InitConfig struct { ResourceManager *manager.ResourceManager } -type InitFunc func(InitConfig) (Provider, error) +type InitFunc func(InitConfig) (Provider, error) // nolint:golint diff --git a/cmd/virtual-kubelet/internal/provider/types.go b/cmd/virtual-kubelet/internal/provider/types.go index 8c507840f..f99e3bc1e 100644 --- a/cmd/virtual-kubelet/internal/provider/types.go +++ b/cmd/virtual-kubelet/internal/provider/types.go @@ -7,7 +7,7 @@ const ( OperatingSystemWindows = "Windows" ) -type OperatingSystems map[string]bool +type OperatingSystems map[string]bool // nolint:golint var ( // ValidOperatingSystems defines the group of operating systems @@ -18,7 +18,7 @@ var ( } ) -func (o OperatingSystems) Names() []string { +func (o OperatingSystems) Names() []string { // nolint:golint keys := make([]string, 0, len(o)) for k := range o { keys = append(keys, k) diff --git a/errdefs/invalid.go b/errdefs/invalid.go index 4816557b0..51e400266 100644 --- a/errdefs/invalid.go +++ b/errdefs/invalid.go @@ -5,7 +5,7 @@ import ( "fmt" ) -// InvalidInput is an error interface which denotes whether the opration failed due +// ErrInvalidInput is an error interface which denotes whether the opration failed due // to a the resource not being found. type ErrInvalidInput interface { InvalidInput() bool diff --git a/errdefs/notfound.go b/errdefs/notfound.go index cdc60ca25..a944f5117 100644 --- a/errdefs/notfound.go +++ b/errdefs/notfound.go @@ -5,7 +5,7 @@ import ( "fmt" ) -// NotFound is an error interface which denotes whether the opration failed due +// ErrNotFound is an error interface which denotes whether the opration failed due // to a the resource not being found. type ErrNotFound interface { NotFound() bool diff --git a/internal/lock/monitor.go b/internal/lock/monitor.go index 331ddc610..7feeb0a56 100644 --- a/internal/lock/monitor.go +++ b/internal/lock/monitor.go @@ -31,6 +31,8 @@ type Subscription interface { Value() Value } +// Value contains the last set value from Set(). If the value is unset the version will be 0, and the value will be +// nil. type Value struct { Value interface{} Version int64 diff --git a/internal/test/e2e/framework/pod.go b/internal/test/e2e/framework/pod.go index 2054cc0c7..7a3f93d79 100644 --- a/internal/test/e2e/framework/pod.go +++ b/internal/test/e2e/framework/pod.go @@ -183,7 +183,7 @@ func (f *Framework) GetRunningPodsFromProvider(ctx context.Context) (*corev1.Pod return result, err } -// GetRunningPodsFromProvider gets the running pods from the provider of the virtual kubelet +// GetRunningPodsFromKubernetes gets the running pods from the provider of the virtual kubelet func (f *Framework) GetRunningPodsFromKubernetes(ctx context.Context) (*corev1.PodList, error) { result := &corev1.PodList{} diff --git a/node/api/exec.go b/node/api/exec.go index 938a1fcf3..e15a9d52e 100644 --- a/node/api/exec.go +++ b/node/api/exec.go @@ -49,9 +49,6 @@ type TermSize struct { Height uint16 } -// HandleContainerExec makes an http handler func from a Provider which execs a command in a pod's container -// Note that this handler currently depends on gorrilla/mux to get url parts as variables. -// TODO(@cpuguy83): don't force gorilla/mux on consumers of this function // ContainerExecHandlerConfig is used to pass options to options to the container exec handler. type ContainerExecHandlerConfig struct { // StreamIdleTimeout is the maximum time a streaming connection @@ -72,7 +69,7 @@ func WithExecStreamIdleTimeout(dur time.Duration) ContainerExecHandlerOption { } } -// WithExecStreamIdleTimeout sets the idle timeout for a container exec stream +// WithExecStreamCreationTimeout sets the creation timeout for a container exec stream func WithExecStreamCreationTimeout(dur time.Duration) ContainerExecHandlerOption { return func(cfg *ContainerExecHandlerConfig) { cfg.StreamCreationTimeout = dur diff --git a/node/api/pods.go b/node/api/pods.go index 0faf12fe7..6142c17b9 100644 --- a/node/api/pods.go +++ b/node/api/pods.go @@ -24,9 +24,9 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" ) -type PodListerFunc func(context.Context) ([]*v1.Pod, error) +type PodListerFunc func(context.Context) ([]*v1.Pod, error) // nolint:golint -func HandleRunningPods(getPods PodListerFunc) http.HandlerFunc { +func HandleRunningPods(getPods PodListerFunc) http.HandlerFunc { // nolint:golint if getPods == nil { return NotImplemented } diff --git a/node/api/server.go b/node/api/server.go index eba8e88aa..a2da257ec 100644 --- a/node/api/server.go +++ b/node/api/server.go @@ -33,7 +33,7 @@ type ServeMux interface { Handle(path string, h http.Handler) } -type PodHandlerConfig struct { +type PodHandlerConfig struct { // nolint:golint RunInContainer ContainerExecHandlerFunc GetContainerLogs ContainerLogsHandlerFunc // GetPods is meant to enumerate the pods that the provider knows about