LoadSnapshot loads and parses a snapshot with a given ID.
(ctx context.Context, rep repo.Repository, manifestID manifest.ID)
| 90 | |
| 91 | // LoadSnapshot loads and parses a snapshot with a given ID. |
| 92 | func LoadSnapshot(ctx context.Context, rep repo.Repository, manifestID manifest.ID) (*Manifest, error) { |
| 93 | sm := &Manifest{} |
| 94 | |
| 95 | em, err := rep.GetManifest(ctx, manifestID, sm) |
| 96 | if err != nil { |
| 97 | if errors.Is(err, manifest.ErrNotFound) { |
| 98 | return nil, ErrSnapshotNotFound |
| 99 | } |
| 100 | |
| 101 | return nil, errors.Wrap(err, "unable to find manifest entries") |
| 102 | } |
| 103 | |
| 104 | if em.Labels[manifest.TypeLabelKey] != ManifestType { |
| 105 | return nil, errors.New("manifest is not a snapshot") |
| 106 | } |
| 107 | |
| 108 | sm.ID = manifestID |
| 109 | |
| 110 | return sm, nil |
| 111 | } |
| 112 | |
| 113 | // SaveSnapshot persists given snapshot manifest and returns manifest ID. |
| 114 | func SaveSnapshot(ctx context.Context, rep repo.RepositoryWriter, man *Manifest) (manifest.ID, error) { |