forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_buildconfigs.go
99 lines (80 loc) · 3.19 KB
/
fake_buildconfigs.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
package testclient
import (
"fmt"
"io"
"net/url"
kapi "k8s.io/kubernetes/pkg/api"
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/watch"
buildapi "github.com/openshift/origin/pkg/build/api"
"github.com/openshift/origin/pkg/client"
)
// FakeBuildConfigs implements BuildConfigInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakeBuildConfigs struct {
Fake *Fake
Namespace string
}
func (c *FakeBuildConfigs) Get(name string) (*buildapi.BuildConfig, error) {
obj, err := c.Fake.Invokes(ktestclient.NewGetAction("buildconfigs", c.Namespace, name), &buildapi.BuildConfig{})
if obj == nil {
return nil, err
}
return obj.(*buildapi.BuildConfig), err
}
func (c *FakeBuildConfigs) List(opts kapi.ListOptions) (*buildapi.BuildConfigList, error) {
obj, err := c.Fake.Invokes(ktestclient.NewListAction("buildconfigs", c.Namespace, opts), &buildapi.BuildConfigList{})
if obj == nil {
return nil, err
}
return obj.(*buildapi.BuildConfigList), err
}
func (c *FakeBuildConfigs) Create(inObj *buildapi.BuildConfig) (*buildapi.BuildConfig, error) {
obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("buildconfigs", c.Namespace, inObj), inObj)
if obj == nil {
return nil, err
}
return obj.(*buildapi.BuildConfig), err
}
func (c *FakeBuildConfigs) Update(inObj *buildapi.BuildConfig) (*buildapi.BuildConfig, error) {
obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("buildconfigs", c.Namespace, inObj), inObj)
if obj == nil {
return nil, err
}
return obj.(*buildapi.BuildConfig), err
}
func (c *FakeBuildConfigs) Delete(name string) error {
_, err := c.Fake.Invokes(ktestclient.NewDeleteAction("buildconfigs", c.Namespace, name), &buildapi.BuildConfig{})
return err
}
func (c *FakeBuildConfigs) Watch(opts kapi.ListOptions) (watch.Interface, error) {
return c.Fake.InvokesWatch(ktestclient.NewWatchAction("buildconfigs", c.Namespace, opts))
}
func (c *FakeBuildConfigs) WebHookURL(name string, trigger *buildapi.BuildTriggerPolicy) (*url.URL, error) {
switch {
case trigger.GenericWebHook != nil:
return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/generic", name, trigger.GenericWebHook.Secret))
case trigger.GitHubWebHook != nil:
return url.Parse(fmt.Sprintf("http://localhost/buildConfigHooks/%s/%s/github", name, trigger.GitHubWebHook.Secret))
default:
return nil, client.ErrTriggerIsNotAWebHook
}
}
func (c *FakeBuildConfigs) Instantiate(request *buildapi.BuildRequest) (result *buildapi.Build, err error) {
action := ktestclient.NewCreateAction("buildconfigs", c.Namespace, request)
action.Subresource = "instantiate"
obj, err := c.Fake.Invokes(action, &buildapi.Build{})
if obj == nil {
return nil, err
}
return obj.(*buildapi.Build), err
}
func (c *FakeBuildConfigs) InstantiateBinary(request *buildapi.BinaryBuildRequestOptions, r io.Reader) (result *buildapi.Build, err error) {
action := ktestclient.NewCreateAction("buildconfigs", c.Namespace, request)
action.Subresource = "instantiatebinary"
obj, err := c.Fake.Invokes(action, &buildapi.Build{})
if obj == nil {
return nil, err
}
return obj.(*buildapi.Build), err
}