func (c *client) Get(ctx context.Context, key ObjectKey, obj runtime.Object) error {
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.Get(ctx, key, obj)
	}
	return c.typedClient.Get(ctx, key, obj)
}
Get implements client.Client
package client
import (
	"context"
	"fmt"
	"reflect"
	"k8s.io/apimachinery/pkg/api/meta"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/apimachinery/pkg/runtime/serializer"
	"k8s.io/client-go/dynamic"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/rest"
	"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
)
type Options struct {
	Scheme *runtime.Scheme
	Mapper meta.RESTMapper
}
func New(config *rest.Config, options Options) (Client, error) {
	if config == nil {
		return nil, fmt.Errorf("must provide non-nil rest.Config to client.New")
	}
	if options.Scheme == nil {
		options.Scheme = scheme.Scheme
	}
	if options.Mapper == nil {
		var err error
		options.Mapper, err = apiutil.NewDynamicRESTMapper(config)
		if err != nil {
			return nil, err
		}
	}
	dynamicClient, err := dynamic.NewForConfig(config)
	if err != nil {
		return nil, err
	}
	c := &client{
		typedClient: typedClient{
			cache: clientCache{
				config:         config,
				scheme:         options.Scheme,
				mapper:         options.Mapper,
				codecs:         serializer.NewCodecFactory(options.Scheme),
				resourceByType: make(map[reflect.Type]*resourceMeta),
			},
			paramCodec: runtime.NewParameterCodec(options.Scheme),
		},
		unstructuredClient: unstructuredClient{
			client:     dynamicClient,
			restMapper: options.Mapper,
		},
	}
	return c, nil
}
var _ Client = &client{}
type client struct {
	typedClient        typedClient
	unstructuredClient unstructuredClient
}
func (c *client) resetGroupVersionKind(obj runtime.Object, gvk schema.GroupVersionKind) {
	if gvk != schema.EmptyObjectKind.GroupVersionKind() {
		if v, ok := obj.(schema.ObjectKind); ok {
			v.SetGroupVersionKind(gvk)
		}
	}
}
func (c *client) Create(ctx context.Context, obj runtime.Object, opts ...CreateOption) error {
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.Create(ctx, obj, opts...)
	}
	return c.typedClient.Create(ctx, obj, opts...)
}
func (c *client) Update(ctx context.Context, obj runtime.Object, opts ...UpdateOption) error {
	defer c.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.Update(ctx, obj, opts...)
	}
	return c.typedClient.Update(ctx, obj, opts...)
}
func (c *client) Delete(ctx context.Context, obj runtime.Object, opts ...DeleteOption) error {
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.Delete(ctx, obj, opts...)
	}
	return c.typedClient.Delete(ctx, obj, opts...)
}
func (c *client) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...DeleteAllOfOption) error {
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.DeleteAllOf(ctx, obj, opts...)
	}
	return c.typedClient.DeleteAllOf(ctx, obj, opts...)
}
func (c *client) Patch(ctx context.Context, obj runtime.Object, patch Patch, opts ...PatchOption) error {
	defer c.resetGroupVersionKind(obj, obj.GetObjectKind().GroupVersionKind())
	_, ok := obj.(*unstructured.Unstructured)
	if ok {
		return c.unstructuredClient.Patch(ctx, obj, patch, opts...)
	}
	return c.typedClient.Patch(ctx, obj, patch, opts...)
}