Skip to content

Commit 76904ab

Browse files
committed
fix lint issues
Signed-off-by: CrazyMax <[email protected]>
1 parent c5e4327 commit 76904ab

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,17 @@ ARG DEBIAN_FRONTEND
104104
RUN apt-get install -y --no-install-recommends libgcc-10-dev libc6-dev
105105
RUN --mount=type=bind,target=. \
106106
--mount=type=cache,target=/root/.cache \
107-
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
108-
golangci-lint run ./... && cd swarmd && golangci-lint run ./...
107+
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint <<EOT
108+
set -e
109+
config=$(pwd)/.golangci.yml
110+
for dir in . swarmd; do
111+
(
112+
set -x
113+
cd $dir
114+
golangci-lint run --config "$config" ./...
115+
)
116+
done
117+
EOT
109118

110119
FROM gobase AS fmt-proto
111120
RUN --mount=type=bind,target=. \

ca/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"math/big"
1010
"math/rand"
1111
"path/filepath"
12-
"slices"
1312
"strings"
1413
"sync"
1514
"time"
@@ -661,7 +660,7 @@ func NewServerTLSConfig(certs []tls.Certificate, rootCAPool *x509.CertPool) (*tl
661660
RootCAs: rootCAPool,
662661
ClientCAs: rootCAPool,
663662
PreferServerCipherSuites: true,
664-
CipherSuites: slices.Clone(strongTLSCiphers),
663+
CipherSuites: append([]uint16(nil), strongTLSCiphers...),
665664
MinVersion: tls.VersionTLS12,
666665
NextProtos: alpnProtoStr,
667666
}, nil
@@ -678,7 +677,7 @@ func NewClientTLSConfig(certs []tls.Certificate, rootCAPool *x509.CertPool, serv
678677
ServerName: serverName,
679678
Certificates: certs,
680679
RootCAs: rootCAPool,
681-
CipherSuites: slices.Clone(strongTLSCiphers),
680+
CipherSuites: append([]uint16(nil), strongTLSCiphers...),
682681
MinVersion: tls.VersionTLS12,
683682
}, nil
684683
}

manager/deks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func (r RaftDEKData) UnmarshalHeaders(headers map[string]string, kekData ca.KEKD
8181
func (r RaftDEKData) MarshalHeaders(kekData ca.KEKData) (map[string]string, error) {
8282
headers := make(map[string]string)
8383
for headerKey, contents := range map[string][]byte{
84-
pemHeaderRaftDEK: r.CurrentDEK,
85-
pemHeaderRaftPendingDEK: r.PendingDEK,
84+
pemHeaderRaftDEK: r.EncryptionKeys.CurrentDEK,
85+
pemHeaderRaftPendingDEK: r.EncryptionKeys.PendingDEK,
8686
} {
8787
if contents != nil {
8888
dekStr, err := encodePEMHeaderValue(contents, kekData.KEK, r.FIPS)

manager/state/raft/testutils/testutils.go

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
"google.golang.org/grpc"
13-
1412
"code.cloudfoundry.org/clock/fakeclock"
13+
"github.com/docker/go-events"
1514
"github.com/moby/swarmkit/v2/api"
1615
"github.com/moby/swarmkit/v2/ca"
1716
cautils "github.com/moby/swarmkit/v2/ca/testutils"
@@ -25,6 +24,7 @@ import (
2524
"github.com/stretchr/testify/require"
2625
etcdraft "go.etcd.io/etcd/raft/v3"
2726
"go.etcd.io/etcd/raft/v3/raftpb"
27+
"google.golang.org/grpc"
2828
)
2929

3030
// TestNode represents a raft test node
@@ -46,6 +46,38 @@ func (n *TestNode) Leader() uint64 {
4646
return id
4747
}
4848

49+
func (n *TestNode) Status() etcdraft.Status {
50+
return n.Node.Status()
51+
}
52+
53+
func (n *TestNode) Run(ctx context.Context) {
54+
n.Node.Run(ctx)
55+
}
56+
57+
func (n *TestNode) Done() <-chan struct{} {
58+
return n.Node.Done()
59+
}
60+
61+
func (n *TestNode) ProposeValue(ctx context.Context, actions []api.StoreAction, cb func()) error {
62+
return n.Node.ProposeValue(ctx, actions, cb)
63+
}
64+
65+
func (n *TestNode) MemoryStore() *store.MemoryStore {
66+
return n.Node.MemoryStore()
67+
}
68+
69+
func (n *TestNode) ReadyForProposals() bool {
70+
return n.Node.ReadyForProposals()
71+
}
72+
73+
func (n *TestNode) GetMemberlist() map[uint64]*api.RaftMember {
74+
return n.Node.GetMemberlist()
75+
}
76+
77+
func (n *TestNode) SubscribeLeadership() (q chan events.Event, cancel func()) {
78+
return n.Node.SubscribeLeadership()
79+
}
80+
4981
// AdvanceTicks advances the raft state machine fake clock
5082
func AdvanceTicks(clockSource *fakeclock.FakeClock, ticks int) {
5183
// A FakeClock timer won't fire multiple times if time is advanced
@@ -66,7 +98,7 @@ func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[ui
6698
prev = new(etcdraft.Status)
6799
*prev = n.Status()
68100
for _, n2 := range nodes {
69-
if n2.Config.ID == prev.Lead {
101+
if n2.Node.Config.ID == prev.Lead {
70102
leadNode = n2
71103
continue nodeLoop
72104
}
@@ -76,7 +108,7 @@ func WaitForCluster(t *testing.T, clockSource *fakeclock.FakeClock, nodes map[ui
76108
cur := n.Status()
77109

78110
for _, n2 := range nodes {
79-
if n2.Config.ID == cur.Lead {
111+
if n2.Node.Config.ID == cur.Lead {
80112
if cur.Lead != prev.Lead || cur.Term != prev.Term || cur.Applied != prev.Applied {
81113
return errors.New("state does not match on all nodes")
82114
}
@@ -496,7 +528,7 @@ func CleanupNonRunningNode(node *TestNode) {
496528
// belonging to the same cluster
497529
func Leader(nodes map[uint64]*TestNode) *TestNode {
498530
for _, n := range nodes {
499-
if n.Config.ID == n.Leader() {
531+
if n.Node.Config.ID == n.Leader() {
500532
return n
501533
}
502534
}

0 commit comments

Comments
 (0)