Skip to content

Commit ff7805c

Browse files
[Delegations prereq] Make snapshot manifest list dynamic
Splitting up #175
1 parent 5c96ea2 commit ff7805c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

repo.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ var topLevelMetadata = []string{
2828
"timestamp.json",
2929
}
3030

31-
var snapshotMetadata = []string{
32-
"root.json",
33-
"targets.json",
34-
}
35-
3631
// TargetsWalkFunc is a function of a target path name and a target payload used to
3732
// execute some function on each staged target file. For example, it may normalize path
3833
// names and generate target file metadata with additional custom metadata.
@@ -803,6 +798,12 @@ func (r *Repo) Snapshot() error {
803798
return r.SnapshotWithExpires(data.DefaultExpires("snapshot"))
804799
}
805800

801+
func (r *Repo) snapshotManifests() []string {
802+
// Note: root pinning is not supported in Spec 1.0.19.
803+
// root.json might need to be removed.
804+
return []string{"root.json", "targets.json"}
805+
}
806+
806807
func (r *Repo) SnapshotWithExpires(expires time.Time) error {
807808
if !validExpires(expires) {
808809
return ErrInvalidExpires{expires}
@@ -817,12 +818,12 @@ func (r *Repo) SnapshotWithExpires(expires time.Time) error {
817818
return err
818819
}
819820

820-
for _, name := range snapshotMetadata {
821-
if err := r.verifySignature(name, db); err != nil {
821+
for _, manifestName := range r.snapshotManifests() {
822+
if err := r.verifySignature(manifestName, db); err != nil {
822823
return err
823824
}
824825
var err error
825-
snapshot.Meta[name], err = r.snapshotFileMeta(name)
826+
snapshot.Meta[manifestName], err = r.snapshotFileMeta(manifestName)
826827
if err != nil {
827828
return err
828829
}
@@ -949,7 +950,7 @@ func (r *Repo) Commit() error {
949950
if err != nil {
950951
return err
951952
}
952-
for _, name := range snapshotMetadata {
953+
for _, name := range r.snapshotManifests() {
953954
expected, ok := snapshot.Meta[name]
954955
if !ok {
955956
return fmt.Errorf("tuf: snapshot.json missing hash for %s", name)

0 commit comments

Comments
 (0)