Skip to content

Commit 64ff34e

Browse files
[Delegations prereq] Make snapshot manifest list dynamic
Splitting up #175
1 parent a1f2a82 commit 64ff34e

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.
@@ -792,6 +787,12 @@ func (r *Repo) Snapshot() error {
792787
return r.SnapshotWithExpires(data.DefaultExpires("snapshot"))
793788
}
794789

790+
func (r *Repo) snapshotManifests() []string {
791+
// Note: root pinning is not supported in Spec 1.0.19.
792+
// root.json might need to be removed.
793+
return []string{"root.json", "targets.json"}
794+
}
795+
795796
func (r *Repo) SnapshotWithExpires(expires time.Time) error {
796797
if !validExpires(expires) {
797798
return ErrInvalidExpires{expires}
@@ -806,12 +807,12 @@ func (r *Repo) SnapshotWithExpires(expires time.Time) error {
806807
return err
807808
}
808809

809-
for _, name := range snapshotMetadata {
810-
if err := r.verifySignature(name, db); err != nil {
810+
for _, manifestName := range r.snapshotManifests() {
811+
if err := r.verifySignature(manifestName, db); err != nil {
811812
return err
812813
}
813814
var err error
814-
snapshot.Meta[name], err = r.snapshotFileMeta(name)
815+
snapshot.Meta[manifestName], err = r.snapshotFileMeta(manifestName)
815816
if err != nil {
816817
return err
817818
}
@@ -936,7 +937,7 @@ func (r *Repo) Commit() error {
936937
if err != nil {
937938
return err
938939
}
939-
for _, name := range snapshotMetadata {
940+
for _, name := range r.snapshotManifests() {
940941
expected, ok := snapshot.Meta[name]
941942
if !ok {
942943
return fmt.Errorf("tuf: snapshot.json missing hash for %s", name)

0 commit comments

Comments
 (0)