예제 #1
0
파일: manager.go 프로젝트: nfoonf/shipyard
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(&reg); err != nil {
		return nil, err
	}

	registry, err := shipyard.NewRegistry(reg.ID, reg.Name, reg.Addr)
	if err != nil {
		return nil, err
	}

	return registry, nil
}
예제 #2
0
파일: manager.go 프로젝트: nfoonf/shipyard
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(&regs); 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
}