/
persistentvolumeclaim.go
91 lines (75 loc) · 3.44 KB
/
persistentvolumeclaim.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
package mocks
import (
"context"
"fmt"
v1 "k8s.io/api/core/v1"
"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"
)
// compile simulation whether ClientsetMock implements interface
var _ corev1.PersistentVolumeClaimInterface = (*Pvc)(nil)
type Pvc struct{}
func NewPvc() *Pvc {
return &Pvc{}
}
// Apply implements v1.PersistentVolumeClaimInterface
func (*Pvc) Apply(ctx context.Context, persistentVolumeClaim *configcorev1.PersistentVolumeClaimApplyConfiguration, opts metav1.ApplyOptions) (result *v1.PersistentVolumeClaim, err error) {
panic("unimplemented")
}
// ApplyStatus implements v1.PersistentVolumeClaimInterface
func (*Pvc) ApplyStatus(ctx context.Context, persistentVolumeClaim *configcorev1.PersistentVolumeClaimApplyConfiguration, opts metav1.ApplyOptions) (result *v1.PersistentVolumeClaim, err error) {
panic("unimplemented")
}
// Create implements v1.PersistentVolumeClaimInterface
func (*Pvc) Create(ctx context.Context, persistentVolumeClaim *v1.PersistentVolumeClaim, opts metav1.CreateOptions) (*v1.PersistentVolumeClaim, error) {
if persistentVolumeClaim.ObjectMeta.Name == "create_bad" {
return nil, fmt.Errorf("mock error: cannot create pvc")
} else {
return nil, fmt.Errorf("mock error: unknown")
}
}
// Delete implements v1.PersistentVolumeClaimInterface
func (*Pvc) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
if name == "delete_bad" {
return fmt.Errorf("mock error: cannot delete pvc")
} else {
return errors.NewNotFound(schema.GroupResource{}, name)
}
}
// DeleteCollection implements v1.PersistentVolumeClaimInterface
func (*Pvc) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
panic("unimplemented")
}
// Get implements v1.PersistentVolumeClaimInterface
func (*Pvc) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.PersistentVolumeClaim, error) {
panic("unimplemented")
}
// List implements v1.PersistentVolumeClaimInterface
func (*Pvc) List(ctx context.Context, opts metav1.ListOptions) (*v1.PersistentVolumeClaimList, error) {
panic("unimplemented")
}
// Patch implements v1.PersistentVolumeClaimInterface
func (*Pvc) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.PersistentVolumeClaim, err error) {
panic("unimplemented")
}
// Update implements v1.PersistentVolumeClaimInterface
func (*Pvc) Update(ctx context.Context, persistentVolumeClaim *v1.PersistentVolumeClaim, opts metav1.UpdateOptions) (*v1.PersistentVolumeClaim, error) {
if persistentVolumeClaim.ObjectMeta.Name == "update_bad" {
return nil, errors.NewBadRequest("mock error: cannot update pvc")
} else {
return nil, errors.NewNotFound(schema.GroupResource{}, persistentVolumeClaim.ObjectMeta.Name)
}
}
// UpdateStatus implements v1.PersistentVolumeClaimInterface
func (*Pvc) UpdateStatus(ctx context.Context, persistentVolumeClaim *v1.PersistentVolumeClaim, opts metav1.UpdateOptions) (*v1.PersistentVolumeClaim, error) {
panic("unimplemented")
}
// Watch implements v1.PersistentVolumeClaimInterface
func (*Pvc) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
panic("unimplemented")
}