Documentation ¶
Overview ¶
Package remote has the client implementation for interrogating and updating K8s objects and their metadata.
Index ¶
- Constants
- Variables
- func GetPristineVersionForDiff(obj *unstructured.Unstructured) (*unstructured.Unstructured, string)
- type Client
- func (c *Client) Delete(ctx context.Context, obj model.K8sMeta, opts DeleteOptions) (_ *SyncResult, finalError error)
- func (c *Client) DisplayName(o model.K8sMeta) string
- func (c *Client) Get(ctx context.Context, obj model.K8sMeta) (*unstructured.Unstructured, error)
- func (c *Client) IsNamespaced(gvk schema.GroupVersionKind) (bool, error)
- func (c *Client) ListObjects(ctx context.Context, 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(ctx context.Context, original model.K8sLocalObject, opts SyncOptions) (_ *SyncResult, finalError error)
- func (c *Client) ValidatorFor(ctx context.Context, gvk schema.GroupVersionKind) (k8smeta.Validator, error)
- type Collection
- type ConditionFunc
- type Config
- type ConnectOpts
- type ContextInfo
- type DeleteOptions
- type GVKFilter
- type KubeAttributes
- type ListQueryConfig
- type ListQueryScope
- type SyncOptions
- type SyncResult
- type SyncResultType
- type TypeWaitOptions
Constants ¶
const (
ForceInClusterContext = "__incluster__"
)
Constants for special context values.
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 ¶
func (c *Client) Delete(ctx context.Context, obj model.K8sMeta, opts DeleteOptions) (_ *SyncResult, finalError error)
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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, 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
func (c *Client) ValidatorFor(ctx context.Context, gvk schema.GroupVersionKind) (k8smeta.Validator, error)
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 ConditionFunc ¶ added in v0.10.0
ConditionFunc returns if a specific condition tests as true for the supplied object.
type Config ¶
type Config struct { ListPageSize int64 // 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) CurrentContextInfo ¶ added in v0.14.0
func (c *Config) CurrentContextInfo() (*ContextInfo, error)
CurrentContextInfo returns information for the current context found in kubeconfig.
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 ForceContext string // __incluster__ or __current or named context }
ConnectOpts are the connection options required for the config.
type ContextInfo ¶
type ContextInfo struct { ContextName string // the name of the context 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
type DeleteOptions ¶ added in v0.10.0
type DeleteOptions struct { DryRun bool // do not actually delete, return what would happen DisableDeleteFn ConditionFunc // test to see if deletion should be disabled. }
DeleteOptions provides the caller with options for the delete operation.
type GVKFilter ¶ added in v0.12.2
type GVKFilter func(gvk schema.GroupVersionKind) bool
GVKFilter returns true if a gvk needs to be processed
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 GVKFilter // filters for group version kind Concurrency int // concurrent queries to execute ClusterScopedLists bool // perform list queries across namespaces when multiple namespaces in picture Limit int64 // chunk limit for query }
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 DisableUpdateFn ConditionFunc // do not update an existing object WaitOptions TypeWaitOptions // opts for waiting 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