...
1
19
20 package fake
21
22 import (
23 "k8s.io/apimachinery/pkg/runtime/schema"
24 "k8s.io/client-go/testing"
25 )
26
27 type PutAction[T any] interface {
28 testing.Action
29 GetName() string
30 GetOptions() T
31 }
32
33 type PutActionImpl[T any] struct {
34 testing.ActionImpl
35 Name string
36 Options T
37 }
38
39 func (a PutActionImpl[T]) GetName() string {
40 return a.Name
41 }
42
43 func (a PutActionImpl[T]) GetOptions() T {
44 return a.Options
45 }
46
47 func (a PutActionImpl[T]) DeepCopy() testing.Action {
48 return PutActionImpl[T]{
49 ActionImpl: a.ActionImpl.DeepCopy().(testing.ActionImpl),
50 Name: a.Name,
51 Options: a.Options,
52 }
53 }
54
55 func NewRootPutAction[T any](resource schema.GroupVersionResource, name string, options T) PutActionImpl[T] {
56 action := PutActionImpl[T]{}
57 action.Verb = "put"
58 action.Resource = resource
59 action.Name = name
60 action.Options = options
61
62 return action
63 }
64
65 func NewPutAction[T any](resource schema.GroupVersionResource, namespace, name string, options T) PutActionImpl[T] {
66 action := PutActionImpl[T]{}
67 action.Verb = "put"
68 action.Resource = resource
69 action.Namespace = namespace
70 action.Name = name
71 action.Options = options
72
73 return action
74 }
75
76 func NewRootPutSubresourceAction[T any](resource schema.GroupVersionResource, subresource, name string, options T) PutActionImpl[T] {
77 action := PutActionImpl[T]{}
78 action.Verb = "put"
79 action.Resource = resource
80 action.Subresource = subresource
81 action.Name = name
82 action.Options = options
83
84 return action
85 }
86
87 func NewPutSubresourceAction[T any](resource schema.GroupVersionResource, namespace, subresource, name string, options T) PutActionImpl[T] {
88 action := PutActionImpl[T]{}
89 action.Verb = "put"
90 action.Resource = resource
91 action.Subresource = subresource
92 action.Namespace = namespace
93 action.Name = name
94 action.Options = options
95
96 return action
97 }
98
View as plain text