Skip to content

Commit

Permalink
Merge pull request #46 from engineerd/trishankatdatadog/registry-then…
Browse files Browse the repository at this point in the history
…-notary

Push to registry-then-notary instead of other way around
  • Loading branch information
Radu M committed Feb 6, 2020
2 parents a859999 + 2889e44 commit 7d8fd32
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cmd/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,21 @@ func (s *signCmd) run() error {
cm = &custom
}

// NOTE: We first push to the Registry, and then Notary. This is so that if we modify the bundle locally,
// we will not invalidate its signature by first pushing to Notary, and then the Registry.

// We push only thin bundles to the Registry.
if !s.thick {
if err := cnab.Push(s.file, s.ref); err != nil {
return err
}
}

target, err := tuf.SignAndPublish(trustDir, trustServer, s.ref, s.file, tlscacert, s.rootKey, timeout, cm)
if err != nil {
return fmt.Errorf("cannot sign and publish trust data: %v", err)
}

log.Infof("Pushed trust data for %v: %v\n", s.ref, hex.EncodeToString(target.Hashes["sha256"]))

if s.thick {
return nil
}

return cnab.Push(s.file, s.ref)
return nil
}

0 comments on commit 7d8fd32

Please sign in to comment.