rest

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePatch

func GeneratePatch(object runtime.Object, raw, originalRaw runtime.RawExtension) ([]byte, error)

func ParseUserGroup

func ParseUserGroup(groupEncoded string) (groups []string)

func ParseUserIdentity

func ParseUserIdentity(idEncoded string) (id string)

Types

type FakeKubeControl

type FakeKubeControl struct {
	// contains filtered or unexported fields
}

Fake interface for testing

func NewFakeKubeControl

func NewFakeKubeControl() *FakeKubeControl

func (*FakeKubeControl) Create

func (r *FakeKubeControl) Create(
	namespace string, raw runtime.RawExtension, deco func(obj runtime.Object) runtime.Object) (runtime.Object, error)

func (*FakeKubeControl) Delete

func (r *FakeKubeControl) Delete(gvk *schema.GroupVersionKind, resource, namespace, name string) error

func (*FakeKubeControl) Get

func (r *FakeKubeControl) Get(
	gvk *schema.GroupVersionKind, resource, namespace, name string, serverPrint bool) (runtime.Object, error)

Get a resource

func (*FakeKubeControl) Impersonate

func (r *FakeKubeControl) Impersonate(userID string, userGroups []string) KubeControlInterface

func (*FakeKubeControl) KindFor

func (*FakeKubeControl) List

func (r *FakeKubeControl) List(resource, namespace string, options *metav1.ListOptions, serverPrint bool) (runtime.Object, error)

List resources

func (*FakeKubeControl) Patch

func (r *FakeKubeControl) Patch(
	namespace, name string, gvk schema.GroupVersionKind, pt types.PatchType, data []byte) (runtime.Object, error)

func (*FakeKubeControl) Replace

func (r *FakeKubeControl) Replace(
	namespace string, overwrite bool, raw runtime.RawExtension) (runtime.Object, error)

func (*FakeKubeControl) SetObject

func (r *FakeKubeControl) SetObject(gvk *schema.GroupVersionKind, resource, namespace, name string, object runtime.Object)

func (*FakeKubeControl) UnsetImpersonate

func (r *FakeKubeControl) UnsetImpersonate() KubeControlInterface

type Helper

type Helper struct {
	// The name of this resource as the server would recognize it
	Resource string
	// A RESTClient capable of mutating this resource.
	RESTClient *rest.RESTClient
	// True if the resource type is scoped to namespaces
	NamespaceScoped bool
	// Enable server print
	ServerPrint bool
}

Helper provides methods for retrieving or mutating a RESTful resource.

func NewHelper

func NewHelper(config *rest.Config, mapping *meta.RESTMapping, serverPrint bool) (*Helper, error)

NewHelper creates a Helper from a ResourceMapping

func (*Helper) List

func (m *Helper) List(namespace string, options *metav1.ListOptions) (runtime.Object, error)

List return object list

type KubeControl

type KubeControl struct {
	// contains filtered or unexported fields
}

func NewKubeControl

func NewKubeControl(mapper *Mapper, config *rest.Config) *KubeControl

func (*KubeControl) Create

func (r *KubeControl) Create(
	namespace string, raw runtime.RawExtension, deco func(obj runtime.Object) runtime.Object) (runtime.Object, error)

func (*KubeControl) Delete

func (r *KubeControl) Delete(gvk *schema.GroupVersionKind, resource, namespace, name string) error

func (*KubeControl) Get

func (r *KubeControl) Get(
	gvk *schema.GroupVersionKind, resource, namespace, name string, serverPrint bool) (runtime.Object, error)

Get a resource

func (*KubeControl) Impersonate

func (r *KubeControl) Impersonate(userID string, userGroups []string) KubeControlInterface

func (*KubeControl) KindFor

func (*KubeControl) List

func (r *KubeControl) List(
	resource, namespace string, options *metav1.ListOptions, serverPrint bool) (runtime.Object, error)

List resources

func (*KubeControl) Patch

func (r *KubeControl) Patch(
	namespace, name string, gvk schema.GroupVersionKind, pt types.PatchType, data []byte) (runtime.Object, error)

func (*KubeControl) Replace

func (r *KubeControl) Replace(namespace string, overwrite bool, raw runtime.RawExtension) (runtime.Object, error)

func (*KubeControl) UnsetImpersonate

func (r *KubeControl) UnsetImpersonate() KubeControlInterface

type KubeControlInterface

type KubeControlInterface interface {

	// Impersonate a user
	Impersonate(userID string, userGroups []string) KubeControlInterface

	// Unset impersonate headers
	UnsetImpersonate() KubeControlInterface

	// Create creates an object
	Create(namespace string, raw runtime.RawExtension, deco func(obj runtime.Object) runtime.Object) (runtime.Object, error)

	// Delete a resource
	Delete(gvk *schema.GroupVersionKind, resource, namespace, name string) error

	// Get a resource
	Get(gvk *schema.GroupVersionKind, resource, namespace, name string, serverPrint bool) (runtime.Object, error)

	// List resources
	List(resource, namespace string, options *metav1.ListOptions, serverPrint bool) (runtime.Object, error)

	// Update resource
	Replace(namespace string, overwrite bool, obj runtime.RawExtension) (runtime.Object, error)

	// Patch resource
	Patch(namespace, name string, gvk schema.GroupVersionKind, pt types.PatchType, data []byte) (runtime.Object, error)

	// KindFor returns kind of a resource
	KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)
}

KubeControlInterface to call kubernetes api

type Mapper

type Mapper struct {
	// contains filtered or unexported fields
}

Mapper is a struct to define resource mapping

func NewFakeMapper

func NewFakeMapper(resources []*restmapper.APIGroupResources) *Mapper

NewFakeMapper is helper function to create fake mapper

func NewMapper

func NewMapper(discoveryclient discovery.CachedDiscoveryInterface, stopCh <-chan struct{}) *Mapper

NewMapper is to create the mapper struct

func (*Mapper) Mapper

func (p *Mapper) Mapper() meta.RESTMapper

func (*Mapper) MappingFor

func (p *Mapper) MappingFor(resourceOrKindArg string) (*meta.RESTMapping, error)

MappingFor returns the RESTMapping for the Kind given, or the Kind referenced by the resource. Prefers a fully specified GroupVersionResource match. If one is not found, we match on a fully specified GroupVersionKind, or fallback to a match on GroupKind.

func (*Mapper) MappingForGVK

func (p *Mapper) MappingForGVK(gvk schema.GroupVersionKind) (*meta.RESTMapping, error)

MappingForGVK returns the RESTMapping for a gvk

func (*Mapper) Run

func (p *Mapper) Run()

Run start the refresh goroutine

Jump to

Keyboard shortcuts

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