popeye: github.com/derailed/popeye/internal/client Index | Files

package client

import "github.com/derailed/popeye/internal/client"

Index

Package Files

client.go config.go factory.go gvr.go helpers.go metrics.go types.go

Constants

const (
    // NA Not available
    NA  = "n/a"

    // NamespaceAll designates the fictional all namespace.
    NamespaceAll = "all"

    // AllNamespaces designates all namespaces.
    AllNamespaces = ""

    // ClusterScope designates a resource is not namespaced.
    ClusterScope = "-"

    // NotNamespaced designates a non resource namespace.
    NotNamespaced = "*"
)
const (

    // CallTimeout represents api call timeout limit.
    CallTimeout = 5 * time.Second
)

func Can Uses

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

Can determines the available actions for a given resource.

func CleanseNamespace Uses

func CleanseNamespace(ns string) string

CleanseNamespace ensures all ns maps to blank.

func FQN Uses

func FQN(ns, n string) string

FQN returns a fully qualified resource name.

func IsAllNamespace Uses

func IsAllNamespace(ns string) bool

IsAllNamespace returns true if ns == all.

func IsAllNamespaces Uses

func IsAllNamespaces(ns string) bool

IsAllNamespaces returns true if all namespaces, false otherwise.

func IsClusterScoped Uses

func IsClusterScoped(ns string) bool

IsClusterScoped returns true if resource is not namespaced.

func IsClusterWide Uses

func IsClusterWide(ns string) bool

IsClusterWide returns true if ns designates cluster scope, false otherwise.

func IsNamespaced Uses

func IsNamespaced(ns string) bool

IsNamespaced returns true if a specific ns is given.

func MetaFQN Uses

func MetaFQN(m metav1.ObjectMeta) string

MetaFQN returns a fully qualified resource name.

func Namespaced Uses

func Namespaced(p string) (string, string)

Namespaced converts a resource path to namespace and resource name.

type APIClient Uses

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

APIClient represents a Kubernetes api client.

func InitConnectionOrDie Uses

func InitConnectionOrDie(config types.Config) *APIClient

InitConnectionOrDie initialize connection from command line args. Checks for connectivity with the api server.

func NewTestClient Uses

func NewTestClient() *APIClient

NewTestClient for testing ONLY!!

func (*APIClient) ActiveCluster Uses

func (a *APIClient) ActiveCluster() string

ActiveCluster returns the current cluster name.

func (*APIClient) ActiveNamespace Uses

func (a *APIClient) ActiveNamespace() string

ActiveNamespace returns the current namespace.

func (*APIClient) CachedDiscovery Uses

func (a *APIClient) CachedDiscovery() (*disk.CachedDiscoveryClient, error)

CachedDiscovery returns a cached discovery client.

func (*APIClient) CanI Uses

func (a *APIClient) CanI(ns, gvr string, verbs []string) (auth bool, err error)

CanI checks if user has access to a certain resource.

func (*APIClient) CheckConnectivity Uses

func (a *APIClient) CheckConnectivity() (status bool)

CheckConnectivity return true if api server is cool or false otherwise.

func (*APIClient) Config Uses

func (a *APIClient) Config() types.Config

Config return a kubernetes configuration.

func (*APIClient) CurrentNamespaceName Uses

func (a *APIClient) CurrentNamespaceName() (string, error)

CurrentNamespaceName return namespace name set via either cli arg or cluster config.

func (*APIClient) Dial Uses

func (a *APIClient) Dial() (kubernetes.Interface, error)

DialOrDie returns a handle to api server or die.

func (*APIClient) DynDial Uses

func (a *APIClient) DynDial() (dynamic.Interface, error)

DynDial returns a handle to a dynamic interface.

func (*APIClient) HasMetrics Uses

func (a *APIClient) HasMetrics() bool

HasMetrics returns true if the cluster supports metrics.

func (*APIClient) IsActiveNamespace Uses

func (a *APIClient) IsActiveNamespace(ns string) bool

IsActiveNamespace returns true if namespaces matches.

func (*APIClient) MXDial Uses

func (a *APIClient) MXDial() (*versioned.Clientset, error)

MXDial returns a handle to the metrics server.

func (*APIClient) RestConfig Uses

func (a *APIClient) RestConfig() (*restclient.Config, error)

RestConfig returns a rest api client.

func (*APIClient) ServerVersion Uses

func (a *APIClient) ServerVersion() (*version.Info, error)

ServerVersion returns the current server version info.

func (*APIClient) ValidNamespaces Uses

func (a *APIClient) ValidNamespaces() ([]v1.Namespace, error)

ValidNamespaces returns all available namespaces.

type Config Uses

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

Config tracks a kubernetes configuration.

func NewConfig Uses

func NewConfig(f *genericclioptions.ConfigFlags) *Config

NewConfig returns a new k8s config or an error if the flags are invalid.

func (*Config) ClusterNameFromContext Uses

func (c *Config) ClusterNameFromContext(ctx string) (string, error)

ClusterNameFromContext returns the cluster associated with the given context.

func (*Config) ClusterNames Uses

func (c *Config) ClusterNames() ([]string, error)

ClusterNames fetch all kubeconfig defined clusters.

func (*Config) ConfigAccess Uses

func (c *Config) ConfigAccess() (clientcmd.ConfigAccess, error)

ConfigAccess return the current kubeconfig api server access configuration.

func (*Config) ContextNames Uses

func (c *Config) ContextNames() ([]string, error)

ContextNames fetch all available contexts.

func (*Config) Contexts Uses

func (c *Config) Contexts() (map[string]*clientcmdapi.Context, error)

Contexts fetch all available contexts.

func (*Config) CurrentClusterName Uses

func (c *Config) CurrentClusterName() (string, error)

CurrentClusterName returns the active cluster name.

func (*Config) CurrentContextName Uses

func (c *Config) CurrentContextName() (string, error)

CurrentContextName returns the currently active config context.

func (*Config) CurrentGroupNames Uses

func (c *Config) CurrentGroupNames() ([]string, error)

CurrentGroupNames retrieves the active group names.

func (*Config) CurrentNamespaceName Uses

func (c *Config) CurrentNamespaceName() (string, error)

CurrentNamespaceName retrieves the active namespace.

func (*Config) CurrentUserName Uses

func (c *Config) CurrentUserName() (string, error)

CurrentUserName retrieves the active user name.

func (*Config) DelContext Uses

func (c *Config) DelContext(n string) error

DelContext remove a given context from the configuration.

func (*Config) Flags Uses

func (c *Config) Flags() *genericclioptions.ConfigFlags

Flags returns configuration flags.

func (*Config) GetContext Uses

func (c *Config) GetContext(n string) (*clientcmdapi.Context, error)

GetContext fetch a given context or error if it does not exists.

func (*Config) ImpersonateGroups Uses

func (c *Config) ImpersonateGroups() (string, error)

ImpersonateGroups retrieves the active groupsif set on the CLI.

func (*Config) ImpersonateUser Uses

func (c *Config) ImpersonateUser() (string, error)

ImpersonateUser retrieves the active user name if set on the CLI.

func (*Config) NamespaceNames Uses

func (c *Config) NamespaceNames(nns []v1.Namespace) []string

NamespaceNames fetch all available namespaces on current cluster.

func (*Config) RESTConfig Uses

func (c *Config) RESTConfig() (*restclient.Config, error)

RESTConfig fetch the current REST api service connection.

func (*Config) RawConfig Uses

func (c *Config) RawConfig() (clientcmdapi.Config, error)

RawConfig fetch the current kubeconfig with no overrides.

type ContainerMetrics Uses

type ContainerMetrics map[string]Metrics

ContainerMetrics tracks container metrics

type Factory Uses

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

Factory tracks various resource informers.

func NewFactory Uses

func NewFactory(client types.Connection) *Factory

NewFactory returns a new informers factory.

func (*Factory) CanForResource Uses

func (f *Factory) CanForResource(ns, gvr string, verbs []string) (informers.GenericInformer, error)

CanForResource return an informer is user has access.

func (*Factory) Client Uses

func (f *Factory) Client() types.Connection

Client return the factory connection.

func (*Factory) FactoryFor Uses

func (f *Factory) FactoryFor(ns string) di.DynamicSharedInformerFactory

FactoryFor returns a factory for a given namespace.

func (*Factory) ForResource Uses

func (f *Factory) ForResource(ns, gvr string) (informers.GenericInformer, error)

ForResource returns an informer for a given resource.

func (*Factory) Get Uses

func (f *Factory) Get(gvr, path string, wait bool, sel labels.Selector) (runtime.Object, error)

Get retrieves a given resource.

func (*Factory) List Uses

func (f *Factory) List(gvr, ns string, wait bool, labels labels.Selector) ([]runtime.Object, error)

List returns a resource collection.

func (*Factory) SetActiveNS Uses

func (f *Factory) SetActiveNS(ns string) error

SetActiveNS sets the active namespace.

func (*Factory) Start Uses

func (f *Factory) Start(ns string)

Start initializes the informers until caller cancels the context.

func (*Factory) Terminate Uses

func (f *Factory) Terminate()

Terminate stops the factory.

func (*Factory) WaitForCacheSync Uses

func (f *Factory) WaitForCacheSync()

WaitForCacheSync waits for all factories to update their cache.

type GVR Uses

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

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

func FromGVAndR Uses

func FromGVAndR(gv, r string) GVR

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

func NewGVR Uses

func NewGVR(gvr string) GVR

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

func NewGVRFromMeta Uses

func NewGVRFromMeta(a metav1.APIResource) GVR

NewGVRFromMeta builds a gvr from resource metadata.

func (GVR) AsResourceName Uses

func (g GVR) AsResourceName() string

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

func (GVR) G Uses

func (g GVR) G() string

G returns the resource group name.

func (GVR) GR Uses

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

GR returns a full schema representation.

func (GVR) GV Uses

func (g GVR) GV() schema.GroupVersion

GV returns the group version scheme representation.

func (GVR) GVK Uses

func (g GVR) GVK() schema.GroupVersionKind

GVK returns a full schema representation.

func (GVR) GVR Uses

func (g GVR) GVR() schema.GroupVersionResource

GVR returns a full schema representation.

func (GVR) R Uses

func (g GVR) R() string

R returns the resource name.

func (GVR) RG Uses

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

RG returns the resource and group.

func (GVR) String Uses

func (g GVR) String() string

String returns gvr as string.

func (GVR) SubResource Uses

func (g GVR) SubResource() string

SubResource returns a sub resource if available.

func (GVR) V Uses

func (g GVR) V() string

V returns the resource version.

type GVRs Uses

type GVRs []GVR

GVRs represents a collection of gvr.

func (GVRs) Len Uses

func (g GVRs) Len() int

Len returns the list size.

func (GVRs) Less Uses

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

Less returns true if i < j.

func (GVRs) Swap Uses

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

Swap swaps list values.

type Metrics Uses

type Metrics struct {
    CurrentCPU resource.Quantity
    CurrentMEM resource.Quantity
}

Metrics represent an aggregation of all pod containers metrics.

func (Metrics) Empty Uses

func (m Metrics) Empty() bool

Empty checks if we have any metrics.

type NodeMetrics Uses

type NodeMetrics struct {
    CurrentCPU   resource.Quantity
    CurrentMEM   resource.Quantity
    AvailableCPU resource.Quantity
    AvailableMEM resource.Quantity
    TotalCPU     resource.Quantity
    TotalMEM     resource.Quantity
}

NodeMetrics describes raw node metrics.

func (NodeMetrics) Empty Uses

func (n NodeMetrics) Empty() bool

Empty checks if we have any metrics.

type NodesMetrics Uses

type NodesMetrics map[string]NodeMetrics

NodesMetrics tracks usage metrics per nodes.

type PodsMetrics Uses

type PodsMetrics map[string]ContainerMetrics

PodsMetrics tracks usage metrics per pods.

Package client imports 33 packages (graph) and is imported by 7 packages. Updated 2020-06-12. Refresh now. Tools for package owners.