mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-05 17:10:27 +00:00
Generify fake clientsets
This adds a generic implementation of a fake clientset, and uses it to replace the template code in generated fake clientsets for the default methods. The templates are preserved as-is (or as close as they can be) for use in extensions, whether for resources or subresources. Fake clientsets with no extensions are reduced to their main getter, their specific struct, and their constructor. All method implementations are provided by the generic implementation. The dedicated struct is preserved to allow extensions and expansions to be defined where necessary. Instead of handling the variants (with/without list, apply) with a complex sequence of if statements, build up an index into an array containing the various declarations. Similarly, instead of calling different action constructors for namespaced and non-namespaced clientsets, assume the current behaviour of non-namespaced action creation (equivalent to creating a namespaced action with an empty namespace) and document that assumption in the action implementation. Signed-off-by: Stephen Kitt <skitt@redhat.com> Kubernetes-commit: b0ce65df9b74d4dc72050840d5ad067596d7b822
This commit is contained in:
committed by
Kubernetes Publisher
parent
955401ca9a
commit
c475fe0910
@@ -29,6 +29,10 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
// All NewRoot... functions return non-namespaced actions, and are equivalent to
|
||||
// calling the corresponding New... function with an empty namespace.
|
||||
// This is assumed by the fake client generator.
|
||||
|
||||
func NewRootGetAction(resource schema.GroupVersionResource, name string) GetActionImpl {
|
||||
return NewRootGetActionWithOptions(resource, name, metav1.GetOptions{})
|
||||
}
|
||||
|
Reference in New Issue
Block a user