Documentation
¶
Index ¶
- Constants
- Variables
- func Can(verbs []string, v string) bool
- type Authorizer
- type Config
- type Connection
- type Factory
- type GVR
- func (g GVR) AsResourceName() string
- func (g GVR) G() string
- func (g GVR) GR() *schema.GroupResource
- func (g GVR) GV() schema.GroupVersion
- func (g GVR) GVK() schema.GroupVersionKind
- func (g GVR) GVR() schema.GroupVersionResource
- func (g GVR) IsMetricsRes() bool
- func (g GVR) R() string
- func (g GVR) RG() (string, string)
- func (g GVR) String() string
- func (g GVR) SubResource() string
- func (g GVR) V() string
- type GVRS
- type GVRs
- type NamespaceNames
Constants ¶
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 ¶
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 ¶
Types ¶
type Authorizer ¶
type Authorizer interface {
// CanI returns true if the user can use these actions for a given resource.
CanI(string, GVR, ...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) 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
func (g GVR) GVR() schema.GroupVersionResource
GVR returns a full schema representation.
func (GVR) IsMetricsRes ¶ added in v0.20.0
func (g GVR) IsMetricsRes() bool
func (GVR) RG ¶ added in v0.20.0
func (g GVR) RG() (string, string)
RG returns the resource and group.
func (GVR) SubResource ¶ added in v0.20.0
func (g GVR) SubResource() string
SubResource returns a sub resource if available.
type NamespaceNames ¶ added in v0.20.0
type NamespaceNames map[string]struct{}
NamespaceNames tracks a collection of namespace names.