Skip to content

Commit d66b862

Browse files
committed
libindex: various lints
Signed-off-by: Hank Donnay <hdonnay@redhat.com> Change-Id: Ie36484d4b76a2dba60cebeb260c3c22e6a6a6964
1 parent 01de0f0 commit d66b862

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

libindex/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Package libindex is the claircore Indexer.
2+
//
3+
// The Indexer is the component that analyzes container images (or
4+
// container-like filesystems) and produces IndexReports.
5+
package libindex

libindex/fetcher_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,18 @@ func commonLayerServer(t testing.TB, ct int) ([]claircore.LayerDescription, http
231231

232232
t.Cleanup(func() {
233233
// We know we're doing 2 sets of fetches.
234-
max := ct * 2 * runtime.GOMAXPROCS(0)
234+
limit := ct * 2 * runtime.GOMAXPROCS(0)
235235
var total int
236236
for _, v := range fetch {
237237
total += int(*v)
238238
}
239239
switch {
240-
case total > max:
241-
t.Errorf("more fetches than should be possible: %d > %d", total, max)
242-
case total == max:
243-
t.Errorf("prevented no fetches: %d == %d", total, max)
244-
case total < max:
245-
t.Logf("prevented %[3]d fetches: %[1]d < %d", total, max, max-total)
240+
case total > limit:
241+
t.Errorf("more fetches than should be possible: %d > %d", total, limit)
242+
case total == limit:
243+
t.Errorf("prevented no fetches: %d == %d", total, limit)
244+
case total < limit:
245+
t.Logf("prevented %[3]d fetches: %[1]d < %d", total, limit, limit-total)
246246
}
247247
})
248248
inner := http.FileServer(http.Dir(dir))

libindex/libindex.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (l *Libindex) Index(ctx context.Context, manifest *claircore.Manifest) (*cl
197197
//
198198
// If the identifier has changed, clients should arrange for layers to be
199199
// re-indexed.
200-
func (l *Libindex) State(ctx context.Context) (string, error) {
200+
func (l *Libindex) State(_ context.Context) (string, error) {
201201
return l.state, nil
202202
}
203203

@@ -207,7 +207,7 @@ func (l *Libindex) State(ctx context.Context) (string, error) {
207207
// Indexers running different scanner versions will produce different state strings.
208208
// Thus this state value can be used as a cue for clients to re-index their manifests
209209
// and obtain a new IndexReport.
210-
func (l *Libindex) setState(ctx context.Context, vscnrs indexer.VersionedScanners) error {
210+
func (l *Libindex) setState(_ context.Context, vscnrs indexer.VersionedScanners) error {
211211
h := md5.New()
212212
var ns []string
213213
m := make(map[string][]byte)

libindex/libindex_integration_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ func (tc testcase) RunInner(ctx context.Context, t *testing.T, pool *pgxpool.Poo
104104
}
105105

106106
// create libindex instance
107+
a, err := CreateRemoteFetchArena(c, t.TempDir())
108+
if err != nil {
109+
t.Fatalf("failed to create RemoteFetchArena: %v", err)
110+
}
107111
opts := &Options{
108112
Store: store,
109113
Locker: ctxLocker,
110-
FetchArena: NewRemoteFetchArena(c, t.TempDir()),
114+
FetchArena: a,
111115
ScanLockRetry: 2 * time.Second,
112116
LayerScanConcurrency: 1,
113117
Ecosystems: []*indexer.Ecosystem{
@@ -125,7 +129,7 @@ func (tc testcase) RunInner(ctx context.Context, t *testing.T, pool *pgxpool.Poo
125129
RepositoryScanners: func(_ context.Context) ([]indexer.RepositoryScanner, error) {
126130
return nil, nil
127131
},
128-
FileScanners: func(ctx context.Context) ([]indexer.FileScanner, error) {
132+
FileScanners: func(_ context.Context) ([]indexer.FileScanner, error) {
129133
return []indexer.FileScanner{&whiteout.Scanner{}}, nil
130134
},
131135
Coalescer: func(_ context.Context) (indexer.Coalescer, error) {

libindex/options.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import (
77
)
88

99
const (
10-
DefaultScanLockRetry = 5 * time.Second
10+
// DefaultScanLockRetry is the default time to wait between attempting to
11+
// acquire the "scan lock".
12+
DefaultScanLockRetry = 5 * time.Second
13+
// DefaultLayerScanConcurrency is the default number of concurrent layer
14+
// "scans".
1115
DefaultLayerScanConcurrency = 10
1216
)
1317

0 commit comments

Comments
 (0)