...
1
16
17
18
19
20 package fake
21
22 import (
23 "context"
24
25 autoscalingapi "k8s.io/api/autoscaling/v1"
26 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27 "k8s.io/apimachinery/pkg/runtime/schema"
28 "k8s.io/apimachinery/pkg/types"
29 "k8s.io/client-go/scale"
30 "k8s.io/client-go/testing"
31 )
32
33
34 type FakeScaleClient struct {
35 testing.Fake
36 }
37
38 func (f *FakeScaleClient) Scales(namespace string) scale.ScaleInterface {
39 return &fakeNamespacedScaleClient{
40 namespace: namespace,
41 fake: &f.Fake,
42 }
43 }
44
45 type fakeNamespacedScaleClient struct {
46 namespace string
47 fake *testing.Fake
48 }
49
50 func (f *fakeNamespacedScaleClient) Get(ctx context.Context, resource schema.GroupResource, name string, opts metav1.GetOptions) (*autoscalingapi.Scale, error) {
51 obj, err := f.fake.
52 Invokes(testing.NewGetSubresourceAction(resource.WithVersion(""), f.namespace, "scale", name), &autoscalingapi.Scale{})
53
54 if err != nil {
55 return nil, err
56 }
57
58 return obj.(*autoscalingapi.Scale), err
59 }
60
61 func (f *fakeNamespacedScaleClient) Update(ctx context.Context, resource schema.GroupResource, scale *autoscalingapi.Scale, opts metav1.UpdateOptions) (*autoscalingapi.Scale, error) {
62 obj, err := f.fake.
63 Invokes(testing.NewUpdateSubresourceAction(resource.WithVersion(""), "scale", f.namespace, scale), &autoscalingapi.Scale{})
64
65 if err != nil {
66 return nil, err
67 }
68
69 return obj.(*autoscalingapi.Scale), err
70 }
71
72 func (f *fakeNamespacedScaleClient) Patch(ctx context.Context, gvr schema.GroupVersionResource, name string, pt types.PatchType, patch []byte, opts metav1.PatchOptions) (*autoscalingapi.Scale, error) {
73 obj, err := f.fake.
74 Invokes(testing.NewPatchSubresourceAction(gvr, f.namespace, name, pt, patch, "scale"), &autoscalingapi.Scale{})
75
76 if err != nil {
77 return nil, err
78 }
79
80 return obj.(*autoscalingapi.Scale), err
81 }
82
View as plain text