func (m DefaultManager) Registry(name string) (*shipyard.Registry, error) { res, err := r.Table(tblNameRegistries).Filter(map[string]string{"name": name}).Run(m.session) if err != nil { return nil, err } if res.IsNil() { return nil, ErrRegistryDoesNotExist } var reg *shipyard.Registry if err := res.One(®); err != nil { return nil, err } registry, err := shipyard.NewRegistry(reg.ID, reg.Name, reg.Addr) if err != nil { return nil, err } return registry, nil }
func (m DefaultManager) Registries() ([]*shipyard.Registry, error) { res, err := r.Table(tblNameRegistries).OrderBy(r.Asc("name")).Run(m.session) if err != nil { return nil, err } regs := []*shipyard.Registry{} if err := res.All(®s); err != nil { return nil, err } registries := []*shipyard.Registry{} for _, r := range regs { reg, err := shipyard.NewRegistry(r.ID, r.Name, r.Addr) if err != nil { return nil, err } registries = append(registries, reg) } return registries, nil }