Documentation ¶
Index ¶
- Variables
- func NewStorage(opts ...StorageOption) (s persistence.Storage, err error)
- type AnySerializer
- type DB
- type DurationSerializer
- type QueryOption
- type StorageOption
- func WithAdditionalAutoMigration(types ...any) StorageOption
- func WithInMemory() StorageOption
- func WithLogger(logger logger.Interface) StorageOption
- func WithMaxOpenConns(max int) StorageOption
- func WithPostgres(host string, port uint16, user string, pw string, db string, sslmode string) StorageOption
- type TimestampSerializer
- type ValueSerializer
Constants ¶
This section is empty.
Variables ¶
var DefaultTypes = []any{ &assessment.MetricImplementation{}, &assessment.Metric{}, &assessment.AssessmentResult{}, &discovery.Resource{}, &evidence.Evidence{}, &orchestrator.CertificationTarget{}, &orchestrator.Certificate{}, &orchestrator.State{}, &orchestrator.Catalog{}, &orchestrator.Category{}, &orchestrator.Control{}, &orchestrator.AuditScope{}, &evaluation.EvaluationResult{}, }
DefaultTypes contains a list of internal types that need to be migrated by default
Functions ¶
func NewStorage ¶
func NewStorage(opts ...StorageOption) (s persistence.Storage, err error)
NewStorage creates a new storage using GORM (which DB to use depends on the StorageOption)
Types ¶
type AnySerializer ¶
type AnySerializer struct{}
AnySerializer is a GORM serializer that allows the serialization and deserialization of the google.protobuf.Any protobuf message type using a JSONB field.
func (AnySerializer) Scan ¶
func (AnySerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)
Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how this struct can be loaded from an SQL database field.
func (AnySerializer) Value ¶
func (AnySerializer) Value(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) (interface{}, error)
Value implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerValuerInterface to indicate how this struct will be saved into an SQL database field.
type DurationSerializer ¶
type DurationSerializer struct{}
DurationSerializer is a GORM serializer that allows the serialization and deserialization of the google.protobuf.Duration protobuf message type.
func (DurationSerializer) Scan ¶
func (DurationSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)
Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how this struct can be loaded from an SQL database field.
func (DurationSerializer) Value ¶
func (DurationSerializer) Value(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) (interface{}, error)
Value implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerValuerInterface to indicate how this struct will be saved into an SQL database field.
type QueryOption ¶
type QueryOption interface{}
func WithPreload ¶
func WithPreload(query string, args ...any) QueryOption
WithPreload allows the customization of Gorm's preload feature with the specified query and arguments.
func WithoutPreload ¶
func WithoutPreload() QueryOption
WithoutPreload disables any kind of preloading of Gorm. This is necessary, if custom join tables are used, otherwise Gorm will throws errors.
type StorageOption ¶
type StorageOption func(*storage)
StorageOption is a functional option type to configure the GORM storage. E.g. WithInMemory or WithPostgres
func WithAdditionalAutoMigration ¶
func WithAdditionalAutoMigration(types ...any) StorageOption
WithAdditionalAutoMigration is an option to add additional types to GORM's auto-migration.
func WithInMemory ¶
func WithInMemory() StorageOption
WithInMemory is an option to configure Storage to use an in memory DB
func WithLogger ¶
func WithLogger(logger logger.Interface) StorageOption
WithLogger is an option to configure Storage to use a Logger
func WithMaxOpenConns ¶
func WithMaxOpenConns(max int) StorageOption
WithMaxOpenConns is an option to configure the maximum number of open connections
func WithPostgres ¶
func WithPostgres(host string, port uint16, user string, pw string, db string, sslmode string) StorageOption
WithPostgres is an option to configure Storage to use a Postgres DB
type TimestampSerializer ¶
type TimestampSerializer struct{}
TimestampSerializer is a GORM serializer that allows the serialization and deserialization of the google.protobuf.Timestamp protobuf message type.
func (TimestampSerializer) Scan ¶
func (TimestampSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)
Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how this struct can be loaded from an SQL database field.
func (TimestampSerializer) Value ¶
func (TimestampSerializer) Value(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) (interface{}, error)
Value implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerValuerInterface to indicate how this struct will be saved into an SQL database field.
type ValueSerializer ¶
type ValueSerializer struct{}
ValueSerializer is a GORM serializer that allows the serialization and deserialization of the google.protobuf.Value protobuf message type.
func (ValueSerializer) Scan ¶
func (ValueSerializer) Scan(ctx context.Context, field *schema.Field, dst reflect.Value, dbValue interface{}) (err error)
Scan implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerInterface to indicate how this struct can be loaded from an SQL database field.
func (ValueSerializer) Value ¶
func (ValueSerializer) Value(_ context.Context, _ *schema.Field, _ reflect.Value, fieldValue interface{}) (interface{}, error)
Value implements https://pkg.go.dev/gorm.io/gorm/schema#SerializerValuerInterface to indicate how this struct will be saved into an SQL database field.