dclient

package
v1.12.0-rc.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeDiscoveryClient

func NewFakeDiscoveryClient(registeredResources []schema.GroupVersionResource) *fakeDiscoveryClient

NewFakeDiscoveryClient returns a fakediscovery client

Types

type IDiscovery

type IDiscovery interface {
	FindResources(group, version, kind, subresource string) (map[TopLevelApiDescription]metav1.APIResource, error)
	// TODO: there's no mapping from GVK to GVR, this is very error prone
	GetGVRFromGVK(schema.GroupVersionKind) (schema.GroupVersionResource, error)
	GetGVKFromGVR(schema.GroupVersionResource) (schema.GroupVersionKind, error)
	OpenAPISchema() (*openapiv2.Document, error)
	CachedDiscoveryInterface() discovery.CachedDiscoveryInterface
}

IDiscovery provides interface to mange Kind and GVR mapping

type Interface

type Interface interface {
	// GetKubeClient provides typed kube client
	GetKubeClient() kubernetes.Interface
	// GetEventsInterface provides typed interface for events
	GetEventsInterface() eventsv1.EventsV1Interface
	// GetDynamicInterface fetches underlying dynamic interface
	GetDynamicInterface() dynamic.Interface
	// Discovery return the discovery client implementation
	Discovery() IDiscovery
	// SetDiscovery sets the discovery client implementation
	SetDiscovery(discoveryClient IDiscovery)
	// RawAbsPath performs a raw call to the kubernetes API
	RawAbsPath(ctx context.Context, path string, method string, dataReader io.Reader) ([]byte, error)
	// GetResource returns the resource in unstructured/json format
	GetResource(ctx context.Context, apiVersion string, kind string, namespace string, name string, subresources ...string) (*unstructured.Unstructured, error)
	// PatchResource patches the resource
	PatchResource(ctx context.Context, apiVersion string, kind string, namespace string, name string, patch []byte) (*unstructured.Unstructured, error)
	// ListResource returns the list of resources in unstructured/json format
	// Access items using []Items
	ListResource(ctx context.Context, apiVersion string, kind string, namespace string, lselector *metav1.LabelSelector) (*unstructured.UnstructuredList, error)
	// DeleteResource deletes the specified resource
	DeleteResource(ctx context.Context, apiVersion string, kind string, namespace string, name string, dryRun bool) error
	// CreateResource creates object for the specified resource/namespace
	CreateResource(ctx context.Context, apiVersion string, kind string, namespace string, obj interface{}, dryRun bool) (*unstructured.Unstructured, error)
	// UpdateResource updates object for the specified resource/namespace
	UpdateResource(ctx context.Context, apiVersion string, kind string, namespace string, obj interface{}, dryRun bool, subresources ...string) (*unstructured.Unstructured, error)
	// UpdateStatusResource updates the resource "status" subresource
	UpdateStatusResource(ctx context.Context, apiVersion string, kind string, namespace string, obj interface{}, dryRun bool) (*unstructured.Unstructured, error)
	// ApplyResource applies object for the specified resource/namespace using server-side apply
	ApplyResource(ctx context.Context, apiVersion string, kind string, namespace string, name string, obj interface{}, dryRun bool, fieldManager string, subresources ...string) (*unstructured.Unstructured, error)
	// ApplyStatusResource applies the resource "status" subresource using server-side apply
	ApplyStatusResource(ctx context.Context, apiVersion string, kind string, namespace string, name string, obj interface{}, dryRun bool, fieldManager string) (*unstructured.Unstructured, error)
}

func NewClient

func NewClient(
	ctx context.Context,
	dyn dynamic.Interface,
	kube kubernetes.Interface,
	resync time.Duration,
) (Interface, error)

NewClient creates new instance of client

func NewEmptyFakeClient

func NewEmptyFakeClient() Interface

func NewFakeClient

func NewFakeClient(scheme *runtime.Scheme, gvrToListKind map[schema.GroupVersionResource]string, objects ...runtime.Object) (Interface, error)

NewFakeClient ---testing utilities

type Resource added in v1.10.5

type Resource struct {
	Group        string
	Version      string
	Resource     string
	SubResource  string
	Unstructured unstructured.Unstructured
}

func GetResources added in v1.10.5

func GetResources(ctx context.Context, c Interface, group, version, kind, subresource, namespace, name string) ([]Resource, error)

type TopLevelApiDescription added in v1.10.0

type TopLevelApiDescription struct {
	schema.GroupVersion
	Kind        string
	Resource    string
	SubResource string
}

TopLevelApiDescription contains a group/version/resource/subresource reference

func (TopLevelApiDescription) GroupVersionKind added in v1.10.0

func (gvrs TopLevelApiDescription) GroupVersionKind() schema.GroupVersionKind

func (TopLevelApiDescription) GroupVersionResource added in v1.10.0

func (gvrs TopLevelApiDescription) GroupVersionResource() schema.GroupVersionResource

func (TopLevelApiDescription) ResourceSubresource added in v1.10.0

func (gvrs TopLevelApiDescription) ResourceSubresource() string

func (TopLevelApiDescription) WithSubResource added in v1.10.0

func (gvrs TopLevelApiDescription) WithSubResource(subresource string) TopLevelApiDescription

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL