/
pod.go
129 lines (106 loc) · 4.08 KB
/
pod.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
package mocks
import (
"context"
"fmt"
v1 "k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1"
policy "k8s.io/api/policy/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
configcorev1 "k8s.io/client-go/applyconfigurations/core/v1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
restclient "k8s.io/client-go/rest"
)
// compile simulation whether ClientsetMock implements interface
var _ corev1.PodInterface = (*Pod)(nil)
type Pod struct{}
func NewPod() *Pod {
return &Pod{}
}
// Bind implements v1.PodInterface
func (*Pod) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error {
panic("unimplemented")
}
// Evict implements v1.PodInterface
func (*Pod) Evict(ctx context.Context, eviction *policy.Eviction) error {
panic("unimplemented")
}
// EvictV1 implements v1.PodInterface
func (*Pod) EvictV1(ctx context.Context, eviction *policyv1.Eviction) error {
panic("unimplemented")
}
// EvictV1beta1 implements v1.PodInterface
func (*Pod) EvictV1beta1(ctx context.Context, eviction *policy.Eviction) error {
panic("unimplemented")
}
// GetLogs implements v1.PodInterface
func (*Pod) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
panic("unimplemented")
}
// ProxyGet implements v1.PodInterface
func (*Pod) ProxyGet(scheme string, name string, port string, path string, params map[string]string) restclient.ResponseWrapper {
panic("unimplemented")
}
// Apply implements v1.PodInterface
func (*Pod) Apply(ctx context.Context, pod *configcorev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error) {
panic("unimplemented")
}
// ApplyStatus implements v1.PodInterface
func (*Pod) ApplyStatus(ctx context.Context, pod *configcorev1.PodApplyConfiguration, opts metav1.ApplyOptions) (result *v1.Pod, err error) {
panic("unimplemented")
}
// DeleteCollection implements v1.PodInterface
func (*Pod) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
panic("unimplemented")
}
// Get implements v1.PodInterface
func (*Pod) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.Pod, error) {
panic("unimplemented")
}
// List implements v1.PodInterface
func (*Pod) List(ctx context.Context, opts metav1.ListOptions) (*v1.PodList, error) {
panic("unimplemented")
}
// Patch implements v1.PodInterface
func (*Pod) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Pod, err error) {
panic("unimplemented")
}
// UpdateEphemeralContainers implements v1.PodInterface
func (*Pod) UpdateEphemeralContainers(ctx context.Context, podName string, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error) {
panic("unimplemented")
}
// UpdateStatus implements v1.PodInterface
func (*Pod) UpdateStatus(ctx context.Context, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error) {
panic("unimplemented")
}
// Watch implements v1.PodInterface
func (*Pod) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
panic("unimplemented")
}
// Create implements v1.PodInterface
func (*Pod) Create(ctx context.Context, pod *v1.Pod, opts metav1.CreateOptions) (*v1.Pod, error) {
if pod.ObjectMeta.Name == "create_bad" {
return nil, fmt.Errorf("mock error: cannot create pod")
} else {
return nil, fmt.Errorf("mock error: unknown")
}
}
// Delete implements v1.PodInterface
func (*Pod) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
if name == "delete_bad" {
return fmt.Errorf("mock error: cannot delete pod")
} else {
return errors.NewNotFound(schema.GroupResource{}, name)
}
}
// Update implements v1.PodInterface
func (*Pod) Update(ctx context.Context, pod *v1.Pod, opts metav1.UpdateOptions) (*v1.Pod, error) {
if pod.ObjectMeta.Name == "update_bad" {
return nil, errors.NewBadRequest("mock error: cannot update pod")
} else {
return nil, errors.NewNotFound(schema.GroupResource{}, pod.ObjectMeta.Name)
}
}