types

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateVerb represents create access on a resource.
	CreateVerb = "create"

	// UpdateVerb represents an update access on a resource.
	UpdateVerb = "update"

	// PatchVerb represents a patch access on a resource.
	PatchVerb = "patch"

	// DeleteVerb represents a delete access on a resource.
	DeleteVerb = "delete"

	// GetVerb represents a get access on a resource.
	GetVerb = "get"

	// ListVerb represents a list access on a resource.
	ListVerb = "list"

	// WatchVerb represents a watch access on a resource.
	WatchVerb = "watch"
)

Variables

View Source
var (
	// GetAccess reads a resource.
	GetAccess = []string{GetVerb}
	// ListAccess list resources.
	ListAccess = []string{ListVerb}
	// MonitorAccess monitors a collection of resources.
	MonitorAccess = []string{ListVerb, WatchVerb}
	// ReadAllAccess represents an all read access to a resource.
	ReadAllAccess = []string{GetVerb, ListVerb, WatchVerb}
)

Functions

func Can added in v0.20.0

func Can(verbs []string, v string) bool

Can determines the available actions for a given resource.

Types

type Authorizer

type Authorizer interface {
	// CanI returns true if the user can use these actions for a given resource.
	CanI(string, GVR, string, []string) (bool, error)
}

Authorizer checks what a user can or cannot do to a resource.

type Config

type Config interface {
	// CurrentNamespaceName returns the current context namespace.
	CurrentNamespaceName() (string, error)

	// CurrentContextName returns the current context.
	CurrentContextName() (string, error)

	// CurrentClusterName returns the current cluster.
	CurrentClusterName() (string, error)

	// Flags tracks k8s cli flags.
	Flags() *genericclioptions.ConfigFlags

	// RESTConfig tracks k8s client conn.
	RESTConfig() (*restclient.Config, error)

	// CallTimeout tracks api server ttl.
	CallTimeout() time.Duration
}

Config represents an api server configuration.

type Connection

type Connection interface {
	Authorizer

	// Config returns current config.
	Config() Config

	// ConnectionOK checks api server connection status.
	ConnectionOK() bool

	// Dial connects to api server.
	Dial() (kubernetes.Interface, error)

	// CachedDiscovery connects to discovery client.
	CachedDiscovery() (*disk.CachedDiscoveryClient, error)

	// RestConfig connects to rest client.
	RestConfig() (*restclient.Config, error)

	// MXDial connects to metrics server.
	MXDial() (*versioned.Clientset, error)

	// DynDial connects to dynamic client.
	DynDial() (dynamic.Interface, error)

	// HasMetrics checks if metrics server is available.
	HasMetrics() bool

	// ServerVersion returns current server version.
	ServerVersion() (*version.Info, error)

	// CheckConnectivity checks if api server connection is happy or not.
	CheckConnectivity() bool

	// ActiveContext returns the current context name.
	ActiveContext() string

	// ActiveCluster returns the current cluster name.
	ActiveCluster() string

	// ActiveNamespace returns the current namespace.
	ActiveNamespace() string

	// IsActiveNamespace checks if given ns is active.
	IsActiveNamespace(string) bool
}

Connection represents a Kubenetes apiserver connection.

type Factory

type Factory interface {
	// Client retrieves an api client.
	Client() Connection

	// Get fetch a given resource.
	Get(GVR, string, bool, labels.Selector) (runtime.Object, error)

	// List fetch a collection of resources.
	List(GVR, string, bool, labels.Selector) ([]runtime.Object, error)

	// ForResource fetch an informer for a given resource.
	ForResource(string, GVR) (informers.GenericInformer, error)

	// CanForResource fetch an informer for a given resource if authorized
	CanForResource(string, GVR, []string) (informers.GenericInformer, error)

	// WaitForCacheSync synchronize the cache.
	WaitForCacheSync()
}

Factory represents a resource factory.

type GVR added in v0.20.0

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

GVR represents a kubernetes resource schema as a string. Format is group/version/resources:subresource

var BlankGVR GVR

func FromGVAndR added in v0.20.0

func FromGVAndR(gv, r string) GVR

FromGVAndR builds a gvr from a group/version and resource.

func NewGVR added in v0.20.0

func NewGVR(gvr string) GVR

NewGVR builds a new gvr from a group, version, resource.

func NewGVRFromAPIRes added in v0.20.0

func NewGVRFromAPIRes(gv schema.GroupVersion, api metav1.APIResource) GVR

NewGVRFromAPIRes builds a gvr from server resource.

func (GVR) AsResourceName added in v0.20.0

func (g GVR) AsResourceName() string

AsResourceName returns a resource . separated descriptor in the shape of kind.version.group.

func (GVR) G added in v0.20.0

func (g GVR) G() string

G returns the resource group name.

func (GVR) GR added in v0.20.0

func (g GVR) GR() *schema.GroupResource

GR returns a full schema representation.

func (GVR) GV added in v0.20.0

func (g GVR) GV() schema.GroupVersion

GV returns the group version scheme representation.

func (GVR) GVK added in v0.20.0

func (g GVR) GVK() schema.GroupVersionKind

GVK returns a full schema representation.

func (GVR) GVR added in v0.20.0

GVR returns a full schema representation.

func (GVR) IsMetricsRes added in v0.20.0

func (g GVR) IsMetricsRes() bool

func (GVR) R added in v0.20.0

func (g GVR) R() string

R returns the resource name.

func (GVR) RG added in v0.20.0

func (g GVR) RG() (string, string)

RG returns the resource and group.

func (GVR) String added in v0.20.0

func (g GVR) String() string

String returns gvr as string.

func (GVR) SubResource added in v0.20.0

func (g GVR) SubResource() string

SubResource returns a sub resource if available.

func (GVR) V added in v0.20.0

func (g GVR) V() string

V returns the resource version.

type GVRS added in v0.20.0

type GVRS []GVR

type GVRs added in v0.20.0

type GVRs []GVR

GVRs represents a collection of gvr.

func (GVRs) Len added in v0.20.0

func (g GVRs) Len() int

Len returns the list size.

func (GVRs) Less added in v0.20.0

func (g GVRs) Less(i, j int) bool

Less returns true if i < j.

func (GVRs) Swap added in v0.20.0

func (g GVRs) Swap(i, j int)

Swap swaps list values.

type NamespaceNames added in v0.20.0

type NamespaceNames map[string]struct{}

NamespaceNames tracks a collection of namespace names.

Jump to

Keyboard shortcuts

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