func()

in ccadb2OneCRL/main.go [274:326]


func (u *Updater) Update() error {
	// Do some canary tests against Kinto to make sure that
	// we are properly authenticated for both production and
	// staging before we move on with anything.
	err := u.TryAuth()
	if err != nil {
		return err
	}
	// Policy is that if staging or prod (or both) are in review then we bail
	// out of this operation early and send out emails.
	inReview, err := u.AnySignerInReview()
	if err != nil {
		return err
	}
	if inReview {
		log.Info("changes at staging or production (or both) are in review")
		// We want to find the intersection between the CCADB
		// and OneCRL as those are the revocations that are still
		// in review. Once we find them we would like to post
		// gentle reminders to the associated Bugzilla tickets.
		intersection, err := u.FindIntersection()
		if err != nil {
			return err
		}
		u.BlastEmails(intersection)
		return nil
	}
	err = u.FindDiffs()
	if err != nil {
		return err
	}
	if u.NoDiffs() {
		log.Info("no differences found between the CCADB and OneCRL staging/production")
		return nil
	}
	// From here on we begin mutating datasets (OneCRL staging/production and Bugzilla)
	// so we would like to put these actions into a transactional context. Ideally,
	// each step should be able to undo itself if necessary.
	err = transaction.Start().
		Then(u.PushToStaging()).
		Then(u.OpenBug()).
		Then(u.UpdateRecordsWithBugID()).
		Then(u.PutStagingIntoReview()).
		Then(u.PushToProduction()).
		Then(u.PutProductionIntoReview()).
		AutoRollbackOnError(true).
		AutoClose(true).
		Commit()
	if err == nil {
		log.WithField("bugzilla", u.bugzilla.ShowBug(u.bugID)).Info("successfully completed update")
	}
	return err
}