github.com/quay/claircore@v1.5.28/indexer/controller/fetchlayers.go (about)

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