Skip to content
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
14 changes: 14 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
run:
tests: false
linters:
disable-all: true
enable:
- misspell
- gofmt
- goimports
- golint
- ineffassign
- deadcode
- unconvert
- govet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dperny
Do you want to exclude auto generated protobuf files pb.go and vendor directory?
Similar to gometalinter , golangci supports a deadline flag

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably do, but currently those actually pass linting, so I didn't worry about actually doing it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how much extra time do they add ? if it's significant , shall we add them now?

17 changes: 0 additions & 17 deletions .gometalinter.json

This file was deleted.

2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func (a *Agent) nodeDescriptionWithHostname(ctx context.Context, tlsInfo *api.No

// Override hostname and TLS info
if desc != nil {
if a.config.Hostname != "" && desc != nil {
if a.config.Hostname != "" {
desc.Hostname = a.config.Hostname
}
desc.TLSInfo = tlsInfo
Expand Down
2 changes: 1 addition & 1 deletion agent/exec/dockerapi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func parsePortMap(portMap nat.PortMap) ([]*api.PortConfig, error) {
return nil, err
}

protocol := api.ProtocolTCP
var protocol api.PortConfig_Protocol
switch strings.ToLower(parts[1]) {
case "tcp":
protocol = api.ProtocolTCP
Expand Down
4 changes: 2 additions & 2 deletions agent/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *session) start(ctx context.Context, description *api.NodeDescription) e
// `ctx` is done and hence fail to propagate the timeout error to the agent.
// If the error is not propogated to the agent, the agent will not close
// the session or rebuild a new session.
sessionCtx, cancelSession := context.WithCancel(ctx) // nolint: vet
sessionCtx, cancelSession := context.WithCancel(ctx) //nolint:govet

// Need to run Session in a goroutine since there's no way to set a
// timeout for an individual Recv call in a stream.
Expand All @@ -159,7 +159,7 @@ func (s *session) start(ctx context.Context, description *api.NodeDescription) e
select {
case err := <-errChan:
if err != nil {
return err // nolint: vet
return err //nolint:govet
}
case <-time.After(dispatcherRPCTimeout):
cancelSession()
Expand Down
2 changes: 1 addition & 1 deletion cmd/swarmctl/service/flagparser/tmpfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func parseTmpfs(flags *pflag.FlagSet, spec *api.ServiceSpec) error {
// remove suffix and try again
suffix := meat[len(meat)-1]
meat = meat[:len(meat)-1]
var multiplier int64 = 1
var multiplier int64
switch suffix {
case 'g':
multiplier = 1 << 30
Expand Down
6 changes: 3 additions & 3 deletions direct.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ version/version.go:
setup: ## install dependencies
@echo "🐳 $@"
# TODO(stevvooe): Install these from the vendor directory
@go get -u github.com/alecthomas/gometalinter
@gometalinter --install
# install golangci-lint version 1.17.1 to ./bin/golangci-lint
@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1
@go get -u github.com/lk4d4/vndr
@go get -u github.com/stevvooe/protobuild

Expand All @@ -65,7 +65,7 @@ checkprotos: generate ## check if protobufs needs to be generated again
check: fmt-proto
check: ## Run various source code validation tools
@echo "🐳 $@"
@gometalinter ./...
@./bin/golangci-lint run

.PHONY: fmt-proto
fmt-proto:
Expand Down
2 changes: 1 addition & 1 deletion manager/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (d *Dispatcher) Run(ctx context.Context) error {
if err != nil {
return err
}
if err == nil && len(clusters) == 1 {
if len(clusters) == 1 {
heartbeatPeriod, err := gogotypes.DurationFromProto(clusters[0].Spec.Dispatcher.HeartbeatPeriod)
if err == nil && heartbeatPeriod > 0 {
d.config.HeartbeatPeriod = heartbeatPeriod
Expand Down
2 changes: 1 addition & 1 deletion manager/drivers/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (m *DriverProvider) NewSecretDriver(driver *api.Driver) (*SecretDriver, err
if m.pluginGetter == nil {
return nil, fmt.Errorf("plugin getter is nil")
}
if driver == nil && driver.Name == "" {
if driver == nil || driver.Name == "" {
Copy link
Copy Markdown
Contributor

@dani-docker dani-docker Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nitpick, shall we change the error to driver specification is not set ? as long as no caller is checking the actual error string

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably ends up just getting logged, and I don't think it needs to be changed in this particular PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

return nil, fmt.Errorf("driver specification is nil")
}
// Search for the specified plugin
Expand Down
9 changes: 1 addition & 8 deletions manager/orchestrator/restart/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,13 @@ func (r *Supervisor) Cancel(taskID string) {
<-delay.doneCh
}

// CancelAll aborts all pending restarts and waits for any instances of
// StartNow that have already triggered to complete.
// CancelAll aborts all pending restarts
func (r *Supervisor) CancelAll() {
var cancelled []delayedStart

r.mu.Lock()
for _, delay := range r.delays {
delay.cancel()
}
r.mu.Unlock()

for _, delay := range cancelled {
<-delay.doneCh
}
}

// ClearServiceHistory forgets restart history related to a given service ID.
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/docker/swarmkit/manager/encryption"
"github.com/docker/swarmkit/remotes"
"github.com/docker/swarmkit/xnet"
"github.com/grpc-ecosystem/go-grpc-prometheus"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt"
Expand Down