Documentation ¶
Index ¶
- Constants
- func DynamicResourceClient(dynamicClient dynamic.Interface, mapper meta.RESTMapper, ...) (dynamic.ResourceInterface, error)
- func ListAndWatch(ctx context.Context, lw ListerWatcher, opts metav1.ListOptions) (watch.Interface, error)
- func NewClientError(err error) *apierrors.StatusError
- type ListFunc
- type ListWatch
- type Lister
- type ListerWatcher
- type ListerWatcherFactory
- type Manager
- type Options
- type Runnable
- type WatchFunc
- type Watcher
Constants ¶
const ( // RESTConfigTimeout sets the REST config timeout for the remediator to 1 hour. // // RESTConfigTimeout should be longer than 2*minWatchTimeout to respect // the watch timeout set by `ListOptions.TimeoutSeconds` in the watch // create requests. RESTConfigTimeout = time.Hour )
const StatusClientError = 600
StatusClientError is a "fake" HTTP status code used to indicate a client-side error. Normal status codes go from 1xx-5xx, so using 600 should be safe, unless Kubernetes starts using it.
const StatusReasonClientError metav1.StatusReason = "ClientError"
StatusReasonClientError is the reason used for client-side errors. It's the human readable form of the `StatusClientError` status code.
Variables ¶
This section is empty.
Functions ¶
func DynamicResourceClient ¶ added in v1.15.1
func DynamicResourceClient(dynamicClient dynamic.Interface, mapper meta.RESTMapper, gvk schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error)
DynamicResourceClient uses a generic dynamic.Interface to build a resource-specific client.
- For cluster-scoped resources, namespace must be empty.
- For namespace-scoped resources, namespace may optionally be empty, to include resources in all namespaces.
func ListAndWatch ¶ added in v1.15.1
func ListAndWatch(ctx context.Context, lw ListerWatcher, opts metav1.ListOptions) (watch.Interface, error)
ListAndWatch wraps a list and watch and returns a watch interface. This way, you can watch from "now" and get all the existing objects, not just new changes to objects.
If ResourceVersion is specified, ListAndWatch acts like a normal Watch. Otherwise, a List is performed first and `Added` events are simulated, followed by a Watch, where subsequent `Added` events for pre-existing objects are converted to `Modified` events, unless that object is deleted first.
func NewClientError ¶ added in v1.15.1
func NewClientError(err error) *apierrors.StatusError
NewClientError returns an error indicating that there was a client-side error. Unfortunately, the watch.Interface does not include a way to return client-side errors that preserves their error type. But at least this way we can tell the difference between a client-side error and a server-side error.
Types ¶
type ListFunc ¶ added in v1.15.1
type ListFunc func(ctx context.Context, options metav1.ListOptions) (*unstructured.UnstructuredList, error)
ListFunc knows how to list resources.
type ListWatch ¶ added in v1.15.1
ListWatch implements the ListerWatcher interface. ListFunc and WatchFunc must not be nil
func NewFilteredListWatchFromClient ¶ added in v1.15.1
func NewFilteredListWatchFromClient(dynamicClient dynamic.Interface, mapper meta.RESTMapper, gvk schema.GroupVersionKind, namespace string, optionsModifier func(options *metav1.ListOptions)) *ListWatch
NewFilteredListWatchFromClient creates a new ListWatch that can dynamically modify ListOptions. This allows specifying option defaults and overrides.
func NewListWatchFromClient ¶ added in v1.15.1
func NewListWatchFromClient(dynamicClient dynamic.Interface, mapper meta.RESTMapper, gvk schema.GroupVersionKind, namespace string) *ListWatch
NewListWatchFromClient creates a new ListWatch.
func (*ListWatch) List ¶ added in v1.15.1
func (lw *ListWatch) List(ctx context.Context, options metav1.ListOptions) (*unstructured.UnstructuredList, error)
List a set of apiserver resources
type Lister ¶ added in v1.15.1
type Lister interface { // List returns a list of unstructured objects. // List can be cancelled with the input context. List(ctx context.Context, options metav1.ListOptions) (*unstructured.UnstructuredList, error) }
Lister is any object that performs listing of a resource.
type ListerWatcher ¶ added in v1.15.1
ListerWatcher is any object can perform both lists and watches. This is similar to the ListerWatcher in client-go, except it uses the dynamic client to return unstructured objects without requiring a local scheme.
type ListerWatcherFactory ¶ added in v1.15.1
type ListerWatcherFactory func(gvk schema.GroupVersionKind, namespace string) ListerWatcher
ListerWatcherFactory knows how to build ListerWatchers for the specified GroupVersionKind and Namespace.
func NewListerWatcherFactoryFromClient ¶ added in v1.15.1
func NewListerWatcherFactoryFromClient(cfg *rest.Config) (ListerWatcherFactory, error)
NewListerWatcherFactoryFromClient creates a ListerWatcherFactory using a dynamic client and mapper build from the specified REST config.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager accepts new resource lists that are parsed from Git and then updates declared resources and get GVKs.
func NewManager ¶
func NewManager(scope declared.Scope, syncName string, cfg *rest.Config, q *queue.ObjectQueue, decls *declared.Resources, options *Options, ch conflict.Handler) (*Manager, error)
NewManager starts a new watch manager
func (*Manager) ManagementConflict ¶
ManagementConflict returns true if any watcher notices any management conflicts. This function is threadsafe.
func (*Manager) NeedsUpdate ¶
NeedsUpdate returns true if the Manager's watches need to be updated. This function is threadsafe.
func (*Manager) UpdateWatches ¶
func (m *Manager) UpdateWatches(ctx context.Context, gvkMap map[schema.GroupVersionKind]struct{}) status.MultiError
UpdateWatches accepts a map of GVKs that should be watched and takes the following actions:
- stop watchers for any GroupVersionKind that is not present in the given map.
- start watchers for any GroupVersionKind that is present in the given map and not present in the current watch map.
This function is threadsafe.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options contains options for creating a watch manager.
type Runnable ¶
type Runnable interface { Stop() Run(ctx context.Context) status.Error ManagementConflict() bool SetManagementConflict(object client.Object, commit string) ClearManagementConflict() // contains filtered or unexported methods }
Runnable defines the custom watch interface.
func NewFiltered ¶
func NewFiltered(cfg watcherConfig) Runnable
NewFiltered returns a new filtered watcher initialized with the given options.