Skip to content

Commit 8ef2e3d

Browse files
[Delegations prereq] Make snapshot manifest list dynamic
Splitting up #175
1 parent 84c43e5 commit 8ef2e3d

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.
@@ -812,6 +807,12 @@ func (r *Repo) Snapshot() error {
812807
return r.SnapshotWithExpires(data.DefaultExpires("snapshot"))
813808
}
814809

810+
func (r *Repo) snapshotManifests() []string {
811+
// Note: root pinning is not supported in Spec 1.0.19.
812+
// root.json might need to be removed.
813+
return []string{"root.json", "targets.json"}
814+
}
815+
815816
func (r *Repo) SnapshotWithExpires(expires time.Time) error {
816817
if !validExpires(expires) {
817818
return ErrInvalidExpires{expires}
@@ -826,12 +827,12 @@ func (r *Repo) SnapshotWithExpires(expires time.Time) error {
826827
return err
827828
}
828829

829-
for _, name := range snapshotMetadata {
830-
if err := r.verifySignature(name, db); err != nil {
830+
for _, manifestName := range r.snapshotManifests() {
831+
if err := r.verifySignature(manifestName, db); err != nil {
831832
return err
832833
}
833834
var err error
834-
snapshot.Meta[name], err = r.snapshotFileMeta(name)
835+
snapshot.Meta[manifestName], err = r.snapshotFileMeta(manifestName)
835836
if err != nil {
836837
return err
837838
}
@@ -958,7 +959,7 @@ func (r *Repo) Commit() error {
958959
if err != nil {
959960
return err
960961
}
961-
for _, name := range snapshotMetadata {
962+
for _, name := range r.snapshotManifests() {
962963
expected, ok := snapshot.Meta[name]
963964
if !ok {
964965
return fmt.Errorf("tuf: snapshot.json missing hash for %s", name)

0 commit comments

Comments
 (0)