Skip to content

Commit

Permalink
AddDigestTargets -> AddTargetsWithDigest
Browse files Browse the repository at this point in the history
Signed-off-by: Marina Moore <[email protected]>
  • Loading branch information
mnm678 committed Dec 6, 2021
1 parent 3285548 commit f8404c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ func (r *Repo) AddTargets(paths []string, custom json.RawMessage) error {
return r.AddTargetsWithExpires(paths, custom, data.DefaultExpires("targets"))
}

func (r *Repo) AddDigestTargets(digest string, digestAlg string, length int64, custom json.RawMessage, path string) error {
func (r *Repo) AddTargetsWithDigest(digest string, digestAlg string, length int64, custom json.RawMessage, path string) error {
expires := data.DefaultExpires("targets")

// TODO: support delegated targets
Expand All @@ -711,6 +711,8 @@ func (r *Repo) AddDigestTargets(digest string, digestAlg string, length int64, c
return err
}

// If custom is provided, set custom, otherwise maintain existing custom
// metadata
if len(custom) > 0 {
meta.Custom = &custom
} else if t, ok := t.Targets[path]; ok {
Expand Down
2 changes: 1 addition & 1 deletion repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ func (rs *RepoSuite) TestSignDigest(c *C) {
hash := "bc11b176a293bb341a0f2d0d226f52e7fcebd186a7c4dfca5fc64f305f06b94c"
size := int64(42)

c.Assert(r.AddDigestTargets(hash, "sha256", size, nil, digest), IsNil)
c.Assert(r.AddTargetsWithDigest(hash, "sha256", size, nil, digest), IsNil)
c.Assert(r.Snapshot(), IsNil)
c.Assert(r.Timestamp(), IsNil)
c.Assert(r.Commit(), IsNil)
Expand Down

0 comments on commit f8404c4

Please sign in to comment.