-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathk8s.go
63 lines (51 loc) · 1.48 KB
/
k8s.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 mocks
import (
"fmt"
"github.com/ethersphere/beekeeper/pkg/k8s/customresource/ingressroute"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
// compile simulation whether ClientsetMock implements interface
var _ kubernetes.Interface = (*Clientset)(nil)
type Client struct {
expectError bool
}
func NewClient(expectError bool) *Client {
return &Client{expectError: expectError}
}
// NewForConfig returns a new Kubernetes clientset
func (c *Client) NewForConfig(*rest.Config) (*kubernetes.Clientset, error) {
if c.expectError {
return nil, fmt.Errorf("mock error")
}
return &kubernetes.Clientset{}, nil
}
// NewIngressRouteClientForConfig returns a new ingressroute client
func (c *Client) NewIngressRouteClientForConfig(*rest.Config) (*ingressroute.CustomResourceClient, error) {
if c.expectError {
return nil, fmt.Errorf("mock error")
}
return &ingressroute.CustomResourceClient{}, nil
}
func (c *Client) InClusterConfig() (*rest.Config, error) {
if c.expectError {
return nil, fmt.Errorf("mock error")
}
return &rest.Config{}, nil
}
func (c *Client) BuildConfigFromFlags(masterUrl string, kubeconfigPath string) (*rest.Config, error) {
if c.expectError {
return nil, fmt.Errorf("mock error")
}
return &rest.Config{}, nil
}
func (c *Client) OsUserHomeDir() (string, error) {
if c.expectError {
return "", fmt.Errorf("mock error")
}
return "home", nil
}
func FlagString(name string, value string, usage string) *string {
return new(string)
}
func FlagParse() {}