Documentation ¶
Index ¶
- Variables
- func IsAlreadyExistsErr(err error) bool
- func IsDeadlineErr(err error) bool
- func IsInvalidNameErr(err error) bool
- func IsKubernetesErr(err error) bool
- func IsNamespaceNotExistsErr(err error) bool
- func IsNetworkErr(err error) bool
- func IsNotExistsErr(err error) bool
- func IsServiceUnavailableErr(err error) bool
- func IsUnauthorizedErr(err error) bool
- func IsValidationErr(err error) bool
- type ListTranformer
- type Logger
- type ManagedNames
- type ResourceType
- type Visor
- func (k *Visor) CreateClusterResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
- func (k *Visor) CreateResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
- func (k *Visor) DeleteResource(ctx context.Context, t ResourceType, name string) (err error)
- func (k *Visor) FetchLogs(ctx context.Context, tail int64, w io.Writer, cname, pname string) (err error)
- func (k *Visor) GetClusterResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
- func (k *Visor) GetResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
- func (k *Visor) ListResources(ctx context.Context, t ResourceType, v ListTranformer, ...) (err error)
- func (k *Visor) UpdateResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
Constants ¶
This section is empty.
Variables ¶
var ( //ResourceTypeJobs is used for job management ResourceTypeJobs = ResourceType("jobs") //ResourceTypePods is used for pod inspection ResourceTypePods = ResourceType("pods") //ResourceTypeDatasets is used for dataset management ResourceTypeDatasets = ResourceType("datasets") //ResourceTypeEvents is the resource type for event fetching ResourceTypeEvents = ResourceType("events") //ResourceTypeQuota can be used to retrieve quota information ResourceTypeQuota = ResourceType("resourcequotas") //ResourceTypeSecrets can be used to get secret information ResourceTypeSecrets = ResourceType("secrets") //ResourceTypeDeployments is used for deployment management ResourceTypeDeployments = ResourceType("deployments") //ResourceTypeRoles is used for role management ResourceTypeRoles = ResourceType("roles") //ResourceTypeRoleBindings is used for role bindings management ResourceTypeRoleBindings = ResourceType("rolebindings") //ResourceTypeClusterRoles is used for cluster roles management ResourceTypeClusterRoles = ResourceType("clusterroles") //ResourceTypeClusterRoleBindings is used for cluster role bindings management ResourceTypeClusterRoleBindings = ResourceType("clusterrolebindings") //ResourceTypeDaemonsets is used for daemonset management ResourceTypeDaemonsets = ResourceType("daemonsets") //ResourceTypeCustomResourceDefinition is used for crd management ResourceTypeCustomResourceDefinition = ResourceType("customresourcedefinitions") )
var ( //MaxLogBytes determines how much logs we're gonna return, we cap it hard at this point MaxLogBytes = int64(1024 * 1024) //1MiB //DefaultPrefix is used to identify a job created by the cli DefaultPrefix = "nlz-nerd" )
Functions ¶
func IsAlreadyExistsErr ¶
IsAlreadyExistsErr indicates that what is attempted to be created already exists
func IsDeadlineErr ¶
IsDeadlineErr indicates that a context deadline exceeded
func IsInvalidNameErr ¶
IsInvalidNameErr indicates the provided name was invalid
func IsKubernetesErr ¶
IsKubernetesErr is for unexpected kubernetes errors
func IsNamespaceNotExistsErr ¶
IsNamespaceNotExistsErr indicates that what is attempted to be created already exists
func IsNetworkErr ¶
IsNetworkErr is for unexpected kubernetes errors
func IsNotExistsErr ¶
IsNotExistsErr indicates that what is attempted to be created already exists
func IsServiceUnavailableErr ¶
IsServiceUnavailableErr indicates that kubernetes is unhealthy
func IsUnauthorizedErr ¶
IsUnauthorizedErr indicates that what is attempted to be created already exists
func IsValidationErr ¶
IsValidationErr asserts for a validation error
Types ¶
type ListTranformer ¶
type ListTranformer interface { Transform(fn func(in ManagedNames) (out ManagedNames)) Len() int }
ListTranformer must be implemented to allow Nerd to transparently manage resource names
type Logger ¶
type Logger interface {
Debugf(format string, args ...interface{})
}
Logger describes the logging dependency the services require
type ManagedNames ¶
type ManagedNames interface { GetName() string GetLabels() map[string]string SetLabels(map[string]string) SetName(name string) SetGenerateName(name string) }
ManagedNames allows for Nerd to transparently manage resources based on names and there prefixes
type Visor ¶
type Visor struct {
// contains filtered or unexported fields
}
Visor provides access to Kubernetes resources while transparently filtering, naming and labeling resources that are managed by the CLI.
func NewVisor ¶
func NewVisor(ns, prefix string, api kubernetes.Interface, crd crd.Interface, apiext apiext.Interface, logs Logger) *Visor
NewVisor will setup a Kubernetes visor
func (*Visor) CreateClusterResource ¶
func (k *Visor) CreateClusterResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
CreateClusterResource will use the kube RESTClient to create a cluster resource while using the context, adding the Nerd prefix and handling errors specific to our domain.
func (*Visor) CreateResource ¶
func (k *Visor) CreateResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
CreateResource will use the kube RESTClient to create a resource while using the context, adding the Nerd prefix and handling errors specific to our domain.
func (*Visor) DeleteResource ¶
DeleteResource will use the kube RESTClient to delete a resource by its name.
func (*Visor) FetchLogs ¶
func (k *Visor) FetchLogs(ctx context.Context, tail int64, w io.Writer, cname, pname string) (err error)
FetchLogs will read logs from container with name 'cname' from pod 'pname' and write it to writer 'w'
func (*Visor) GetClusterResource ¶
func (k *Visor) GetClusterResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
GetClusterResource will use the kube RESTClient to describe a resource by its name.
func (*Visor) GetResource ¶
func (k *Visor) GetResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
GetResource will use the kube RESTClient to describe a resource by its name.
func (*Visor) ListResources ¶
func (k *Visor) ListResources(ctx context.Context, t ResourceType, v ListTranformer, lselector, fselector []string) (err error)
ListResources will use the RESTClient to list resources while using the context and transparently filter resources managed by the CLI
func (*Visor) UpdateResource ¶
func (k *Visor) UpdateResource(ctx context.Context, t ResourceType, v ManagedNames, name string) (err error)
UpdateResource will use the kube RESTClient to update a resource while using the context, adding the Nerd prefix and handling errors specific to our domain.