Exemplo n.º 1
0
// Add one assertion to the batch.
func (b *Batch) Add(a asserts.Assertion) error {
	if err := b.bs.Put(a.Type(), a); err != nil {
		if revErr, ok := err.(*asserts.RevisionError); ok {
			if revErr.Current >= a.Revision() {
				// we already got something more recent
				return nil
			}
		}
		return err
	}
	b.refs = append(b.refs, a.Ref())
	return nil
}
Exemplo n.º 2
0
func writeAssert(a asserts.Assertion, targetDir string) error {
	ref := a.Ref()
	fn := fmt.Sprintf("%s.%s", strings.Join(ref.PrimaryKey, ","), ref.Type.Name)
	return ioutil.WriteFile(filepath.Join(targetDir, "asserts", fn), asserts.Encode(a), 0644)
}