forked from cncodog/shipyard
-
Notifications
You must be signed in to change notification settings - Fork 25
/
manager_mock.go
198 lines (153 loc) · 4.51 KB
/
manager_mock.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package mock_test
import (
"github.com/gorilla/sessions"
"github.com/samalba/dockerclient"
"github.com/shipyard/shipyard"
"github.com/shipyard/shipyard/auth"
"github.com/shipyard/shipyard/controller/manager"
"github.com/shipyard/shipyard/dockerhub"
registry "github.com/shipyard/shipyard/registry/v1"
)
type MockManager struct{}
func (m MockManager) Container(id string) (*dockerclient.ContainerInfo, error) {
return getTestContainerInfo(TestContainerId, TestContainerName, TestContainerImage), nil
}
func (m MockManager) DockerClient() *dockerclient.DockerClient {
return nil
}
func (m MockManager) SaveServiceKey(key *auth.ServiceKey) error {
return nil
}
func (m MockManager) RemoveServiceKey(key string) error {
return nil
}
func (m MockManager) SaveEvent(event *shipyard.Event) error {
return nil
}
func (m MockManager) Events(limit int) ([]*shipyard.Event, error) {
return getTestEvents(), nil
}
func (m MockManager) PurgeEvents() error {
return nil
}
func (m MockManager) ServiceKey(key string) (*auth.ServiceKey, error) {
return TestServiceKey, nil
}
func (m MockManager) ServiceKeys() ([]*auth.ServiceKey, error) {
return []*auth.ServiceKey{
TestServiceKey,
}, nil
}
func (m MockManager) Accounts() ([]*auth.Account, error) {
return []*auth.Account{
TestAccount,
}, nil
}
func (m MockManager) Account(username string) (*auth.Account, error) {
return nil, nil
}
func (m MockManager) SaveAccount(account *auth.Account) error {
return nil
}
func (m MockManager) DeleteAccount(account *auth.Account) error {
return nil
}
func (m MockManager) Roles() ([]*auth.ACL, error) {
return auth.DefaultACLs(), nil
}
func (m MockManager) Role(name string) (*auth.ACL, error) {
roles, err := m.Roles()
return roles[0], err
}
func (m MockManager) Authenticate(username, password string) (bool, error) {
return false, nil
}
func (m MockManager) NewAuthToken(username, userAgent string) (*auth.AuthToken, error) {
return nil, nil
}
func (m MockManager) VerifyAuthToken(username, token string) error {
return nil
}
func (m MockManager) VerifyServiceKey(key string) error {
return nil
}
func (m MockManager) NewServiceKey(description string) (*auth.ServiceKey, error) {
return nil, nil
}
func (m MockManager) ChangePassword(username, password string) error {
return nil
}
func (m MockManager) WebhookKeys() ([]*dockerhub.WebhookKey, error) {
return []*dockerhub.WebhookKey{
TestWebhookKey,
}, nil
}
func (m MockManager) NewWebhookKey(image string) (*dockerhub.WebhookKey, error) {
return nil, nil
}
func (m MockManager) WebhookKey(key string) (*dockerhub.WebhookKey, error) {
return nil, nil
}
func (m MockManager) SaveWebhookKey(key *dockerhub.WebhookKey) error {
return nil
}
func (m MockManager) DeleteWebhookKey(id string) error {
return nil
}
func (m MockManager) Store() *sessions.CookieStore {
return nil
}
func (m MockManager) StoreKey() string {
return ""
}
func (m MockManager) AddRegistry(registry *shipyard.Registry) error {
return nil
}
func (m MockManager) Registries() ([]*shipyard.Registry, error) {
return []*shipyard.Registry{
TestRegistry,
}, nil
}
func (m MockManager) Registry(name string) (*shipyard.Registry, error) {
return TestRegistry, nil
}
func (m MockManager) RemoveRegistry(registry *shipyard.Registry) error {
return nil
}
func (m MockManager) Nodes() ([]*shipyard.Node, error) {
return []*shipyard.Node{
TestNode,
}, nil
}
func (m MockManager) Repositories() ([]*registry.Repository, error) {
return []*registry.Repository{
TestRepository,
}, nil
}
func (m MockManager) Repository(name string) (*registry.Repository, error) {
return TestRepository, nil
}
func (m MockManager) DeleteRepository(name string) error {
return nil
}
func (m MockManager) Node(name string) (*shipyard.Node, error) {
return TestNode, nil
}
func (m MockManager) CreateConsoleSession(c *shipyard.ConsoleSession) error {
return nil
}
func (m MockManager) RemoveConsoleSession(c *shipyard.ConsoleSession) error {
return nil
}
func (m MockManager) ConsoleSession(token string) (*shipyard.ConsoleSession, error) {
return TestConsoleSession, nil
}
func (m MockManager) ValidateConsoleSessionToken(containerId, token string) bool {
return true
}
func (m MockManager) GetAuthenticator() auth.Authenticator {
return nil
}
func (m MockManager) ScaleContainer(id string, numInstances int) manager.ScaleResult {
return manager.ScaleResult{Scaled: []string{"9c3c7dd2199a95cce29950b612ecf918ae278a42e53e10f6cccb752b6fbcd8b3"}, Errors: []string{"500 Internal Server Error: no resources available to schedule container"}}
}