2022-05-17 16:40:51 +02:00
|
|
|
package dclient
|
2022-05-03 07:30:04 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
|
|
"k8s.io/client-go/dynamic/fake"
|
|
|
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
|
|
|
)
|
|
|
|
|
2022-05-17 08:19:03 +02:00
|
|
|
// NewMockClient ---testing utilities
|
2022-05-03 07:30:04 +02:00
|
|
|
func NewMockClient(scheme *runtime.Scheme, gvrToListKind map[schema.GroupVersionResource]string, objects ...runtime.Object) (Interface, error) {
|
|
|
|
c := fake.NewSimpleDynamicClientWithCustomListKinds(scheme, gvrToListKind, objects...)
|
|
|
|
// the typed and dynamic client are initialized with similar resources
|
|
|
|
kclient := kubefake.NewSimpleClientset(objects...)
|
|
|
|
return &client{
|
|
|
|
client: c,
|
|
|
|
kclient: kclient,
|
|
|
|
}, nil
|
|
|
|
}
|