forked from deis/builder
/
secrets.go
63 lines (52 loc) · 1.92 KB
/
secrets.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
package k8s
import (
"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/watch"
)
// SecretGetter is a (k8s.io/kubernetes/pkg/client/unversioned).SecretsInterface compatible
// interface which only has the Get function. It's used in places that only need Get to make
// them easier to test and more easily swappable with other implementations
// (should the need arise).
type SecretGetter interface {
Get(name string) (*api.Secret, error)
}
// FakeSecretGetter is a mock function that can be swapped in for an SecretGetter or
// (k8s.io/kubernetes/pkg/client/unversioned).SecretsInterface, so you can
// unit test your code.
type FakeSecretGetter struct {
Fn func(string) (*api.Secret, error)
}
// Get is the interface definition.
func (f *FakeSecretGetter) Get(name string) (*api.Secret, error) {
return f.Fn(name)
}
// Delete is the interface definition.
func (f *FakeSecretGetter) Delete(name string) error {
return nil
}
// Create is the interface definition.
func (f *FakeSecretGetter) Create(secret *api.Secret) (*api.Secret, error) {
return &api.Secret{}, nil
}
// Update is the interface definition.
func (f *FakeSecretGetter) Update(secret *api.Secret) (*api.Secret, error) {
return &api.Secret{}, nil
}
// List is the interface definition.
func (f *FakeSecretGetter) List(opts api.ListOptions) (*api.SecretList, error) {
return &api.SecretList{}, nil
}
// Watch is the interface definition.
func (f *FakeSecretGetter) Watch(opts api.ListOptions) (watch.Interface, error) {
return nil, nil
}
// FakeSecretsNamespacer is a mock function that can be swapped in for an
// (k8s.io/kubernetes/pkg/client/unversioned).SecretsNamespacer, so you can unit test you code
type FakeSecretsNamespacer struct {
Fn func(string) client.SecretsInterface
}
// Secrets is the interface definition.
func (f *FakeSecretsNamespacer) Secrets(namespace string) client.SecretsInterface {
return f.Fn(namespace)
}