forked from ehazlett/shipyard
-
Notifications
You must be signed in to change notification settings - Fork 50
/
registry.go
43 lines (35 loc) · 1.11 KB
/
registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package shipyard
import (
registry "github.com/shipyard/shipyard/registry/v1"
)
type Registry struct {
ID string `json:"id,omitempty" gorethink:"id,omitempty"`
Name string `json:"name,omitempty" gorethink:"name,omitempty"`
Addr string `json:"addr,omitempty", gorethink:"addr,omitempty"`
registryClient *registry.RegistryClient `json:"-" gorethink:"-"`
}
func NewRegistry(id, name, addr string) (*Registry, error) {
rClient, err := registry.NewRegistryClient(addr, nil)
if err != nil {
return nil, err
}
return &Registry{
ID: id,
Name: name,
Addr: addr,
registryClient: rClient,
}, nil
}
func (r *Registry) Repositories() ([]*registry.Repository, error) {
res, err := r.registryClient.Search("", 1, 100)
if err != nil {
return nil, err
}
return res.Results, nil
}
func (r *Registry) Repository(name string) (*registry.Repository, error) {
return r.registryClient.Repository(name)
}
func (r *Registry) DeleteRepository(name string) error {
return r.registryClient.DeleteRepository(name)
}