file

package
v0.0.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultStorageRoot = "/data"
)

Variables

This section is empty.

Functions

func NewConfigurationScanSummaryStorage added in v0.0.18

func NewConfigurationScanSummaryStorage(realStore *StorageQuerier) storage.Interface

func NewVulnerabilitySummaryStorage added in v0.0.20

func NewVulnerabilitySummaryStorage(realStore *StorageQuerier) storage.Interface

Types

type ConfigurationScanSummaryStorage added in v0.0.18

type ConfigurationScanSummaryStorage struct {
	// contains filtered or unexported fields
}

ConfigurationScanSummaryStorage offers a storage solution for ConfigurationScanSummary objects, implementing custom business logic for these objects and using the underlying default storage implementation.

func (*ConfigurationScanSummaryStorage) Count added in v0.0.18

Count is not supported for ConfigurationScanSummary objects. Objects are generated on the fly and not stored.

func (*ConfigurationScanSummaryStorage) Create added in v0.0.18

Create is not supported for ConfigurationScanSummary objects. Objects are generated on the fly and not stored.

func (*ConfigurationScanSummaryStorage) Delete added in v0.0.18

Delete is not supported for ConfigurationScanSummary objects. Objects are generated on the fly and not stored.

func (*ConfigurationScanSummaryStorage) Get added in v0.0.18

Get generates and returns a single ConfigurationScanSummary object for a namespace

func (*ConfigurationScanSummaryStorage) GetList added in v0.0.18

GetList generates and returns a list of ConfigurationScanSummary objects for the cluster

func (*ConfigurationScanSummaryStorage) GuaranteedUpdate added in v0.0.18

func (s *ConfigurationScanSummaryStorage) GuaranteedUpdate(
	ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool,
	preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error

GuaranteedUpdate is not supported for ConfigurationScanSummary objects. Objects are generated on the fly and not stored.

func (*ConfigurationScanSummaryStorage) Versioner added in v0.0.18

Versioner Returns Versioner associated with this interface.

func (*ConfigurationScanSummaryStorage) Watch added in v0.0.18

Watch is not supported for ConfigurationScanSummary objects. Objects are generated on the fly and not stored.

type StorageImpl

type StorageImpl struct {
	// contains filtered or unexported fields
}

StorageImpl offers a common interface for object marshaling/unmarshaling operations and hides all the storage-related operations behind it.

func (*StorageImpl) Count

func (s *StorageImpl) Count(key string) (int64, error)

Count returns number of different entries under the key (generally being path prefix).

func (*StorageImpl) Create

func (s *StorageImpl) Create(ctx context.Context, key string, obj, out runtime.Object, _ uint64) error

Create adds a new object at a key even when it already exists. 'ttl' is time-to-live in seconds (and is ignored). If no error is returned and out is not nil, out will be set to the read value from database.

func (*StorageImpl) Delete

Delete removes the specified key and returns the value that existed at that spot. If key didn't exist, it will return NotFound storage error. If 'cachedExistingObject' is non-nil, it can be used as a suggestion about the current version of the object to avoid read operation from storage to get it. However, the implementations have to retry in case suggestion is stale.

func (*StorageImpl) Get

func (s *StorageImpl) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error

Get unmarshals object found at key into objPtr. On a not found error, will either return a zero object of the requested type, or an error, depending on 'opts.ignoreNotFound'. Treats empty responses and nil response nodes exactly like a not found error. The returned contents may be delayed, but it is guaranteed that they will match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.

func (*StorageImpl) GetByCluster added in v0.0.18

func (s *StorageImpl) GetByCluster(ctx context.Context, apiVersion, kind string, listObj runtime.Object) error

GetByCluster returns all objects in a given cluster, given their api version and kind.

func (*StorageImpl) GetByNamespace added in v0.0.18

func (s *StorageImpl) GetByNamespace(ctx context.Context, apiVersion, kind, namespace string, listObj runtime.Object) error

GetByNamespace returns all objects in a given namespace, given their api version and kind.

func (*StorageImpl) GetList

func (s *StorageImpl) GetList(ctx context.Context, key string, _ storage.ListOptions, listObj runtime.Object) error

GetList unmarshalls objects found at key into a *List api object (an object that satisfies runtime.IsList definition). If 'opts.Recursive' is false, 'key' is used as an exact match. If `opts.Recursive' is true, 'key' is used as a prefix. The returned contents may be delayed, but it is guaranteed that they will match 'opts.ResourceVersion' according 'opts.ResourceVersionMatch'.

func (*StorageImpl) GuaranteedUpdate

func (s *StorageImpl) GuaranteedUpdate(
	ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool,
	preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error

GuaranteedUpdate keeps calling 'tryUpdate()' to update key 'key' (of type 'destination') retrying the update until success if there is index conflict. Note that object passed to tryUpdate may change across invocations of tryUpdate() if other writers are simultaneously updating it, so tryUpdate() needs to take into account the current contents of the object when deciding how the update object should look. If the key doesn't exist, it will return NotFound storage error if ignoreNotFound=false else `destination` will be set to the zero value of it's type. If the eventual successful invocation of `tryUpdate` returns an output with the same serialized contents as the input, it won't perform any update, but instead set `destination` to an object with those contents. If 'cachedExistingObject' is non-nil, it can be used as a suggestion about the current version of the object to avoid read operation from storage to get it. However, the implementations have to retry in case suggestion is stale.

Example:

s := /* implementation of Interface */ err := s.GuaranteedUpdate(

 "myKey", &MyType{}, true, preconditions,
 func(input runtime.Object, res ResponseMeta) (runtime.Object, *uint64, error) {
   // Before each invocation of the user defined function, "input" is reset to
   // current contents for "myKey" in database.
   curr := input.(*MyType)  // Guaranteed to succeed.

   // Make the modification
   curr.Counter++

   // Return the modified object - return an error to stop iterating. Return
   // a uint64 to alter the TTL on the object, or nil to keep it the same value.
   return cur, nil, nil
}, cachedExistingObject

)

func (*StorageImpl) Versioner

func (s *StorageImpl) Versioner() storage.Versioner

Versioner Returns Versioner associated with this interface.

func (*StorageImpl) Watch

Watch begins watching the specified key. Events are decoded into API objects, and any items selected by 'p' are sent down to returned watch.Interface. resourceVersion may be used to specify what version to begin watching, which should be the current resourceVersion, and no longer rv+1 (e.g. reconnecting without missing any updates). If resource version is "0", this interface will get current object at given key and send it in an "ADDED" event, before watch starts.

type StorageQuerier added in v0.0.18

type StorageQuerier interface {
	storage.Interface
	GetByNamespace(ctx context.Context, apiVersion, kind, namespace string, listObj runtime.Object) error
	GetByCluster(ctx context.Context, apiVersion, kind string, listObj runtime.Object) error
}

StorageQuerier wraps the storage.Interface and adds some extra methods which are used by the storage implementation.

func NewStorageImpl

func NewStorageImpl(appFs afero.Fs, root string) StorageQuerier

type VulnerabilitySummaryStorage added in v0.0.20

type VulnerabilitySummaryStorage struct {
	// contains filtered or unexported fields
}

VulnerabilitySummaryStorage implements a storage for vulnerability summaries.

It provides vulnerability summaries for scopes like namespace and cluster. To get these summaries, the storage fetches existing stored VulnerabilitySummary objects and aggregates them on the fly.

func (*VulnerabilitySummaryStorage) Count added in v0.0.20

func (s *VulnerabilitySummaryStorage) Count(key string) (int64, error)

Count is not supported for VulnerabilitySummary objects. Objects are generated on the fly and not stored.

func (*VulnerabilitySummaryStorage) Create added in v0.0.20

func (s *VulnerabilitySummaryStorage) Create(ctx context.Context, key string, obj, out runtime.Object, _ uint64) error

Create is not supported for VulnerabilitySummary objects. Objects are generated on the fly and not stored.

func (*VulnerabilitySummaryStorage) Delete added in v0.0.20

Delete is not supported for VulnerabilitySummary objects. Objects are generated on the fly and not stored.

func (*VulnerabilitySummaryStorage) Get added in v0.0.20

func (*VulnerabilitySummaryStorage) GetList added in v0.0.20

func (*VulnerabilitySummaryStorage) GuaranteedUpdate added in v0.0.20

func (s *VulnerabilitySummaryStorage) GuaranteedUpdate(
	ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool,
	preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error

GuaranteedUpdate is not supported for VulnerabilitySummary objects. Objects are generated on the fly and not stored.

func (*VulnerabilitySummaryStorage) Versioner added in v0.0.20

Versioner Returns Versioner associated with this interface.

func (*VulnerabilitySummaryStorage) Watch added in v0.0.20

Watch is not supported for VulnerabilitySummary objects. Objects are generated on the fly and not stored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL