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) Get(obj model.K8sMeta) (*unstructured.Unstructured, error)
- func (c *Client) ListExtraObjects(ignore []model.K8sQbecMeta, scope ListQueryConfig) ([]model.K8sQbecMeta, error)
- func (c *Client) ServerMetadata() *ServerMetadata
- func (c *Client) Sync(original model.K8sLocalObject, opts SyncOptions) (_ *SyncResult, finalError error)
- type Config
- type ConnectOpts
- type ContextInfo
- type ListQueryConfig
- type ListQueryScope
- type ServerMetadata
- type SyncOptions
- type SyncResult
- type SyncResultType
- type Validator
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 ErrSchemaNotFound = errors.New("schema not found") // returned when a validation schema is not found )
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) 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) ListExtraObjects ¶
func (c *Client) ListExtraObjects(ignore []model.K8sQbecMeta, scope ListQueryConfig) ([]model.K8sQbecMeta, error)
ListExtraObjects returns all objects for the application and environment that do not belong to the ignore list supplied. The ignore list is usually the unfiltered list of all objects belonging to all components for an environment.
func (*Client) ServerMetadata ¶
func (c *Client) ServerMetadata() *ServerMetadata
ServerMetadata returns server metadata for the cluster that this client connects to.
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.
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.
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 ListQueryConfig ¶
type ListQueryConfig struct { Application string // must be non-blank Environment string // must be non-blank ListQueryScope ComponentFilter model.Filter // filters for object component 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 ServerMetadata ¶
type ServerMetadata struct {
// contains filtered or unexported fields
}
ServerMetadata provides metadata information for a K8s cluster.
func (*ServerMetadata) DisplayName ¶
func (sm *ServerMetadata) DisplayName(o model.K8sMeta) string
DisplayName returns a display name for the supplied object in a format that mimics phrases that can be pasted into kubectl commands.
func (*ServerMetadata) IsNamespaced ¶
func (sm *ServerMetadata) IsNamespaced(gvk schema.GroupVersionKind) (bool, error)
IsNamespaced returns true if the resource corresponding to the supplied GroupVersionKind is namespaced.
func (*ServerMetadata) ValidatorFor ¶
func (sm *ServerMetadata) ValidatorFor(gvk schema.GroupVersionKind) (Validator, error)
ValidatorFor returns a validator for the supplied GroupVersionKind.
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 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
type Validator ¶
type Validator interface { // Validate validates the supplied object and returns a slice of validation errors. Validate(obj *unstructured.Unstructured) []error }
Validator validates documents of a specific type.
Source Files
¶
- client.go
- collection.go
- config.go
- discovery-cache.go
- meta.go
- patch.go
- pristine.go
- query.go