/
fetchlayers.go
35 lines (31 loc) · 1.03 KB
/
fetchlayers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package controller
import (
"context"
"fmt"
"github.com/quay/zlog"
"github.com/quay/claircore/internal/wart"
)
func fetchLayers(ctx context.Context, s *Controller) (State, error) {
zlog.Info(ctx).Msg("layers fetch start")
defer zlog.Info(ctx).Msg("layers fetch done")
toFetch, err := reduce(ctx, s.Store, s.Vscnrs, s.manifest.Layers)
if err != nil {
return Terminal, fmt.Errorf("failed to determine layers to fetch: %w", err)
}
zlog.Debug(ctx).
Int("count", len(toFetch)).
Msg("fetching layers")
if err := s.Realizer.Realize(ctx, toFetch); err != nil {
zlog.Warn(ctx).
Err(err).
Msg("layers fetch failure")
return Terminal, fmt.Errorf("failed to fetch layers: %w", err)
}
// With the addition of the LayerDescription abstraction, it's possible that
// the "toFetch" slice is modified by the Realize call above. Once the
// LayerDescription type is plumbed through the Indexer, this can be
// removed.
wart.CopyLayerPointers(s.manifest.Layers, toFetch)
zlog.Info(ctx).Msg("layers fetch success")
return ScanLayers, nil
}