// 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 }
// VerifySchema will error if there is a schema missmatch. func (s *Store) VerifySchema() (int, error) { sp, err := s.GetSnapshot().FastForward() if err != nil { return -1, err } v, err := cp.VerifySchema(SchemaVersion, sp) if err != nil { if cp.IsErrSchemaMism(err) { err = fmt.Errorf("%s (%d != %d)", err, SchemaVersion, v) } return v, err } return v, nil }