Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeAggregatedData(storage ContainerProfileStorage, ctx context.Context, key string, ...) (string, string, string)
- func DeflateContainerProfileSpec(container softwarecomposition.ContainerProfileSpec, sbomSet mapset.Set[string]) softwarecomposition.ContainerProfileSpec
- func DeflateLabelSelectorRequirement(in []metav1.LabelSelectorRequirement) []metav1.LabelSelectorRequirement
- func DeflateRulePolicies(in map[string]softwarecomposition.RulePolicy) map[string]softwarecomposition.RulePolicy
- func DeflateSortString(in []string) []string
- func DeflateStringer[T Stringer](in []T) []T
- func DeleteMetadata(conn *sqlite.Conn, path string, metadata runtime.Object) error
- func DeleteTimeSeriesContainerEntries(conn *sqlite.Conn, path string) error
- func IsPayloadFile(path string) bool
- func KeysToPath(prefix, root, kind, ns, name string) string
- func ListTimeSeriesContainers(conn *sqlite.Conn, path string) (map[string][]softwarecomposition.TimeSeriesContainers, error)
- func ListTimeSeriesExpired(conn *sqlite.Conn, d time.Duration) ([]string, error)
- func ListTimeSeriesWithData(conn *sqlite.Conn) ([]string, error)
- func NewApplicationProfileStorage(realStore StorageQuerier) storage.Interface
- func NewConfigurationScanSummaryStorage(realStore StorageQuerier) storage.Interface
- func NewGeneratedNetworkPolicyStorage(realStore StorageQuerier, nnStore storage.Interface) storage.Interface
- func NewKubernetesClient() (*kubernetes.Clientset, error)
- func NewNetworkNeighborhoodStorage(realStore StorageQuerier) storage.Interface
- func NewPool(path string, size int) *sqlitemigration.Pool
- func NewTestPool(dir string) *sqlitemigration.Pool
- func NewVulnerabilitySummaryStorage(realStore StorageQuerier) storage.Interface
- func PathToKeys(path string) (string, string, string, string, string)
- func ReadMetadata(conn *sqlite.Conn, path string) ([]byte, error)
- func ReplaceTimeSeriesContainerEntries(conn *sqlite.Conn, path, seriesID string, deleteTimeSeries []string, ...) error
- func SplitProfileName(profileName string) (name string, tsSuffix string)
- func WriteJSON(conn *sqlite.Conn, path string, metadataJSON []byte) error
- func WriteTimeSeriesEntry(conn *sqlite.Conn, ...) error
- type ApplicationProfileProcessor
- type ApplicationProfileStorage
- func (a ApplicationProfileStorage) CompactRevision() int64
- func (a ApplicationProfileStorage) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error
- func (a ApplicationProfileStorage) Delete(ctx context.Context, key string, out runtime.Object, ...) error
- func (a ApplicationProfileStorage) Get(ctx context.Context, key string, opts storage.GetOptions, ...) error
- func (a ApplicationProfileStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (a ApplicationProfileStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (a ApplicationProfileStorage) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ...) error
- func (a ApplicationProfileStorage) ReadinessCheck() error
- func (a ApplicationProfileStorage) RequestWatchProgress(ctx context.Context) error
- func (a ApplicationProfileStorage) SetKeysFunc(_ storage.KeysFunc)
- func (a ApplicationProfileStorage) Stats(_ context.Context) (storage.Stats, error)
- func (a ApplicationProfileStorage) Versioner() storage.Versioner
- func (a ApplicationProfileStorage) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)
- type ConfigurationScanSummaryStorage
- func (s *ConfigurationScanSummaryStorage) CompactRevision() int64
- func (ConfigurationScanSummaryStorage) Count(key string) (int64, error)
- func (ConfigurationScanSummaryStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
- func (ConfigurationScanSummaryStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, ...) error
- func (s *ConfigurationScanSummaryStorage) Get(ctx context.Context, key string, _ storage.GetOptions, objPtr runtime.Object) error
- func (s *ConfigurationScanSummaryStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (s *ConfigurationScanSummaryStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (ConfigurationScanSummaryStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, ...) error
- func (ConfigurationScanSummaryStorage) ReadinessCheck() error
- func (ConfigurationScanSummaryStorage) RequestWatchProgress(context.Context) error
- func (s *ConfigurationScanSummaryStorage) SetKeysFunc(_ storage.KeysFunc)
- func (s *ConfigurationScanSummaryStorage) Stats(_ context.Context) (storage.Stats, error)
- func (ConfigurationScanSummaryStorage) Versioner() storage.Versioner
- func (ConfigurationScanSummaryStorage) Watch(_ context.Context, _ string, _ storage.ListOptions) (watch.Interface, error)
- type ConsolidatedSlugData
- type ContainerProfileProcessor
- func (a *ContainerProfileProcessor) AfterCreate(ctx context.Context, object runtime.Object) error
- func (a *ContainerProfileProcessor) ConsolidateTimeSeries(ctx context.Context) error
- func (a *ContainerProfileProcessor) PreSave(ctx context.Context, object runtime.Object) error
- func (a *ContainerProfileProcessor) SetStorage(containerProfileStorage ContainerProfileStorage)
- type ContainerProfileStorage
- type ContainerProfileStorageImpl
- func (c *ContainerProfileStorageImpl) BeginTransaction(ctx context.Context) (func(*error), error)
- func (c *ContainerProfileStorageImpl) DeleteContainerProfile(ctx context.Context, key string) error
- func (c *ContainerProfileStorageImpl) DeleteTimeSeriesContainerEntries(ctx context.Context, key string) error
- func (c *ContainerProfileStorageImpl) GetContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
- func (c *ContainerProfileStorageImpl) GetContainerProfileMetadata(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
- func (c *ContainerProfileStorageImpl) GetSbom(ctx context.Context, key string) (softwarecomposition.SBOMSyft, error)
- func (c *ContainerProfileStorageImpl) GetStorageImpl() *StorageImpl
- func (c *ContainerProfileStorageImpl) GetTsContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
- func (c *ContainerProfileStorageImpl) ListTimeSeriesContainers(ctx context.Context, key string) (map[string][]softwarecomposition.TimeSeriesContainers, error)
- func (c *ContainerProfileStorageImpl) ListTimeSeriesExpired(ctx context.Context, threshold time.Duration) ([]string, error)
- func (c *ContainerProfileStorageImpl) ListTimeSeriesWithData(ctx context.Context) ([]string, error)
- func (c *ContainerProfileStorageImpl) ReplaceTimeSeriesContainerEntries(ctx context.Context, key, seriesID string, deleteTimeSeries []string, ...) error
- func (c *ContainerProfileStorageImpl) SaveContainerProfile(ctx context.Context, key string, profile *softwarecomposition.ContainerProfile) error
- func (c *ContainerProfileStorageImpl) UpdateApplicationProfile(ctx context.Context, key, prefix, root, namespace, slug, wlid string, ...) error
- func (c *ContainerProfileStorageImpl) UpdateNetworkNeighborhood(ctx context.Context, key, prefix, root, namespace, slug, wlid string, ...) error
- func (c *ContainerProfileStorageImpl) WithConnection(ctx context.Context) (context.Context, func(), error)
- func (c *ContainerProfileStorageImpl) WriteTimeSeriesEntry(ctx context.Context, ...) error
- type DefaultProcessor
- type DirectIOReader
- type DirectIOWriter
- type GeneratedNetworkPolicyStorage
- func (s *GeneratedNetworkPolicyStorage) CompactRevision() int64
- func (GeneratedNetworkPolicyStorage) Count(key string) (int64, error)
- func (GeneratedNetworkPolicyStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
- func (GeneratedNetworkPolicyStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, ...) error
- func (s *GeneratedNetworkPolicyStorage) Get(ctx context.Context, key string, opts storage.GetOptions, ...) error
- func (s *GeneratedNetworkPolicyStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (s *GeneratedNetworkPolicyStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (GeneratedNetworkPolicyStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, ...) error
- func (GeneratedNetworkPolicyStorage) ReadinessCheck() error
- func (GeneratedNetworkPolicyStorage) RequestWatchProgress(context.Context) error
- func (s *GeneratedNetworkPolicyStorage) SetKeysFunc(_ storage.KeysFunc)
- func (s *GeneratedNetworkPolicyStorage) Stats(_ context.Context) (storage.Stats, error)
- func (GeneratedNetworkPolicyStorage) Versioner() storage.Versioner
- func (GeneratedNetworkPolicyStorage) Watch(_ context.Context, _ string, _ storage.ListOptions) (watch.Interface, error)
- type KubernetesAPI
- type NetworkNeighborhoodProcessor
- type NetworkNeighborhoodStorage
- func (a NetworkNeighborhoodStorage) CompactRevision() int64
- func (a NetworkNeighborhoodStorage) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error
- func (a NetworkNeighborhoodStorage) Delete(ctx context.Context, key string, out runtime.Object, ...) error
- func (a NetworkNeighborhoodStorage) Get(ctx context.Context, key string, opts storage.GetOptions, ...) error
- func (a NetworkNeighborhoodStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (a NetworkNeighborhoodStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (a NetworkNeighborhoodStorage) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ...) error
- func (a NetworkNeighborhoodStorage) ReadinessCheck() error
- func (a NetworkNeighborhoodStorage) RequestWatchProgress(ctx context.Context) error
- func (a NetworkNeighborhoodStorage) SetKeysFunc(_ storage.KeysFunc)
- func (a NetworkNeighborhoodStorage) Stats(_ context.Context) (storage.Stats, error)
- func (a NetworkNeighborhoodStorage) Versioner() storage.Versioner
- func (a NetworkNeighborhoodStorage) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)
- type PartialObjectMetadata
- type Processor
- type ResourceMaps
- type ResourcesCleanupHandler
- type ResourcesFetcher
- type StorageImpl
- func (s *StorageImpl) CalculateChecksum(in runtime.Object) (string, error)
- func (s *StorageImpl) CompactRevision() int64
- func (s *StorageImpl) Count(key string) (int64, error)
- func (s *StorageImpl) Create(ctx context.Context, key string, obj, metaOut runtime.Object, _ uint64) error
- func (s *StorageImpl) CreateWithConn(ctx context.Context, conn *sqlite.Conn, key string, ...) error
- func (s *StorageImpl) Delete(ctx context.Context, key string, metaOut runtime.Object, ...) error
- func (s *StorageImpl) DeleteWithConn(ctx context.Context, conn *sqlite.Conn, key string, metaOut runtime.Object, ...) error
- func (s *StorageImpl) Get(ctx context.Context, key string, opts storage.GetOptions, ...) error
- func (s *StorageImpl) GetByCluster(ctx context.Context, apiVersion, kind string, listObj runtime.Object) error
- func (s *StorageImpl) GetByNamespace(ctx context.Context, apiVersion, kind, namespace string, ...) error
- func (s *StorageImpl) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (s *StorageImpl) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (s *StorageImpl) GetListWithConn(ctx context.Context, conn *sqlite.Conn, key string, opts storage.ListOptions, ...) error
- func (s *StorageImpl) GetWithConn(ctx context.Context, conn *sqlite.Conn, key string, opts storage.GetOptions, ...) error
- func (s *StorageImpl) GuaranteedUpdate(ctx context.Context, key string, metaOut runtime.Object, ignoreNotFound bool, ...) error
- func (s *StorageImpl) GuaranteedUpdateWithConn(ctx context.Context, conn *sqlite.Conn, key string, metaOut runtime.Object, ...) error
- func (s *StorageImpl) ReadinessCheck() error
- func (s *StorageImpl) RequestWatchProgress(context.Context) error
- func (s *StorageImpl) SetKeysFunc(_ storage.KeysFunc)
- func (s *StorageImpl) Stats(_ context.Context) (storage.Stats, error)
- func (s *StorageImpl) Versioner() storage.Versioner
- func (s *StorageImpl) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)
- type StorageQuerier
- type Stringer
- type TimeSeriesOperations
- type TransactionManager
- type TypeCleanupHandlerFunc
- type TypeDeleteFunc
- type VulnerabilitySummaryStorage
- func (s *VulnerabilitySummaryStorage) CompactRevision() int64
- func (VulnerabilitySummaryStorage) Count(key string) (int64, error)
- func (VulnerabilitySummaryStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
- func (VulnerabilitySummaryStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, ...) error
- func (s *VulnerabilitySummaryStorage) Get(ctx context.Context, key string, _ storage.GetOptions, objPtr runtime.Object) error
- func (s *VulnerabilitySummaryStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
- func (s *VulnerabilitySummaryStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, ...) error
- func (VulnerabilitySummaryStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, ...) error
- func (VulnerabilitySummaryStorage) ReadinessCheck() error
- func (VulnerabilitySummaryStorage) RequestWatchProgress(context.Context) error
- func (s *VulnerabilitySummaryStorage) SetKeysFunc(_ storage.KeysFunc)
- func (s *VulnerabilitySummaryStorage) Stats(_ context.Context) (storage.Stats, error)
- func (VulnerabilitySummaryStorage) Versioner() storage.Versioner
- func (VulnerabilitySummaryStorage) Watch(_ context.Context, _ string, _ storage.ListOptions) (watch.Interface, error)
- type WatchDispatcher
Constants ¶
const ( OpenDynamicThreshold = 50 EndpointDynamicThreshold = 100 )
const ( DefaultStorageRoot = "/data" GobExt = ".g" MetadataExt = ".m" SchemaVersion = int64(1) StorageV1Beta1ApiVersion = "spdx.softwarecomposition.kubescape.io/v1beta1" )
const (
MinSizeToReport = 30 * 1024 * 1024 // 30MB
)
Variables ¶
var ( ObjectCompletedError = errors.New("object is completed") ObjectTooLargeError = errors.New("object is too large") )
var (
ErrMetadataNotFound = errors.New("metadata not found")
)
var ( Workloads = mapset.NewSet[string]([]string{ "cronjob", "daemonset", "deployment", "job", "replicaset", "statefulset", }...) // FIXME put in a configmap )
Functions ¶
func ComputeAggregatedData ¶ added in v0.0.233
func ComputeAggregatedData(storage ContainerProfileStorage, ctx context.Context, key string, parts map[string]string) (string, string, string)
ComputeAggregatedData computes aggregated profile data for an aggregated profile. It is a package-level helper so both the processor and storage implementation can reuse it without introducing a dependency between storage and processor types.
Parameters: - storage: any implementation of ContainerProfileStorage (declared in this package). - ctx: parent context (used to create short-lived timeouts for individual profile lookups). - key: the aggregated profile key (used only for logging). - parts: map of child profile keys -> checksum (may be modified in-place; missing checksums will be filled).
Returns: (status, completion, checksum)
func DeflateContainerProfileSpec ¶ added in v0.0.233
func DeflateContainerProfileSpec(container softwarecomposition.ContainerProfileSpec, sbomSet mapset.Set[string]) softwarecomposition.ContainerProfileSpec
func DeflateLabelSelectorRequirement ¶ added in v0.0.199
func DeflateLabelSelectorRequirement(in []metav1.LabelSelectorRequirement) []metav1.LabelSelectorRequirement
func DeflateRulePolicies ¶ added in v0.0.135
func DeflateRulePolicies(in map[string]softwarecomposition.RulePolicy) map[string]softwarecomposition.RulePolicy
func DeflateSortString ¶ added in v0.0.135
func DeflateStringer ¶ added in v0.0.118
func DeflateStringer[T Stringer](in []T) []T
func DeleteMetadata ¶ added in v0.0.137
DeleteMetadata deletes metadata for the given path and unmarshals the deleted metadata into the provided runtime.Object.
func DeleteTimeSeriesContainerEntries ¶ added in v0.0.199
DeleteTimeSeriesContainerEntries deletes all time series entries for a completed container.
func IsPayloadFile ¶ added in v0.0.137
IsPayloadFile returns true if a given file at `path` is an object payload file, else false
func KeysToPath ¶ added in v0.0.231
func ListTimeSeriesContainers ¶ added in v0.0.199
func ListTimeSeriesContainers(conn *sqlite.Conn, path string) (map[string][]softwarecomposition.TimeSeriesContainers, error)
ListTimeSeriesContainers retrieves time series containers for a given path.
func ListTimeSeriesExpired ¶ added in v0.0.228
ListTimeSeriesExpired cleans up time series containers which are older than d.
func ListTimeSeriesWithData ¶ added in v0.0.228
ListTimeSeriesWithData retrieves all time series keys that have data.
func NewApplicationProfileStorage ¶ added in v0.0.199
func NewApplicationProfileStorage(realStore StorageQuerier) storage.Interface
func NewConfigurationScanSummaryStorage ¶ added in v0.0.18
func NewConfigurationScanSummaryStorage(realStore StorageQuerier) storage.Interface
func NewGeneratedNetworkPolicyStorage ¶ added in v0.0.33
func NewGeneratedNetworkPolicyStorage(realStore StorageQuerier, nnStore storage.Interface) storage.Interface
func NewKubernetesClient ¶ added in v0.0.199
func NewKubernetesClient() (*kubernetes.Clientset, error)
func NewNetworkNeighborhoodStorage ¶ added in v0.0.199
func NewNetworkNeighborhoodStorage(realStore StorageQuerier) storage.Interface
func NewPool ¶ added in v0.0.137
func NewPool(path string, size int) *sqlitemigration.Pool
NewPool creates a new SQLite connection pool at the given path. It returns an error if the connection cannot be opened or the database cannot be initialized. It is your responsibility to call conn.Close() when you no longer need conn.
func NewTestPool ¶ added in v0.0.137
func NewTestPool(dir string) *sqlitemigration.Pool
NewTestPool creates a new temporary SQLite connection (for testing only).
func NewVulnerabilitySummaryStorage ¶ added in v0.0.20
func NewVulnerabilitySummaryStorage(realStore StorageQuerier) storage.Interface
func PathToKeys ¶ added in v0.0.231
func ReadMetadata ¶ added in v0.0.137
ReadMetadata reads metadata for the given path and returns it as a byte slice.
func ReplaceTimeSeriesContainerEntries ¶ added in v0.0.199
func ReplaceTimeSeriesContainerEntries(conn *sqlite.Conn, path, seriesID string, deleteTimeSeries []string, newTimeSeries []softwarecomposition.TimeSeriesContainers) error
ReplaceTimeSeriesContainerEntries replaces time series entries for a given path and seriesID.
func SplitProfileName ¶ added in v0.0.231
Types ¶
type ApplicationProfileProcessor ¶ added in v0.0.66
type ApplicationProfileProcessor struct {
// contains filtered or unexported fields
}
func NewApplicationProfileProcessor ¶ added in v0.0.121
func NewApplicationProfileProcessor(cfg config.Config) *ApplicationProfileProcessor
func (*ApplicationProfileProcessor) AfterCreate ¶ added in v0.0.199
func (*ApplicationProfileProcessor) SetStorage ¶ added in v0.0.143
func (a *ApplicationProfileProcessor) SetStorage(containerProfileStorage ContainerProfileStorage)
type ApplicationProfileStorage ¶ added in v0.0.199
type ApplicationProfileStorage struct {
// contains filtered or unexported fields
}
func (ApplicationProfileStorage) CompactRevision ¶ added in v0.0.221
func (a ApplicationProfileStorage) CompactRevision() int64
func (ApplicationProfileStorage) Delete ¶ added in v0.0.199
func (a ApplicationProfileStorage) Delete(ctx context.Context, key string, out runtime.Object, preconditions *storage.Preconditions, validateDeletion storage.ValidateObjectFunc, cachedExistingObject runtime.Object, opts storage.DeleteOptions) error
func (ApplicationProfileStorage) Get ¶ added in v0.0.199
func (a ApplicationProfileStorage) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error
func (ApplicationProfileStorage) GetCurrentResourceVersion ¶ added in v0.0.199
func (a ApplicationProfileStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (ApplicationProfileStorage) GetList ¶ added in v0.0.199
func (a ApplicationProfileStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
func (ApplicationProfileStorage) GuaranteedUpdate ¶ added in v0.0.199
func (a ApplicationProfileStorage) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error
func (ApplicationProfileStorage) ReadinessCheck ¶ added in v0.0.199
func (a ApplicationProfileStorage) ReadinessCheck() error
func (ApplicationProfileStorage) RequestWatchProgress ¶ added in v0.0.199
func (a ApplicationProfileStorage) RequestWatchProgress(ctx context.Context) error
func (ApplicationProfileStorage) SetKeysFunc ¶ added in v0.0.221
func (a ApplicationProfileStorage) SetKeysFunc(_ storage.KeysFunc)
func (ApplicationProfileStorage) Versioner ¶ added in v0.0.199
func (a ApplicationProfileStorage) Versioner() storage.Versioner
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) CompactRevision ¶ added in v0.0.221
func (s *ConfigurationScanSummaryStorage) CompactRevision() int64
func (ConfigurationScanSummaryStorage) Count ¶ added in v0.0.18
Count is not supported for immutable objects. Objects are generated on the fly and not stored.
func (ConfigurationScanSummaryStorage) Create ¶ added in v0.0.18
func (ConfigurationScanSummaryStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
Create is not supported for immutable objects. Objects are generated on the fly and not stored.
func (ConfigurationScanSummaryStorage) Delete ¶ added in v0.0.18
func (ConfigurationScanSummaryStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, _ storage.ValidateObjectFunc, _ runtime.Object, _ storage.DeleteOptions) error
Delete is not supported for immutable objects. Objects are generated on the fly and not stored.
func (*ConfigurationScanSummaryStorage) Get ¶ added in v0.0.18
func (s *ConfigurationScanSummaryStorage) Get(ctx context.Context, key string, _ storage.GetOptions, objPtr runtime.Object) error
Get generates and returns a single ConfigurationScanSummary object for a namespace
func (*ConfigurationScanSummaryStorage) GetCurrentResourceVersion ¶ added in v0.0.199
func (s *ConfigurationScanSummaryStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (*ConfigurationScanSummaryStorage) GetList ¶ added in v0.0.18
func (s *ConfigurationScanSummaryStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
GetList generates and returns a list of ConfigurationScanSummary objects for the cluster
func (ConfigurationScanSummaryStorage) GuaranteedUpdate ¶ added in v0.0.18
func (ConfigurationScanSummaryStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, _ *storage.Preconditions, _ storage.UpdateFunc, _ runtime.Object) error
GuaranteedUpdate is not supported for immutable objects. Objects are generated on the fly and not stored.
func (ConfigurationScanSummaryStorage) ReadinessCheck ¶ added in v0.0.174
func (ConfigurationScanSummaryStorage) ReadinessCheck() error
func (ConfigurationScanSummaryStorage) RequestWatchProgress ¶ added in v0.0.42
RequestWatchProgress fulfills the storage.Interface
It’s function is only relevant to etcd.
func (*ConfigurationScanSummaryStorage) SetKeysFunc ¶ added in v0.0.221
func (s *ConfigurationScanSummaryStorage) SetKeysFunc(_ storage.KeysFunc)
type ConsolidatedSlugData ¶ added in v0.0.236
ConsolidatedSlugData contains the slug (name) and namespace of a consolidated profile
type ContainerProfileProcessor ¶ added in v0.0.199
type ContainerProfileProcessor struct {
CleanupHandler *ResourcesCleanupHandler
CleanupInterval time.Duration
DefaultNamespace string
DeleteThreshold time.Duration
Interval time.Duration
LastCleanup time.Time
MaxContainerProfileSize int
ContainerProfileStorage ContainerProfileStorage
ConsolidatedSlugChannel chan ConsolidatedSlugData
}
func NewContainerProfileProcessor ¶ added in v0.0.199
func NewContainerProfileProcessor(cfg config.Config, cleanupHandler *ResourcesCleanupHandler) *ContainerProfileProcessor
func (*ContainerProfileProcessor) AfterCreate ¶ added in v0.0.199
AfterCreate is called after a TS ContainerProfile is created to store metadata.
func (*ContainerProfileProcessor) ConsolidateTimeSeries ¶ added in v0.0.231
func (a *ContainerProfileProcessor) ConsolidateTimeSeries(ctx context.Context) error
ConsolidateTimeSeries processes all time series data, handling expired and active series separately.
The function runs in two phases: 1. Process expired time series (past deleteThreshold) - marked as Completed/Partial 2. Process active time series with data - follow normal completion flow
Expired time series are always marked as Completed/Partial unless they were already Completed/Full, ensuring incomplete profiles don't remain in a Learning state indefinitely.
func (*ContainerProfileProcessor) SetStorage ¶ added in v0.0.199
func (a *ContainerProfileProcessor) SetStorage(containerProfileStorage ContainerProfileStorage)
type ContainerProfileStorage ¶ added in v0.0.231
type ContainerProfileStorage interface {
TransactionManager
TimeSeriesOperations
// DeleteContainerProfile deletes a container profile by key.
DeleteContainerProfile(ctx context.Context, key string) error
// GetContainerProfile retrieves a complete container profile by key.
GetContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
// GetContainerProfileMetadata retrieves only the metadata of a container profile.
// This is more efficient when only metadata is needed.
GetContainerProfileMetadata(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
// GetSbom retrieves an SBOM by key.
// Returns storage.ErrCodeKeyNotFound if not found or not implemented.
GetSbom(ctx context.Context, key string) (softwarecomposition.SBOMSyft, error)
// GetTsContainerProfile retrieves a time-series container profile.
// This bypasses locking mechanisms used by GetContainerProfile.
GetTsContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
// SaveContainerProfile creates or updates a container profile.
SaveContainerProfile(ctx context.Context, key string, profile *softwarecomposition.ContainerProfile) error
// UpdateApplicationProfile updates the application profile associated with a container profile.
UpdateApplicationProfile(ctx context.Context, key, prefix, root, namespace, slug, wlid string, instanceID interface{ GetStringNoContainer() string }, profile *softwarecomposition.ContainerProfile, creationTimestamp metav1.Time) error
// UpdateNetworkNeighborhood updates the network neighborhood associated with a container profile.
UpdateNetworkNeighborhood(ctx context.Context, key, prefix, root, namespace, slug, wlid string, instanceID interface{ GetStringNoContainer() string }, profile *softwarecomposition.ContainerProfile, creationTimestamp metav1.Time) error
}
ContainerProfileStorage defines the storage operations for container profiles. This interface abstracts the underlying database implementation, allowing different backends (SQLite, PostgreSQL, etc.) to be used interchangeably.
Connection Management: - The database connection is stored in the context using context.WithValue with key connKey - Call BeginTransaction to acquire a connection and get a context with the connection embedded - All data operations extract the connection from the context - Use the cleanup function returned by BeginTransaction to return the connection to the pool
Example usage:
storage := NewContainerProfileStorageImpl(storageImpl, pool)
ctx, cleanup, err := storage.WithConnection(ctx)
if err != nil { ... }
defer cleanup()
err = storage.SaveContainerProfile(ctx, key, profile)
if err != nil { ... }
// For transactions (savepoints):
endFn, err := storage.BeginTransaction(ctx)
if err != nil { ... }
err = doSomeWork(ctx)
endFn(&err) // commits if err is nil, rolls back otherwise
type ContainerProfileStorageImpl ¶ added in v0.0.231
type ContainerProfileStorageImpl struct {
// contains filtered or unexported fields
}
ContainerProfileStorageImpl implements ContainerProfileStorage using SQLite as the backend.
func NewContainerProfileStorageImpl ¶ added in v0.0.231
func NewContainerProfileStorageImpl(storageImpl *StorageImpl, pool *sqlitemigration.Pool) *ContainerProfileStorageImpl
NewContainerProfileStorageImpl creates a new SQLite-backed ContainerProfileStorage.
func (*ContainerProfileStorageImpl) BeginTransaction ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) BeginTransaction(ctx context.Context) (func(*error), error)
BeginTransaction starts a SQLite transaction (savepoint) and returns a function to commit or rollback based on the error state.
func (*ContainerProfileStorageImpl) DeleteContainerProfile ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) DeleteContainerProfile(ctx context.Context, key string) error
func (*ContainerProfileStorageImpl) DeleteTimeSeriesContainerEntries ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) DeleteTimeSeriesContainerEntries(ctx context.Context, key string) error
func (*ContainerProfileStorageImpl) GetContainerProfile ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) GetContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
func (*ContainerProfileStorageImpl) GetContainerProfileMetadata ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) GetContainerProfileMetadata(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
func (*ContainerProfileStorageImpl) GetSbom ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) GetSbom(ctx context.Context, key string) (softwarecomposition.SBOMSyft, error)
func (*ContainerProfileStorageImpl) GetStorageImpl ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) GetStorageImpl() *StorageImpl
func (*ContainerProfileStorageImpl) GetTsContainerProfile ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) GetTsContainerProfile(ctx context.Context, key string) (softwarecomposition.ContainerProfile, error)
func (*ContainerProfileStorageImpl) ListTimeSeriesContainers ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) ListTimeSeriesContainers(ctx context.Context, key string) (map[string][]softwarecomposition.TimeSeriesContainers, error)
func (*ContainerProfileStorageImpl) ListTimeSeriesExpired ¶ added in v0.0.231
func (*ContainerProfileStorageImpl) ListTimeSeriesWithData ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) ListTimeSeriesWithData(ctx context.Context) ([]string, error)
func (*ContainerProfileStorageImpl) ReplaceTimeSeriesContainerEntries ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) ReplaceTimeSeriesContainerEntries(ctx context.Context, key, seriesID string, deleteTimeSeries []string, newTimeSeries []softwarecomposition.TimeSeriesContainers) error
func (*ContainerProfileStorageImpl) SaveContainerProfile ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) SaveContainerProfile(ctx context.Context, key string, profile *softwarecomposition.ContainerProfile) error
func (*ContainerProfileStorageImpl) UpdateApplicationProfile ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) UpdateApplicationProfile(ctx context.Context, key, prefix, root, namespace, slug, wlid string, instanceID interface{ GetStringNoContainer() string }, profile *softwarecomposition.ContainerProfile, creationTimestamp metav1.Time) error
func (*ContainerProfileStorageImpl) UpdateNetworkNeighborhood ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) UpdateNetworkNeighborhood(ctx context.Context, key, prefix, root, namespace, slug, wlid string, instanceID interface{ GetStringNoContainer() string }, profile *softwarecomposition.ContainerProfile, creationTimestamp metav1.Time) error
func (*ContainerProfileStorageImpl) WithConnection ¶ added in v0.0.231
func (c *ContainerProfileStorageImpl) WithConnection(ctx context.Context) (context.Context, func(), error)
WithConnection acquires a connection from the pool and returns a new context with the connection embedded, plus a cleanup function to return the connection to the pool.
func (*ContainerProfileStorageImpl) WriteTimeSeriesEntry ¶ added in v0.0.231
type DefaultProcessor ¶ added in v0.0.66
type DefaultProcessor struct {
}
func (DefaultProcessor) AfterCreate ¶ added in v0.0.199
func (DefaultProcessor) SetStorage ¶ added in v0.0.143
func (d DefaultProcessor) SetStorage(_ ContainerProfileStorage)
type DirectIOReader ¶ added in v0.0.121
type DirectIOReader struct {
// contains filtered or unexported fields
}
DirectIOReader is a reader that reads data from the underlying reader using direct I/O.
func NewDirectIOReader ¶ added in v0.0.121
func NewDirectIOReader(rd io.Reader) *DirectIOReader
func (*DirectIOReader) Read ¶ added in v0.0.121
func (d *DirectIOReader) Read(p []byte) (int, error)
func (*DirectIOReader) ReadByte ¶ added in v0.0.121
func (d *DirectIOReader) ReadByte() (byte, error)
type DirectIOWriter ¶ added in v0.0.127
type DirectIOWriter struct {
// contains filtered or unexported fields
}
DirectIOWriter is a writer that writes data to the underlying writer using direct I/O.
func NewDirectIOWriter ¶ added in v0.0.127
func NewDirectIOWriter(wr afero.File) *DirectIOWriter
func (*DirectIOWriter) Close ¶ added in v0.0.127
func (d *DirectIOWriter) Close() error
type GeneratedNetworkPolicyStorage ¶ added in v0.0.33
type GeneratedNetworkPolicyStorage struct {
// contains filtered or unexported fields
}
GeneratedNetworkPolicyStorage offers a storage solution for GeneratedNetworkPolicy objects, implementing custom business logic for these objects and using the underlying default storage implementation.
func (*GeneratedNetworkPolicyStorage) CompactRevision ¶ added in v0.0.221
func (s *GeneratedNetworkPolicyStorage) CompactRevision() int64
func (GeneratedNetworkPolicyStorage) Count ¶ added in v0.0.33
Count is not supported for immutable objects. Objects are generated on the fly and not stored.
func (GeneratedNetworkPolicyStorage) Create ¶ added in v0.0.33
func (GeneratedNetworkPolicyStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
Create is not supported for immutable objects. Objects are generated on the fly and not stored.
func (GeneratedNetworkPolicyStorage) Delete ¶ added in v0.0.33
func (GeneratedNetworkPolicyStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, _ storage.ValidateObjectFunc, _ runtime.Object, _ storage.DeleteOptions) error
Delete is not supported for immutable objects. Objects are generated on the fly and not stored.
func (*GeneratedNetworkPolicyStorage) Get ¶ added in v0.0.33
func (s *GeneratedNetworkPolicyStorage) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error
Get generates and returns a single GeneratedNetworkPolicy object
func (*GeneratedNetworkPolicyStorage) GetCurrentResourceVersion ¶ added in v0.0.199
func (s *GeneratedNetworkPolicyStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (*GeneratedNetworkPolicyStorage) GetList ¶ added in v0.0.33
func (s *GeneratedNetworkPolicyStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
GetList generates and returns a list of GeneratedNetworkPolicy objects for the given namespace
func (GeneratedNetworkPolicyStorage) GuaranteedUpdate ¶ added in v0.0.33
func (GeneratedNetworkPolicyStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, _ *storage.Preconditions, _ storage.UpdateFunc, _ runtime.Object) error
GuaranteedUpdate is not supported for immutable objects. Objects are generated on the fly and not stored.
func (GeneratedNetworkPolicyStorage) ReadinessCheck ¶ added in v0.0.174
func (GeneratedNetworkPolicyStorage) ReadinessCheck() error
func (GeneratedNetworkPolicyStorage) RequestWatchProgress ¶ added in v0.0.42
RequestWatchProgress fulfills the storage.Interface
It’s function is only relevant to etcd.
func (*GeneratedNetworkPolicyStorage) SetKeysFunc ¶ added in v0.0.221
func (s *GeneratedNetworkPolicyStorage) SetKeysFunc(_ storage.KeysFunc)
type KubernetesAPI ¶ added in v0.0.199
type KubernetesAPI struct {
// contains filtered or unexported fields
}
func NewKubernetesAPI ¶ added in v0.0.199
func NewKubernetesAPI(cfg config.Config, client *kubernetes.Clientset) *KubernetesAPI
func (*KubernetesAPI) FetchResources ¶ added in v0.0.199
func (h *KubernetesAPI) FetchResources(ns string) (ResourceMaps, error)
FetchResources builds a map of running resources in the cluster needed for cleanup
func (*KubernetesAPI) ListNamespaces ¶ added in v0.0.214
func (h *KubernetesAPI) ListNamespaces(conn *sqlite.Conn) ([]string, error)
type NetworkNeighborhoodProcessor ¶ added in v0.0.81
type NetworkNeighborhoodProcessor struct {
// contains filtered or unexported fields
}
func NewNetworkNeighborhoodProcessor ¶ added in v0.0.121
func NewNetworkNeighborhoodProcessor(cfg config.Config) *NetworkNeighborhoodProcessor
func (NetworkNeighborhoodProcessor) AfterCreate ¶ added in v0.0.199
func (NetworkNeighborhoodProcessor) SetStorage ¶ added in v0.0.143
func (a NetworkNeighborhoodProcessor) SetStorage(_ ContainerProfileStorage)
type NetworkNeighborhoodStorage ¶ added in v0.0.199
type NetworkNeighborhoodStorage struct {
// contains filtered or unexported fields
}
func (NetworkNeighborhoodStorage) CompactRevision ¶ added in v0.0.221
func (a NetworkNeighborhoodStorage) CompactRevision() int64
func (NetworkNeighborhoodStorage) Delete ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) Delete(ctx context.Context, key string, out runtime.Object, preconditions *storage.Preconditions, validateDeletion storage.ValidateObjectFunc, cachedExistingObject runtime.Object, opts storage.DeleteOptions) error
func (NetworkNeighborhoodStorage) Get ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) Get(ctx context.Context, key string, opts storage.GetOptions, objPtr runtime.Object) error
func (NetworkNeighborhoodStorage) GetCurrentResourceVersion ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (NetworkNeighborhoodStorage) GetList ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
func (NetworkNeighborhoodStorage) GuaranteedUpdate ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error
func (NetworkNeighborhoodStorage) ReadinessCheck ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) ReadinessCheck() error
func (NetworkNeighborhoodStorage) RequestWatchProgress ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) RequestWatchProgress(ctx context.Context) error
func (NetworkNeighborhoodStorage) SetKeysFunc ¶ added in v0.0.221
func (a NetworkNeighborhoodStorage) SetKeysFunc(_ storage.KeysFunc)
func (NetworkNeighborhoodStorage) Versioner ¶ added in v0.0.199
func (a NetworkNeighborhoodStorage) Versioner() storage.Versioner
type PartialObjectMetadata ¶ added in v0.0.199
type PartialObjectMetadata struct {
metav1.TypeMeta
metav1.ObjectMeta
}
PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients to get access to a particular ObjectMeta schema without knowing the details of the version.
func (PartialObjectMetadata) DeepCopyObject ¶ added in v0.0.199
func (p PartialObjectMetadata) DeepCopyObject() runtime.Object
type ResourceMaps ¶ added in v0.0.199
type ResourceMaps struct {
// CLUSTER level
RunningContainerImageIds mapset.Set[string]
RunningInstanceIds mapset.Set[string]
// NAMESPACE level
RunningTemplateHash mapset.Set[string]
RunningWlidsToContainerNames *maps.SafeMap[string, mapset.Set[string]]
}
ResourceMaps is a map of running resources in the cluster, based on these maps we can decide which files to delete
type ResourcesCleanupHandler ¶ added in v0.0.199
type ResourcesCleanupHandler struct {
// contains filtered or unexported fields
}
func NewResourcesCleanupHandler ¶ added in v0.0.199
func NewResourcesCleanupHandler(appFs afero.Fs, root string, pool *sqlitemigration.Pool, watchDispatcher *WatchDispatcher, interval time.Duration, defaultNamespace string, fetcher ResourcesFetcher, relevancyEnabled bool) *ResourcesCleanupHandler
func (*ResourcesCleanupHandler) CleanupTask ¶ added in v0.0.199
func (h *ResourcesCleanupHandler) CleanupTask(ctx context.Context, resourceToKindHandler map[string][]TypeCleanupHandlerFunc) error
func (*ResourcesCleanupHandler) RunCleanupTask ¶ added in v0.0.199
func (h *ResourcesCleanupHandler) RunCleanupTask(ctx context.Context)
type ResourcesFetcher ¶ added in v0.0.199
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) CalculateChecksum ¶ added in v0.0.135
func (s *StorageImpl) CalculateChecksum(in runtime.Object) (string, error)
func (*StorageImpl) CompactRevision ¶ added in v0.0.221
func (s *StorageImpl) CompactRevision() int64
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, metaOut runtime.Object, _ uint64) error
Create adds a new object at a key unless 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) CreateWithConn ¶ added in v0.0.199
func (*StorageImpl) Delete ¶
func (s *StorageImpl) Delete(ctx context.Context, key string, metaOut runtime.Object, _ *storage.Preconditions, _ storage.ValidateObjectFunc, _ runtime.Object, _ storage.DeleteOptions) error
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) DeleteWithConn ¶ added in v0.0.199
func (s *StorageImpl) DeleteWithConn(ctx context.Context, conn *sqlite.Conn, key string, metaOut runtime.Object, _ *storage.Preconditions, _ storage.ValidateObjectFunc, _ runtime.Object, _ storage.DeleteOptions) error
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) GetCurrentResourceVersion ¶ added in v0.0.199
func (s *StorageImpl) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (*StorageImpl) GetList ¶
func (s *StorageImpl) GetList(ctx context.Context, key string, opts 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'. GetList only returns metadata for the objects, not the objects themselves.
func (*StorageImpl) GetListWithConn ¶ added in v0.0.199
func (*StorageImpl) GetWithConn ¶ added in v0.0.199
func (*StorageImpl) GuaranteedUpdate ¶
func (s *StorageImpl) GuaranteedUpdate( ctx context.Context, key string, metaOut 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 its 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) GuaranteedUpdateWithConn ¶ added in v0.0.199
func (*StorageImpl) ReadinessCheck ¶ added in v0.0.174
func (s *StorageImpl) ReadinessCheck() error
func (*StorageImpl) RequestWatchProgress ¶ added in v0.0.42
func (s *StorageImpl) RequestWatchProgress(context.Context) error
RequestWatchProgress fulfills the storage.Interface
Its function is only relevant to etcd.
func (*StorageImpl) SetKeysFunc ¶ added in v0.0.221
func (s *StorageImpl) SetKeysFunc(_ storage.KeysFunc)
func (*StorageImpl) Versioner ¶
func (s *StorageImpl) Versioner() storage.Versioner
Versioner Returns Versioner associated with this interface.
func (*StorageImpl) Watch ¶
func (s *StorageImpl) Watch(ctx context.Context, key string, opts storage.ListOptions) (watch.Interface, error)
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
CalculateChecksum(in runtime.Object) (string, error)
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, pool *sqlitemigration.Pool, watchDispatcher *WatchDispatcher, scheme *runtime.Scheme) StorageQuerier
func NewStorageImplWithCollector ¶ added in v0.0.66
func NewStorageImplWithCollector(appFs afero.Fs, root string, conn *sqlitemigration.Pool, watchDispatcher *WatchDispatcher, scheme *runtime.Scheme, processor Processor) StorageQuerier
type TimeSeriesOperations ¶ added in v0.0.231
type TimeSeriesOperations interface {
// ListTimeSeriesExpired returns keys for time series entries older than the given duration.
// These represent profiles that have exceeded their tracking threshold.
ListTimeSeriesExpired(ctx context.Context, threshold time.Duration) ([]string, error)
// ListTimeSeriesWithData returns keys for all time series entries that have pending data.
ListTimeSeriesWithData(ctx context.Context) ([]string, error)
// ListTimeSeriesContainers retrieves time series container information for a given key.
// Returns a map of seriesID to slice of TimeSeriesContainers.
ListTimeSeriesContainers(ctx context.Context, key string) (map[string][]softwarecomposition.TimeSeriesContainers, error)
// DeleteTimeSeriesContainerEntries removes all time series entries for a given key.
DeleteTimeSeriesContainerEntries(ctx context.Context, key string) error
// ReplaceTimeSeriesContainerEntries replaces time series entries for a given key and seriesID.
// It deletes entries in deleteTimeSeries and inserts newTimeSeries.
ReplaceTimeSeriesContainerEntries(ctx context.Context, key, seriesID string, deleteTimeSeries []string, newTimeSeries []softwarecomposition.TimeSeriesContainers) error
}
TimeSeriesOperations defines operations for managing time series data. These operations are used for tracking container profile versions over time.
type TransactionManager ¶ added in v0.0.231
type TransactionManager interface {
// WithConnection acquires a connection from the pool and returns a new context
// with the connection embedded, plus a cleanup function to return the connection to the pool.
// The cleanup function is safe to call multiple times.
// Usage:
// ctx, cleanup, err := storage.WithConnection(ctx)
// if err != nil { return err }
// defer cleanup()
// // ... do work with ctx ...
WithConnection(ctx context.Context) (context.Context, func(), error)
// BeginTransaction starts a SQLite transaction (savepoint) and returns a function
// to commit or rollback based on the error state.
// The connection must already be in the context (from WithConnection).
// Returns a function that must be called with the error pointer to commit or rollback the savepoint.
// Usage:
// endFn, err := storage.BeginTransaction(ctx)
// if err != nil { return err }
// err = doSomeWork(ctx)
// endFn(&err) // commits savepoint if err is nil, rolls back otherwise
BeginTransaction(ctx context.Context) (endFunc func(*error), err error)
}
TransactionManager handles database connection and transaction lifecycle. Implementations should manage connection pooling and transaction semantics appropriate for their backend.
The connection is stored in the context using context.WithValue with key connKey. All storage methods extract the connection from the context.
type TypeCleanupHandlerFunc ¶ added in v0.0.199
type TypeCleanupHandlerFunc func(kind, path string, metadata *metav1.ObjectMeta, resourceMaps ResourceMaps) bool
type TypeDeleteFunc ¶ added in v0.0.199
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) CompactRevision ¶ added in v0.0.221
func (s *VulnerabilitySummaryStorage) CompactRevision() int64
func (VulnerabilitySummaryStorage) Count ¶ added in v0.0.20
Count is not supported for immutable objects. Objects are generated on the fly and not stored.
func (VulnerabilitySummaryStorage) Create ¶ added in v0.0.20
func (VulnerabilitySummaryStorage) Create(_ context.Context, key string, _, _ runtime.Object, _ uint64) error
Create is not supported for immutable objects. Objects are generated on the fly and not stored.
func (VulnerabilitySummaryStorage) Delete ¶ added in v0.0.20
func (VulnerabilitySummaryStorage) Delete(_ context.Context, key string, _ runtime.Object, _ *storage.Preconditions, _ storage.ValidateObjectFunc, _ runtime.Object, _ storage.DeleteOptions) error
Delete is not supported for immutable objects. Objects are generated on the fly and not stored.
func (*VulnerabilitySummaryStorage) Get ¶ added in v0.0.20
func (s *VulnerabilitySummaryStorage) Get(ctx context.Context, key string, _ storage.GetOptions, objPtr runtime.Object) error
func (*VulnerabilitySummaryStorage) GetCurrentResourceVersion ¶ added in v0.0.199
func (s *VulnerabilitySummaryStorage) GetCurrentResourceVersion(_ context.Context) (uint64, error)
func (*VulnerabilitySummaryStorage) GetList ¶ added in v0.0.20
func (s *VulnerabilitySummaryStorage) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error
func (VulnerabilitySummaryStorage) GuaranteedUpdate ¶ added in v0.0.20
func (VulnerabilitySummaryStorage) GuaranteedUpdate(_ context.Context, key string, _ runtime.Object, _ bool, _ *storage.Preconditions, _ storage.UpdateFunc, _ runtime.Object) error
GuaranteedUpdate is not supported for immutable objects. Objects are generated on the fly and not stored.
func (VulnerabilitySummaryStorage) ReadinessCheck ¶ added in v0.0.174
func (VulnerabilitySummaryStorage) ReadinessCheck() error
func (VulnerabilitySummaryStorage) RequestWatchProgress ¶ added in v0.0.42
RequestWatchProgress fulfills the storage.Interface
It’s function is only relevant to etcd.
func (*VulnerabilitySummaryStorage) SetKeysFunc ¶ added in v0.0.221
func (s *VulnerabilitySummaryStorage) SetKeysFunc(_ storage.KeysFunc)
type WatchDispatcher ¶ added in v0.0.160
type WatchDispatcher struct {
// contains filtered or unexported fields
}
WatchDispatcher dispatches events to registered watches
TODO(ttimonen): There's currently no way to gracefully take down WatchDispatcher without leaking a goroutine.
func NewWatchDispatcher ¶ added in v0.0.160
func NewWatchDispatcher() *WatchDispatcher
func (*WatchDispatcher) Added ¶ added in v0.0.160
func (wd *WatchDispatcher) Added(key string, metaOut, obj runtime.Object)
Added dispatches an "Added" event to appropriate watchers
func (*WatchDispatcher) Deleted ¶ added in v0.0.160
func (wd *WatchDispatcher) Deleted(key string, metaOut runtime.Object)
Deleted dispatches a "Deleted" event to appropriate watchers
func (*WatchDispatcher) Modified ¶ added in v0.0.160
func (wd *WatchDispatcher) Modified(key string, metaOut, obj runtime.Object)
Modified dispatches a "Modified" event to appropriate watchers
func (*WatchDispatcher) Register ¶ added in v0.0.160
func (wd *WatchDispatcher) Register(key string, w *watcher)
Register registers a watcher for a given key
Source Files
¶
- applicationprofile_processor.go
- applicationprofile_storage.go
- cleanup.go
- configurationscansummarystorage.go
- containerprofile_aggregator.go
- containerprofile_processor.go
- containerprofile_storage.go
- containerprofile_storage_interface.go
- directio.go
- discovery.go
- generatednetworkpolicy.go
- networkneighborhood_processor.go
- networkneighborhood_storage.go
- open_flag_linux.go
- processor.go
- sqlite.go
- storage.go
- utils.go
- vulnerabilitysummarystorage.go
- watch.go