Documentation ¶
Index ¶
- Variables
- func ContextFromIP(apiServer string) (*Cluster, *Context, error)
- func ContextFromName(contextName 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 ErrNamespaceNotFound
- type ErrorElementsMismatch
- type ErrorNoCluster
- type ErrorNoContext
- type ErrorNotFound
- type ErrorNothingReturned
- type ErrorUnknownResource
- type FilterWriter
- type GetByStateOpts
- 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) DiffClientSide(data manifest.List) (*string, 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, kind string, labels map[string]string) (manifest.List, error)
- func (k Kubectl) GetByState(data manifest.List, opts GetByStateOpts) (manifest.List, error)
- func (k Kubectl) Info() Info
- func (k Kubectl) Namespace(namespace string) (manifest.Manifest, error)
- func (k Kubectl) Namespaces() (map[string]bool, error)
- func (k Kubectl) Resources() (Resources, error)
- func (k Kubectl) ValidateServerSide(data manifest.List) (*string, 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 = 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 ContextFromName ¶ added in v0.21.0
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 // DryRun string passed to kubectl as --dry-run=<DryRun> DryRun string // ApplyStrategy to pick a final method for deploying generated objects ApplyStrategy string }
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, kind string, labels map[string]string) (manifest.List, error) GetByState(data manifest.List, opts GetByStateOpts) (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 // Namespaces the cluster currently has Namespaces() (map[string]bool, error) // Namespace retrieves a namespace from the cluster Namespace(namespace string) (manifest.Manifest, 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 ErrNamespaceNotFound ¶ added in v0.15.1
type ErrNamespaceNotFound struct {
Namespace string
}
func (ErrNamespaceNotFound) Error ¶ added in v0.15.1
func (e ErrNamespaceNotFound) Error() string
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 ErrorNothingReturned ¶ added in v0.14.0
type ErrorNothingReturned struct{}
ErrorNothingReturned means that there was no output returned
func (ErrorNothingReturned) Error ¶ added in v0.14.0
func (e ErrorNothingReturned) 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 GetByStateOpts ¶ added in v0.14.0
type GetByStateOpts struct { // ignoreNotFound allows to ignore errors caused by missing objects IgnoreNotFound bool }
GetByStateOpts allow to specify additional parameters for GetByState function Currently there is just ignoreNotFound parameter which is only useful for GetByState() so we only have GetByStateOpts instead of more generic GetOpts for all get operations
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 NewFromNames ¶ added in v0.21.0
func (Kubectl) Delete ¶
func (k Kubectl) Delete(namespace, kind, name string, opts DeleteOpts) error
Delete deletes the given Kubernetes resource from the cluster
func (Kubectl) DiffClientSide ¶ added in v0.17.0
DiffClientSide takes the desired state and computes the differences, returning them in `diff(1)` format
func (Kubectl) DiffServerSide ¶
DiffServerSide takes the desired state and computes the differences server-side, returning them in `diff(1)` format
func (Kubectl) GetByLabels ¶
func (k Kubectl) GetByLabels(namespace, kind string, labels map[string]string) (manifest.List, error)
GetByLabels retrieves all objects matched by the given labels from the cluster. Set namespace to empty string for --all-namespaces
func (Kubectl) GetByState ¶ added in v0.10.0
GetByState returns the full object, including runtime fields for each resource in the state
func (Kubectl) Namespaces ¶
Namespaces of the cluster
func (Kubectl) ValidateServerSide ¶ added in v0.21.0
ValidateServerSide takes the desired state and computes the differences, returning them in `diff(1)` format It also validates that manifests are valid server-side, but still returns the client-side diff
type Resource ¶ added in v0.9.0
type Resource struct { APIGroup string `json:"APIGROUP"` APIVersion string `json:"APIVERSION"` Kind string `json:"KIND"` Name string `json:"NAME"` Namespaced bool `json:"NAMESPACED,string"` Shortnames string `json:"SHORTNAMES"` Verbs string `json:"VERBS"` Categories string `json:"CATEGORIES"` }
Resource is a Kubernetes API Resource