Browse code

builder/builder-next: 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:47:31
Showing 6 changed files
... ...
@@ -154,8 +154,7 @@ func parseCreatedLayerInfo(img image) ([]string, []string, error) {
154 154
 	return dates, createdBy, nil
155 155
 }
156 156
 
157
-type emptyProvider struct {
158
-}
157
+type emptyProvider struct{}
159 158
 
160 159
 func (p *emptyProvider) ReaderAt(ctx context.Context, dec ocispec.Descriptor) (content.ReaderAt, error) {
161 160
 	return nil, errors.Errorf("ReaderAt not implemented for empty provider")
... ...
@@ -21,11 +21,13 @@ import (
21 21
 	bolt "go.etcd.io/bbolt"
22 22
 )
23 23
 
24
-var keyParent = []byte("parent")
25
-var keyCommitted = []byte("committed")
26
-var keyIsCommitted = []byte("iscommitted")
27
-var keyChainID = []byte("chainid")
28
-var keySize = []byte("size")
24
+var (
25
+	keyParent      = []byte("parent")
26
+	keyCommitted   = []byte("committed")
27
+	keyIsCommitted = []byte("iscommitted")
28
+	keyChainID     = []byte("chainid")
29
+	keySize        = []byte("size")
30
+)
29 31
 
30 32
 // Opt defines options for creating the snapshotter
31 33
 type Opt struct {
... ...
@@ -57,7 +59,7 @@ type snapshotter struct {
57 57
 // NewSnapshotter creates a new snapshotter
58 58
 func NewSnapshotter(opt Opt, prevLM leases.Manager) (snapshot.Snapshotter, leases.Manager, error) {
59 59
 	dbPath := filepath.Join(opt.Root, "snapshots.db")
60
-	db, err := bolt.Open(dbPath, 0600, nil)
60
+	db, err := bolt.Open(dbPath, 0o600, nil)
61 61
 	if err != nil {
62 62
 		return nil, nil, errors.Wrapf(err, "failed to open database file %s", dbPath)
63 63
 	}
... ...
@@ -224,7 +224,7 @@ func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.
224 224
 		return nil, errors.Errorf("multiple outputs not supported")
225 225
 	}
226 226
 
227
-	var rc = opt.Source
227
+	rc := opt.Source
228 228
 	if buildID := opt.Options.BuildID; buildID != "" {
229 229
 		b.mu.Lock()
230 230
 
... ...
@@ -466,6 +466,7 @@ func (sp *streamProxy) SetTrailer(_ grpcmetadata.MD) {
466 466
 func (sp *streamProxy) Context() context.Context {
467 467
 	return sp.ctx
468 468
 }
469
+
469 470
 func (sp *streamProxy) RecvMsg(m interface{}) error {
470 471
 	return io.EOF
471 472
 }
... ...
@@ -478,6 +479,7 @@ type statusProxy struct {
478 478
 func (sp *statusProxy) Send(resp *controlapi.StatusResponse) error {
479 479
 	return sp.SendMsg(resp)
480 480
 }
481
+
481 482
 func (sp *statusProxy) SendMsg(m interface{}) error {
482 483
 	if sr, ok := m.(*controlapi.StatusResponse); ok {
483 484
 		sp.ch <- sr
... ...
@@ -493,6 +495,7 @@ type pruneProxy struct {
493 493
 func (sp *pruneProxy) Send(resp *controlapi.UsageRecord) error {
494 494
 	return sp.SendMsg(resp)
495 495
 }
496
+
496 497
 func (sp *pruneProxy) SendMsg(m interface{}) error {
497 498
 	if sr, ok := m.(*controlapi.UsageRecord); ok {
498 499
 		sp.ch <- sr
... ...
@@ -195,7 +195,7 @@ func newGraphDriverController(ctx context.Context, rt http.RoundTripper, opt Opt
195 195
 		return nil, err
196 196
 	}
197 197
 
198
-	db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0644, nil)
198
+	db, err := bolt.Open(filepath.Join(root, "containerdmeta.db"), 0o644, nil)
199 199
 	if err != nil {
200 200
 		return nil, errors.WithStack(err)
201 201
 	}
... ...
@@ -15,8 +15,7 @@ func newExecutor(_, _ string, _ *libnetwork.Controller, _ *oci.DNSConfig, _ bool
15 15
 	return &winExecutor{}, nil
16 16
 }
17 17
 
18
-type winExecutor struct {
19
-}
18
+type winExecutor struct{}
20 19
 
21 20
 func (w *winExecutor) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
22 21
 	return errors.New("buildkit executor not implemented for windows")
... ...
@@ -520,8 +520,7 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
520 520
 	}
521 521
 }
522 522
 
523
-type emptyProvider struct {
524
-}
523
+type emptyProvider struct{}
525 524
 
526 525
 func (p *emptyProvider) ReaderAt(ctx context.Context, dec ocispec.Descriptor) (content.ReaderAt, error) {
527 526
 	return nil, errors.Errorf("ReaderAt not implemented for empty provider")