Documentation
¶
Overview ¶
Package remote has the client implementation for interrogating and updating K8s objects and their metadata.
Index ¶
- Variables
- func GetPristineVersionForDiff(obj *unstructured.Unstructured) (*unstructured.Unstructured, string)
- type Client
- func (c *Client) Delete(obj model.K8sMeta, dryRun bool) (_ *SyncResult, finalError error)
- func (c *Client) DisplayName(o model.K8sMeta) string
- func (c *Client) Get(obj model.K8sMeta) (*unstructured.Unstructured, error)
- func (c *Client) IsNamespaced(gvk schema.GroupVersionKind) (bool, error)
- func (c *Client) ListObjects(scope ListQueryConfig) (Collection, error)
- func (c *Client) ObjectKey(obj model.K8sMeta) string
- func (c *Client) ResourceInterface(gvk schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error)
- func (c *Client) Sync(original model.K8sLocalObject, opts SyncOptions) (_ *SyncResult, finalError error)
- func (c *Client) ValidatorFor(gvk schema.GroupVersionKind) (k8smeta.Validator, error)
- type Collection
- type Config
- type ConnectOpts
- type ContextInfo
- type KubeAttributes
- type ListQueryConfig
- type ListQueryScope
- type SyncOptions
- type SyncResult
- type SyncResultType
Constants ¶
This section is empty.
Variables ¶
var ( ErrForbidden = errors.New("forbidden") // returned due to an authn/ authz error ErrNotFound = errors.New("not found") // returned when a remote object does not exist )
structured errors
Functions ¶
func GetPristineVersionForDiff ¶
func GetPristineVersionForDiff(obj *unstructured.Unstructured) (*unstructured.Unstructured, string)
GetPristineVersionForDiff interrogates annotations and extracts the pristine version of the supplied live object. If no annotations are found, it halfheartedly deletes known runtime information that is set on the server and returns the supplied object with those attributes removed.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thick remote client that provides high-level operations for commands as opposed to granular ones.
func (*Client) Delete ¶
Delete delete the supplied object if it exists. It does not do anything in dry-run mode.
func (*Client) DisplayName ¶ added in v0.6.2
DisplayName returns the display name of the supplied K8s object.
func (*Client) Get ¶
func (c *Client) Get(obj model.K8sMeta) (*unstructured.Unstructured, error)
Get returns the remote object matching the supplied metadata as an unstructured bag of attributes.
func (*Client) IsNamespaced ¶ added in v0.6.2
func (c *Client) IsNamespaced(gvk schema.GroupVersionKind) (bool, error)
IsNamespaced returns if the supplied group version kind is namespaced.
func (*Client) ListObjects ¶ added in v0.7.1
func (c *Client) ListObjects(scope ListQueryConfig) (Collection, error)
ListObjects returns all objects for the application and environment for the namespace /cluster scopes and kind filtering indicated by the query configuration.
func (*Client) ObjectKey ¶ added in v0.7.0
ObjectKey returns a string key for the supplied object that includes its group-kind, namespace and name. Input values are used in case canonical values cannot be derived (e.g. for custom resources whose CRDs haven't yet been created).
func (*Client) ResourceInterface ¶ added in v0.7.2
func (c *Client) ResourceInterface(gvk schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error)
ResourceInterface returns a dynamic resource interface for the supplied group version kind and namespace.
func (*Client) Sync ¶
func (c *Client) Sync(original model.K8sLocalObject, opts SyncOptions) (_ *SyncResult, finalError error)
Sync syncs the local object by either creating a new one or patching an existing one. It does not do anything in dry-run mode. It also does not create new objects if the caller has disabled the feature.
func (*Client) ValidatorFor ¶ added in v0.6.2
ValidatorFor returns a validator for the supplied group version kind.
type Collection ¶ added in v0.7.1
type Collection interface { Remove(obj []model.K8sQbecMeta) error // remove all objects represented by the input list ToList() []model.K8sQbecMeta // return a list of remaining objects }
Collection represents a set of k8s objects with the ability to remove a subset of objects from it.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config provides clients for specific contexts out of a kubeconfig file, with overrides for auth.
func NewConfig ¶
NewConfig returns a new configuration, adding flags to the supplied command to set k8s access overrides, prefixed by the supplied string.
func (*Config) Client ¶
func (c *Config) Client(opts ConnectOpts) (*Client, error)
Client returns a client that correctly points to the server as specified in the connection options. For this to work correctly, the kubernetes config that is used *must* have a cluster that has the supplied server URL as an endpoint, so that correct TLS certs are used for authenticating the server.
func (*Config) KubeAttributes ¶ added in v0.7.1
func (c *Config) KubeAttributes(opts ConnectOpts) (*KubeAttributes, error)
KubeAttributes returns client attributes for the supplied connection options.
type ConnectOpts ¶
type ConnectOpts struct { EnvName string // environment name, display purposes only ServerURL string // the server URL to connect to, must be configured in the kubeconfig Namespace string // the default namespace to set for the context Verbosity int // verbosity of client interactions }
ConnectOpts are the connection options required for the config.
type ContextInfo ¶
type ContextInfo struct { ServerURL string // the server URL defined for the cluster Namespace string // the namespace if set for the context, else "default" }
ContextInfo has information we care about a K8s context
func CurrentContextInfo ¶
func CurrentContextInfo() (*ContextInfo, error)
CurrentContextInfo returns information for the current context found in kubeconfig.
type KubeAttributes ¶ added in v0.7.1
type KubeAttributes struct { ConfigFile string `json:"configFile"` // the kubeconfig file or a list of such file separated by the list path separator Context string `json:"context"` // the context to use, if known Cluster string `json:"cluster"` // the cluster to use, always set Namespace string `json:"namespace"` // the nanespace to use }
KubeAttributes is a collection k8s attributes pertaining to an connection.
type ListQueryConfig ¶
type ListQueryConfig struct { Application string // must be non-blank Tag string // may be blank Environment string // must be non-blank ListQueryScope // the query scope for namespaces and non-namespaced resources KindFilter model.Filter // filters for object kind Concurrency int // concurrent queries to execute DisableAllNsQueries bool // do not perform list queries across namespaces when multiple namespaces in picture }
ListQueryConfig is the config with which to execute list queries.
type ListQueryScope ¶
type ListQueryScope struct { Namespaces []string // namespaces of interest ClusterObjects bool // whether to query for cluster objects }
ListQueryScope defines the scope at which list queries need to be executed.
type SyncOptions ¶
type SyncOptions struct { DryRun bool // do not actually create or update objects, return what would happen DisableCreate bool // only update objects if they exist, do not create new ones ShowSecrets bool // show secrets in patches and creations }
SyncOptions provides the caller with options for the sync operation.
type SyncResult ¶
type SyncResult struct { Type SyncResultType // the result type GeneratedName string // the actual name of an object that has generateName set Details string // additional details that are safe to print to console (e.g. no secrets) }
SyncResult is the result of a sync operation. There is no difference in the output for a real versus a dry-run.
type SyncResultType ¶
type SyncResultType int
SyncResultType indicates what notionally happened in a sync operation.
const ( SyncObjectsIdentical SyncResultType // sync was a noop due to local and remote being identical SyncSkip // object was skipped for sync (e.g. creation needed but disabled) SyncCreated // object was created SyncUpdated // object was updated SyncDeleted // object was deleted )
Sync result types