diff --git a/repo.go b/repo.go index b8846e26..4c9c53d7 100644 --- a/repo.go +++ b/repo.go @@ -28,11 +28,6 @@ var topLevelMetadata = []string{ "timestamp.json", } -var snapshotMetadata = []string{ - "root.json", - "targets.json", -} - // TargetsWalkFunc is a function of a target path name and a target payload used to // execute some function on each staged target file. For example, it may normalize path // names and generate target file metadata with additional custom metadata. @@ -812,6 +807,12 @@ func (r *Repo) Snapshot() error { return r.SnapshotWithExpires(data.DefaultExpires("snapshot")) } +func (r *Repo) snapshotManifests() []string { + // Note: root pinning is not supported in Spec 1.0.19. + // root.json might need to be removed. + return []string{"root.json", "targets.json"} +} + func (r *Repo) SnapshotWithExpires(expires time.Time) error { if !validExpires(expires) { return ErrInvalidExpires{expires} @@ -826,12 +827,12 @@ func (r *Repo) SnapshotWithExpires(expires time.Time) error { return err } - for _, name := range snapshotMetadata { - if err := r.verifySignature(name, db); err != nil { + for _, manifestName := range r.snapshotManifests() { + if err := r.verifySignature(manifestName, db); err != nil { return err } var err error - snapshot.Meta[name], err = r.snapshotFileMeta(name) + snapshot.Meta[manifestName], err = r.snapshotFileMeta(manifestName) if err != nil { return err } @@ -958,7 +959,7 @@ func (r *Repo) Commit() error { if err != nil { return err } - for _, name := range snapshotMetadata { + for _, name := range r.snapshotManifests() { expected, ok := snapshot.Meta[name] if !ok { return fmt.Errorf("tuf: snapshot.json missing hash for %s", name)