Browse code

daemon/cluster: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2022/01/20 21:52:02
Showing 8 changed files
... ...
@@ -140,7 +140,7 @@ type attacher struct {
140 140
 // New creates a new Cluster instance using provided config.
141 141
 func New(config Config) (*Cluster, error) {
142 142
 	root := filepath.Join(config.Root, swarmDirName)
143
-	if err := os.MkdirAll(root, 0700); err != nil {
143
+	if err := os.MkdirAll(root, 0o700); err != nil {
144 144
 		return nil, err
145 145
 	}
146 146
 	if config.RuntimeRoot == "" {
... ...
@@ -154,7 +154,7 @@ func New(config Config) (*Cluster, error) {
154 154
 		config.RaftElectionTick = 10 * config.RaftHeartbeatTick
155 155
 	}
156 156
 
157
-	if err := os.MkdirAll(config.RuntimeRoot, 0700); err != nil {
157
+	if err := os.MkdirAll(config.RuntimeRoot, 0o700); err != nil {
158 158
 		return nil, err
159 159
 	}
160 160
 	c := &Cluster{
... ...
@@ -66,7 +66,8 @@ func NewController(backend Backend, t *api.Task) (*Controller, error) {
66 66
 			"controller": "plugin",
67 67
 			"task":       t.ID,
68 68
 			"plugin":     spec.Name,
69
-		})}, nil
69
+		}),
70
+	}, nil
70 71
 }
71 72
 
72 73
 func readSpec(t *api.Task) (runtime.PluginSpec, error) {
... ...
@@ -118,7 +118,8 @@ func endpointFromGRPC(e *swarmapi.Endpoint) types.Endpoint {
118 118
 		for _, v := range e.VirtualIPs {
119 119
 			endpoint.VirtualIPs = append(endpoint.VirtualIPs, types.EndpointVirtualIP{
120 120
 				NetworkID: v.NetworkID,
121
-				Addr:      v.Addr})
121
+				Addr:      v.Addr,
122
+			})
122 123
 		}
123 124
 	}
124 125
 
... ...
@@ -15,12 +15,12 @@ func TestNodeCSIInfoFromGRPC(t *testing.T) {
15 15
 		ID: "someID",
16 16
 		Description: &swarmapi.NodeDescription{
17 17
 			CSIInfo: []*swarmapi.NodeCSIInfo{
18
-				&swarmapi.NodeCSIInfo{
18
+				{
19 19
 					PluginName:        "plugin1",
20 20
 					NodeID:            "p1n1",
21 21
 					MaxVolumesPerNode: 1,
22 22
 				},
23
-				&swarmapi.NodeCSIInfo{
23
+				{
24 24
 					PluginName:        "plugin2",
25 25
 					NodeID:            "p2n1",
26 26
 					MaxVolumesPerNode: 2,
... ...
@@ -412,7 +412,7 @@ func (c *containerAdapter) wait(ctx context.Context) (<-chan containerpkg.StateS
412 412
 }
413 413
 
414 414
 func (c *containerAdapter) shutdown(ctx context.Context) error {
415
-	var options = containertypes.StopOptions{}
415
+	options := containertypes.StopOptions{}
416 416
 	// Default stop grace period to nil (daemon will use the stopTimeout of the container)
417 417
 	if spec := c.container.spec(); spec.StopGracePeriod != nil {
418 418
 		timeout := int(spec.StopGracePeriod.Seconds)
... ...
@@ -1,9 +1,8 @@
1 1
 package container // import "github.com/docker/docker/daemon/cluster/executor/container"
2 2
 
3 3
 import (
4
-	"testing"
5
-
6 4
 	"context"
5
+	"testing"
7 6
 	"time"
8 7
 
9 8
 	"github.com/docker/docker/daemon"
... ...
@@ -142,6 +142,7 @@ func getDataPathPort(portNum uint32) (uint32, error) {
142 142
 	}
143 143
 	return portNum, nil
144 144
 }
145
+
145 146
 func resolveDataPathAddr(dataPathAddr string) (string, error) {
146 147
 	if dataPathAddr == "" {
147 148
 		// dataPathAddr is not defined
... ...
@@ -32,7 +32,7 @@ func savePersistentState(root string, config nodeStartConfig) error {
32 32
 	if err != nil {
33 33
 		return err
34 34
 	}
35
-	return ioutils.AtomicWriteFile(filepath.Join(root, stateFile), dt, 0600)
35
+	return ioutils.AtomicWriteFile(filepath.Join(root, stateFile), dt, 0o600)
36 36
 }
37 37
 
38 38
 func clearPersistentState(root string) error {