-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry.go
executable file
·56 lines (48 loc) · 1.66 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
44
45
46
47
48
49
50
51
52
53
54
55
56
package distributionweb
import (
"fmt"
registry "github.com/mtanlee/distributionweb/registry/v2"
)
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"`
User string `json:"user,omitempty", gorethink:"user,omitempty"`
Password string `json:"password,omitempty", gorethink:"passwd,omitempty`
Email string `json:"email,omitempty", gorethink:"email,omitempty"`
registryClient *registry.RegistryClient `json:"-" gorethink:"-"`
}
func NewRegistry(id, name, addr, user, password, email string) (*Registry, error) {
rClient, err := registry.NewRegistryClient(fmt.Sprintf(addr), nil)
if err != nil {
return nil, err
}
return &Registry{
ID: id,
Name: name,
Addr: addr,
User: user,
Password: password,
Email: email,
registryClient: rClient,
}, nil
}
func (r *Registry) Repositories() ([]*registry.Repository, error) {
user := r.User
passwd := r.Password
res, err := r.registryClient.Search("", user, passwd)
if err != nil {
return nil, err
}
return res, nil
}
func (r *Registry) Repository(name, tag string) (*registry.Repository, error) {
user := r.User
passwd := r.Password
return r.registryClient.Repository(name, tag, user, passwd)
}
func (r *Registry) DeleteRepository(name string) error {
// user := r.User
// passwd := r.Password
return r.registryClient.DeleteRepository(name)
}