Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StaticDiscardLogger = logging.Discard()
Functions ¶
This section is empty.
Types ¶
type LoggerInjectable ¶
LoggerInjectable signals that the corresponding object allows injection of a logger. Before calling the internal Persister functions, the Persister's InjectLogger function will be called, if it implements the LoggerInjectable interface. This allows passing down the contextified logger. After calling the function, InjectLogger will be called again with a pointer to the discard logger, to 'uninject' the logger.
type Persister ¶
type Persister interface { // Exists returns whether data for the given resource exists in the persistency, without returning the actual data. // It could be implemented generically by checking if the return value of Get is (nil, nil), // but depending on the storage system, checking for existence could be implemented in a more efficient manner. Exists(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (bool, error) // Get returns the currently persisted data for the specified resource. // If no data for the resource exists, it is expected to return (nil, nil) and not an error. Get(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) (*unstructured.Unstructured, error) // Persist persists the given resource. // Depending on the implementation, it might check for its existence in the storage first and only update it if it differs. // It returns the transformed version of the given resource, which should be the one that is persisted after this command. // The second return value is 'true' if the resource in the storage has changed (meaning the given resource differed from the one in the storage when this method was called). Persist(ctx context.Context, resource *unstructured.Unstructured, t Transformer, subPath string) (*unstructured.Unstructured, bool, error) // Delete deletes the resource from persistence. // If the resource does not exist, Delete will not return an error. Delete(ctx context.Context, name, namespace string, gvk schema.GroupVersionKind, subPath string) error // InternalPersister returns the internal persister, if the current implementation wraps another implementation. // Otherwise, nil is returned. InternalPersister() Persister }
Persister is an interface for all implementations which are able to persist the recorded changes somehow.
func AddLoggingLayer ¶
AddDebugLoggingLayer wraps the given Persister with a logging wrapper that adds logs before and after each call to the internal Persister. It is strongly recommended to use only Debug log level for all non-development purposes, as everything else will likely clutter the logs.
type Transformer ¶
type Transformer interface { // Transform prepares the resource for persistence by removing (volatile) fields which should not be persisted. Transform(*unstructured.Unstructured) (*unstructured.Unstructured, error) }
Transformer transforms between unstructured.Unstructured and the storage.