예제 #1
0
func (m DefaultManager) WebhookKeys() ([]*dockerhub.WebhookKey, error) {
	res, err := r.Table(tblNameWebhookKeys).OrderBy(r.Asc("image")).Run(m.session)
	if err != nil {
		return nil, err
	}
	keys := []*dockerhub.WebhookKey{}
	if err := res.All(&keys); err != nil {
		return nil, err
	}
	return keys, nil
}
예제 #2
0
func (m DefaultManager) Accounts() ([]*auth.Account, error) {
	res, err := r.Table(tblNameAccounts).OrderBy(r.Asc("username")).Run(m.session)
	if err != nil {
		return nil, err
	}
	accounts := []*auth.Account{}
	if err := res.All(&accounts); err != nil {
		return nil, err
	}
	return accounts, nil
}
예제 #3
0
// ConvertSortParameters to rethinkdb query string
func ConvertSortParameters(params api.SortParameters) []interface{} {

	var sorts []interface{}
	for k, v := range params {
		switch v {
		case api.Ascending:
			sorts = append(sorts, r.Asc(strings.ToLower(k)))
			break
		case api.Descending:
			sorts = append(sorts, r.Desc(strings.ToLower(k)))
			break
		default:
			sorts = append(sorts, r.Desc(strings.ToLower(k)))
		}
	}

	// Apply default sort
	if len(sorts) == 0 {
		sorts = append(sorts, r.Asc("id"))
	}

	return sorts
}
예제 #4
0
func (m DefaultManager) Registries() ([]*shipyard.Registry, error) {
	res, err := r.Table(tblNameRegistries).OrderBy(r.Asc("name")).Run(m.session)
	defer res.Close()
	if err != nil {
		return nil, err
	}

	regs := []*shipyard.Registry{}
	if err := res.All(&regs); err != nil {
		return nil, err
	}

	for _, registry := range regs {
		if err := registry.InitRegistryClient(); err != nil {
			log.Errorf("%s", err.Error())
		}
	}

	return regs, nil
}
예제 #5
0
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
}