// Init sets up expected paths. func (s *Store) Init() (*Store, error) { sp, err := s.GetSnapshot().FastForward() if err != nil { return nil, err } exists, _, err := sp.Exists(nextPortPath) if err != nil { return nil, err } if !exists { sp, err = sp.Set(nextPortPath, strconv.Itoa(startPort)) if err != nil { return nil, err } } v, err := cp.VerifySchema(SchemaVersion, sp) if cp.IsErrNoEnt(err) { sp, err = cp.SetSchemaVersion(SchemaVersion, sp) if err != nil { return nil, err } } else if err != nil { if cp.IsErrSchemaMism(err) { err = fmt.Errorf("%s (%d != %d)", err, SchemaVersion, v) } return nil, err } s.snapshot = sp return s, nil }
// SetSchemaVersion is used to update the store schema which is used for // validation. func (s *Store) SetSchemaVersion(version int) error { sp, err := s.GetSnapshot().FastForward() if err != nil { return err } _, err = cp.SetSchemaVersion(version, sp) if err != nil { return err } return nil }