From b0efd685a959265fa3fb7c9a2032bc01e2a494fb Mon Sep 17 00:00:00 2001 From: Ed Robinson Date: Wed, 16 Nov 2016 08:56:52 +0000 Subject: [PATCH] Fix golint recent additions to golint mean that a number of files cause the build to start failing if they are edited (we only run against changed files) This fixes all the errors in the repo so things don't unexpectedly start failing for people making PRs --- acme/acme.go | 3 ++- acme/localStore.go | 2 +- cluster/datastore.go | 4 ++-- cluster/leadership.go | 4 ++-- configuration.go | 4 ++-- integration/consul_test.go | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/acme/acme.go b/acme/acme.go index 0c88caae3..6bb9d5341 100644 --- a/acme/acme.go +++ b/acme/acme.go @@ -119,11 +119,12 @@ func (a *ACME) CreateClusterConfig(leadership *cluster.Leadership, tlsConfig *tl } datastore, err := cluster.NewDataStore( + leadership.Pool.Ctx(), staert.KvSource{ Store: leadership.Store, Prefix: a.Storage, }, - leadership.Pool.Ctx(), &Account{}, + &Account{}, listener) if err != nil { return err diff --git a/acme/localStore.go b/acme/localStore.go index 7432411ee..f01e31d68 100644 --- a/acme/localStore.go +++ b/acme/localStore.go @@ -68,7 +68,7 @@ func (t *localTransaction) Commit(object cluster.Object) error { t.LocalStore.account = object.(*Account) defer t.storageLock.Unlock() if t.dirty { - return fmt.Errorf("Transaction already used. Please begin a new one.") + return fmt.Errorf("transaction already used, please begin a new one") } // write account to file diff --git a/cluster/datastore.go b/cluster/datastore.go index ff81215d9..ec396bb5e 100644 --- a/cluster/datastore.go +++ b/cluster/datastore.go @@ -56,7 +56,7 @@ type Datastore struct { } // NewDataStore creates a Datastore -func NewDataStore(kvSource staert.KvSource, ctx context.Context, object Object, listener Listener) (*Datastore, error) { +func NewDataStore(ctx context.Context, kvSource staert.KvSource, object Object, listener Listener) (*Datastore, error) { datastore := Datastore{ kv: kvSource, ctx: ctx, @@ -230,7 +230,7 @@ func (s *datastoreTransaction) Commit(object Object) error { s.localLock.Lock() defer s.localLock.Unlock() if s.dirty { - return fmt.Errorf("Transaction already used. Please begin a new one.") + return fmt.Errorf("transaction already used, please begin a new one") } s.Datastore.meta.object = object err := s.Datastore.meta.Marshall() diff --git a/cluster/leadership.go b/cluster/leadership.go index bcdff6a1d..80447fa90 100644 --- a/cluster/leadership.go +++ b/cluster/leadership.go @@ -39,7 +39,7 @@ func (l *Leadership) Participate(pool *safe.Pool) { defer log.Debugf("Node %s no more running for election", l.Cluster.Node) backOff := backoff.NewExponentialBackOff() operation := func() error { - return l.run(l.candidate, ctx) + return l.run(ctx, l.candidate) } notify := func(err error, time time.Duration) { @@ -63,7 +63,7 @@ func (l *Leadership) Resign() { log.Infof("Node %s resigned", l.Cluster.Node) } -func (l *Leadership) run(candidate *leadership.Candidate, ctx context.Context) error { +func (l *Leadership) run(ctx context.Context, candidate *leadership.Candidate) error { electedCh, errCh := candidate.RunForElection() for { select { diff --git a/configuration.go b/configuration.go index 754059854..4870b5b26 100644 --- a/configuration.go +++ b/configuration.go @@ -233,10 +233,10 @@ func (certs *Certificates) CreateTLSConfig() (*tls.Config, error) { if errKey == nil { isAPath = true } else { - return nil, fmt.Errorf("Bad TLS Certificate KeyFile format. Expected a path.") + return nil, fmt.Errorf("bad TLS Certificate KeyFile format, expected a path") } } else if errKey == nil { - return nil, fmt.Errorf("Bad TLS Certificate KeyFile format. Expected a path.") + return nil, fmt.Errorf("bad TLS Certificate KeyFile format, expected a path") } cert := tls.Certificate{} diff --git a/integration/consul_test.go b/integration/consul_test.go index d9b7b8218..e80e4747d 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -446,9 +446,9 @@ func (s *ConsulSuite) TestDatastore(c *check.C) { c.Assert(err, checker.IsNil) ctx := context.Background() - datastore1, err := cluster.NewDataStore(*kvSource, ctx, &TestStruct{}, nil) + datastore1, err := cluster.NewDataStore(ctx, *kvSource, &TestStruct{}, nil) c.Assert(err, checker.IsNil) - datastore2, err := cluster.NewDataStore(*kvSource, ctx, &TestStruct{}, nil) + datastore2, err := cluster.NewDataStore(ctx, *kvSource, &TestStruct{}, nil) c.Assert(err, checker.IsNil) setter1, _, err := datastore1.Begin()