Documentation
¶
Index ¶
- Constants
- Variables
- func AddPaginationToQuery(query *gorm.DB, limit int, cont *Continue, listParams ListParams) *gorm.DB
- func BuildContinueString(names []string, count int64) *string
- func CallEventCallback(resourceKind domain.ResourceKind, log logrus.FieldLogger) ...
- func CheckHealth(ctx context.Context, db *gorm.DB) error
- func CountRemainingItems(query *gorm.DB, nextValues []string, listParams ListParams) int64
- func ErrorFromGormError(err error) error
- func GetNonNilFieldsFromResource(resource model.Resource) []string
- func InitDB(cfg *config.Config, log *logrus.Logger) (*gorm.DB, error)
- func InitMigrationDB(cfg *config.Config, log *logrus.Logger) (*gorm.DB, error)
- func ListQuery(dest any, opts ...ListQueryOption) *listQuery
- func NewTraceContextEnforcer() gorm.Plugin
- func SafeEventCallback(log logrus.FieldLogger, callback func())
- func WithBypassSpanCheck(ctx context.Context) context.Context
- type Continue
- type CountByOrgResult
- type CreateOrUpdateMode
- type DBHealthChecker
- type EventCallback
- type EventCallbackCaller
- type GenericStore
- func (s *GenericStore[P, M, A, AL]) Create(ctx context.Context, orgId uuid.UUID, resource *A) (*A, error)
- func (s *GenericStore[P, M, A, AL]) CreateOrUpdate(ctx context.Context, orgId uuid.UUID, resource *A, fieldsToUnset []string, ...) (*A, *A, bool, error)
- func (s *GenericStore[P, M, A, AL]) Delete(ctx context.Context, resource M, associatedResources ...Resource) (bool, error)
- func (s *GenericStore[P, M, A, AL]) Get(ctx context.Context, orgId uuid.UUID, name string) (*A, error)
- func (s *GenericStore[P, M, A, AL]) List(ctx context.Context, orgId uuid.UUID, listParams ListParams) (*AL, error)
- func (s *GenericStore[P, M, A, AL]) Update(ctx context.Context, orgId uuid.UUID, resource *A, fieldsToUnset []string, ...) (*A, *A, error)
- func (s *GenericStore[P, M, A, AL]) UpdateStatus(ctx context.Context, orgId uuid.UUID, resource *A) (*A, error)
- type IntegrationTestCallback
- type ListParams
- type ListQueryOption
- type RemoveOwnerCallback
- type Resource
- type SortColumn
- type SortOrder
- type StatusCount
- type StatusCountList
Constants ¶
const ( ConstraintAuthProviderOIDCUnique = "idx_authproviders_oidc_unique" ConstraintAuthProviderOAuth2Unique = "idx_authproviders_oauth2_unique" )
AuthProvider database constraint names
const ( SortByName SortColumn = "name" SortByCreatedAt SortColumn = "created_at" // Sort columns for vulnerability queries. SortByOwner SortColumn = "owner" SortByDeviceAffected SortColumn = "device_affected" SortBySeverity SortColumn = "severity" SortByCvssScore SortColumn = "cvss_score" SortByPublishedAt SortColumn = "published_at" SortByCveId SortColumn = "cve_id" SortAsc SortOrder = "asc" SortDesc SortOrder = "desc" )
Variables ¶
var ( NullOrgId = org.DefaultID CurrentContinueVersion = 1 )
Functions ¶
func AddPaginationToQuery ¶
func BuildContinueString ¶ added in v0.8.1
func CallEventCallback ¶ added in v0.9.0
func CallEventCallback(resourceKind domain.ResourceKind, log logrus.FieldLogger) func(ctx context.Context, callbackEvent EventCallback, orgId uuid.UUID, name string, oldResource, newResource interface{}, created bool, err error)
func CheckHealth ¶ added in v1.3.0
CheckHealth verifies database connectivity and basic read capability. It depends only on *gorm.DB, not on any per-resource store, so composition roots that no longer construct the monolithic Store can still perform a DB health check.
func CountRemainingItems ¶
func CountRemainingItems(query *gorm.DB, nextValues []string, listParams ListParams) int64
func ErrorFromGormError ¶ added in v0.3.0
ErrorFromGormError translates well-known gorm errors into domain-specific errors. Delegated to storeutil so that packages outside internal/store can reuse the logic.
func InitMigrationDB ¶ added in v0.9.0
func ListQuery ¶ added in v0.3.0
func ListQuery(dest any, opts ...ListQueryOption) *listQuery
func NewTraceContextEnforcer ¶ added in v0.8.1
func SafeEventCallback ¶ added in v0.9.0
func SafeEventCallback(log logrus.FieldLogger, callback func())
Call callback if provided (but don't fail the operation if callback fails) with panic recovery to prevent callback failures from affecting the main operation
Types ¶
type Continue ¶
func ParseContinueString ¶
type CountByOrgResult ¶ added in v0.10.0
CountByOrgResult holds the result of the group by query for organization.
type CreateOrUpdateMode ¶ added in v0.2.0
type CreateOrUpdateMode string
const ( ModeCreateOnly CreateOrUpdateMode = "create-only" ModeUpdateOnly CreateOrUpdateMode = "update-only" ModeCreateOrUpdate CreateOrUpdateMode = "create-or-update" )
type DBHealthChecker ¶ added in v1.3.0
DBHealthChecker adapts CheckHealth to the api_server.HealthChecker interface without requiring a full Store.
func (*DBHealthChecker) CheckHealth ¶ added in v1.3.0
func (h *DBHealthChecker) CheckHealth(ctx context.Context) error
type EventCallback ¶ added in v0.9.0
type EventCallbackCaller ¶ added in v0.9.0
type GenericStore ¶ added in v0.4.0
type GenericStore[P extInt[M], M any, A any, AL any] struct { // Callback for integration tests to inject logic IntegrationTestCreateOrUpdateCallback IntegrationTestCallback // contains filtered or unexported fields }
GenericStore provides generic CRUD operations for resources P is a pointer to a model, for example: *model.Device M is the model, for example: model.Device A is the API resource, for example: domain.Device AL is the API list, for example: domain.DeviceList
func NewGenericStore ¶ added in v0.4.0
func NewGenericStore[P extInt[M], M any, A any, AL any]( db *gorm.DB, log logrus.FieldLogger, apiToModelPtr func(*A) (P, error), modelPtrToAPI func(P, ...model.APIResourceOption) (*A, error), listModelToAPI func([]M, *string, *int64) (AL, error), ) *GenericStore[P, M, A, AL]
func (*GenericStore[P, M, A, AL]) CreateOrUpdate ¶ added in v0.4.0
func (*GenericStore[P, M, A, AL]) List ¶ added in v0.4.0
func (s *GenericStore[P, M, A, AL]) List(ctx context.Context, orgId uuid.UUID, listParams ListParams) (*AL, error)
func (*GenericStore[P, M, A, AL]) UpdateStatus ¶ added in v0.4.0
type IntegrationTestCallback ¶
type IntegrationTestCallback func()
type ListParams ¶
type ListParams struct {
Limit int
Continue *Continue
FieldSelector *selector.FieldSelector
LabelSelector *selector.LabelSelector
AnnotationSelector *selector.AnnotationSelector
SortOrder *SortOrder
SortColumns []SortColumn
}
type ListQueryOption ¶ added in v0.5.0
type ListQueryOption func(*listQuery)
func WithSelectorResolver ¶ added in v0.5.0
func WithSelectorResolver(resolver selector.Resolver) ListQueryOption
type RemoveOwnerCallback ¶ added in v0.10.0
type SortColumn ¶ added in v0.8.1
type SortColumn string
type StatusCount ¶
type StatusCountList ¶ added in v0.3.0
type StatusCountList []StatusCount