Documentation ¶
Index ¶
- Variables
- func ContextFromIP(apiServer string) (*Cluster, *Context, error)
- func Contexts() ([]string, error)
- func IPFromContext(name string) (ip string, err error)
- func Kubeconfig() (objx.Map, error)
- func UnmarshalTable(raw string, ptr interface{}) error
- type ApplyOpts
- type Client
- type Cluster
- type Config
- type Context
- type DeleteOpts
- type ErrorElementsMismatch
- type ErrorNoCluster
- type ErrorNoContext
- type ErrorNotFound
- type ErrorUnknownResource
- type FilterWriter
- type Info
- type Kubectl
- func (k Kubectl) Apply(data manifest.List, opts ApplyOpts) error
- func (k Kubectl) Close() error
- func (k Kubectl) Delete(namespace, kind, name string, opts DeleteOpts) error
- func (k Kubectl) DeleteByLabels(namespace string, labels map[string]interface{}, opts DeleteOpts) error
- func (k Kubectl) DiffServerSide(data manifest.List) (*string, error)
- func (k Kubectl) Get(namespace, kind, name string) (manifest.Manifest, error)
- func (k Kubectl) GetByLabels(namespace string, labels map[string]interface{}) (manifest.List, error)
- func (k Kubectl) Info() Info
- func (k Kubectl) Namespaces() (map[string]bool, error)
- func (k Kubectl) Resources() (Resources, error)
- type Resource
- type Resources
Constants ¶
This section is empty.
Variables ¶
var ErrorNoHeader = fmt.Errorf("table has no header")
ErrorNoHeader occurs when the table lacks an ALL-CAPS header
var ErrorNoMatch error = errors.New("no matches found")
ErrorNoMatch occurs when no item matched had the expected value
Functions ¶
func ContextFromIP ¶ added in v0.7.0
ContextFromIP searches the $KUBECONFIG for a context using a cluster that matches the apiServer
func IPFromContext ¶ added in v0.7.0
IPFromContext parses $KUBECONFIG, finds the cluster with the given name and returns the cluster's endpoint
func Kubeconfig ¶ added in v0.7.0
Kubeconfig returns the merged $KUBECONFIG of the host
func UnmarshalTable ¶ added in v0.9.0
UnmarshalTable unmarshals a raw CLI table into ptr. `json` package is used for getting the dat into the ptr, `json:` struct tags can be used.
Types ¶
type ApplyOpts ¶
type ApplyOpts struct { // force allows to ignore checks and force the operation Force bool // validate allows to enable/disable kubectl validation Validate bool // autoApprove allows to skip the interactive approval AutoApprove bool }
ApplyOpts allow to specify additional parameter for apply operations
type Client ¶
type Client interface { // Get the specified object(s) from the cluster Get(namespace, kind, name string) (manifest.Manifest, error) GetByLabels(namespace string, labels map[string]interface{}) (manifest.List, error) // Apply the configuration to the cluster. `data` must contain a plaintext // format that is `kubectl-apply(1)` compatible Apply(data manifest.List, opts ApplyOpts) error // DiffServerSide runs the diff operation on the server and returns the // result in `diff(1)` format DiffServerSide(data manifest.List) (*string, error) // Delete the specified object(s) from the cluster Delete(namespace, kind, name string, opts DeleteOpts) error DeleteByLabels(namespace string, labels map[string]interface{}, opts DeleteOpts) error // Namespaces the cluster currently has Namespaces() (map[string]bool, error) // Resources returns all known api-resources of the cluster Resources() (Resources, error) // Info returns known informational data about the client. Best effort based, // fields of `Info` that cannot be stocked with valuable data, e.g. // due to an error, shall be left nil. Info() Info // Close may run tasks once the client is no longer needed. Close() error }
Client for working with Kubernetes
type Cluster ¶ added in v0.9.0
type Cluster struct { Cluster struct { Server string `json:"server"` } `json:"cluster"` Name string `json:"name"` }
Cluster is a kubectl cluster
type Config ¶ added in v0.9.0
Config represents a single KUBECONFIG entry (single context + cluster) Omits the arrays of the original schema, to ease using.
type Context ¶ added in v0.9.0
type Context struct { Context struct { Cluster string `json:"cluster"` User string `json:"user"` Namespace string `json:"namespace"` } `json:"context"` Name string `json:"name"` }
Context is a kubectl context
type DeleteOpts ¶
type DeleteOpts ApplyOpts
DeleteOpts allow to specify additional parameters for delete operations Currently not different from ApplyOpts, but may be required in the future
type ErrorElementsMismatch ¶ added in v0.9.0
type ErrorElementsMismatch struct {
Header, Row int
}
ErrorElementsMismatch occurs when a row has a different count of elements than it's header
func (ErrorElementsMismatch) Error ¶ added in v0.9.0
func (e ErrorElementsMismatch) Error() string
type ErrorNoCluster ¶ added in v0.9.0
type ErrorNoCluster string
ErrorNoCluster means that the cluster that was searched for couldn't be found
func (ErrorNoCluster) Error ¶ added in v0.9.0
func (e ErrorNoCluster) Error() string
type ErrorNoContext ¶ added in v0.9.0
type ErrorNoContext string
ErrorNoContext means that the context that was searched for couldn't be found
func (ErrorNoContext) Error ¶ added in v0.9.0
func (e ErrorNoContext) Error() string
type ErrorNotFound ¶
type ErrorNotFound struct {
// contains filtered or unexported fields
}
ErrorNotFound means that the requested object is not found on the server
func (ErrorNotFound) Error ¶
func (e ErrorNotFound) Error() string
type ErrorUnknownResource ¶
type ErrorUnknownResource struct {
// contains filtered or unexported fields
}
ErrorUnknownResource means that the requested resource type is unknown to the server
func (ErrorUnknownResource) Error ¶
func (e ErrorUnknownResource) Error() string
type FilterWriter ¶
type FilterWriter struct {
// contains filtered or unexported fields
}
FilterWriter is an io.Writer that discards every message that matches at least one of the regular expressions.
type Info ¶
type Info struct { // versions ClientVersion *semver.Version ServerVersion *semver.Version // kubeconfig (chosen context + cluster) Kubeconfig Config }
Info contains metadata about the client and its environment
type Kubectl ¶
type Kubectl struct {
// contains filtered or unexported fields
}
Kubectl uses the `kubectl` command to operate on a Kubernetes cluster
func (Kubectl) Delete ¶
func (k Kubectl) Delete(namespace, kind, name string, opts DeleteOpts) error
Delete removes the specified object from the cluster
func (Kubectl) DeleteByLabels ¶
func (k Kubectl) DeleteByLabels(namespace string, labels map[string]interface{}, opts DeleteOpts) error
DeleteByLabels removes all objects matched by the given labels from the cluster
func (Kubectl) DiffServerSide ¶
DiffServerSide takes the desired state and computes the differences on the server, returning them in `diff(1)` format
func (Kubectl) GetByLabels ¶
func (k Kubectl) GetByLabels(namespace string, labels map[string]interface{}) (manifest.List, error)
GetByLabels retrieves all objects matched by the given labels from the cluster
func (Kubectl) Namespaces ¶
Namespaces of the cluster