Documentation ¶
Index ¶
- Constants
- func IsQueryBuilderSetClauseError(err error) bool
- func KeyAccessServerProtoJSON(keyAccessServerJSON []byte) ([]*policy.KeyAccessServer, error)
- func MarshalCreateMetadata(metadata *common.MetadataMutable) ([]byte, *common.Metadata, error)
- func MarshalUpdateMetadata(m *common.MetadataMutable, b common.MetadataUpdateEnum, ...) ([]byte, *common.Metadata, error)
- func NewStatementBuilder() sq.StatementBuilderType
- func NewTable(schema string) func(name string) Table
- func NewUniqueAlreadyExistsError(value string) error
- func StatusifyError(err error, fallbackErr string, log ...any) error
- func WrapIfKnownInvalidQueryErr(err error) error
- type Client
- func (c *Client) Close()
- func (c Client) Exec(ctx context.Context, sql string, args []interface{}) error
- func (c *Client) MigrationDown(ctx context.Context, migrations *embed.FS) error
- func (c *Client) MigrationStatus(ctx context.Context) ([]*goose.MigrationStatus, error)
- func (c Client) Query(ctx context.Context, sql string, args []interface{}) (pgx.Rows, error)
- func (c Client) QueryRow(ctx context.Context, sql string, args []interface{}) (pgx.Row, error)
- func (c *Client) RunMigrations(ctx context.Context, migrations *embed.FS) (int, error)
- func (c *Client) Schema() string
- type Config
- type DBError
- type OptsFunc
- type PgxIface
- type Table
Constants ¶
View Source
const ( ErrTextCreationFailed = "resource creation failed" ErrTextDeletionFailed = "resource deletion failed" ErrTextDeactivationFailed = "resource deactivation failed" ErrTextGetRetrievalFailed = "resource retrieval failed" ErrTextListRetrievalFailed = "resource list retrieval failed" ErrTextUpdateFailed = "resource update failed" ErrTextNotFound = "resource not found" ErrTextConflict = "resource unique field violation" ErrTextRelationInvalid = "resource relation invalid" ErrTextEnumValueInvalid = "enum value invalid" ErrTextUUIDInvalid = "invalid input syntax for type uuid" ErrTextRestrictViolation = "intended action would violate a restriction" ErrTextFqnMissingValue = "FQN must specify a valid value and be of format 'https://<namespace>/attr/<attribute name>/value/<value>'" )
Variables ¶
This section is empty.
Functions ¶
func KeyAccessServerProtoJSON ¶
func KeyAccessServerProtoJSON(keyAccessServerJSON []byte) ([]*policy.KeyAccessServer, error)
func MarshalCreateMetadata ¶
func MarshalUpdateMetadata ¶
func NewStatementBuilder ¶
func NewStatementBuilder() sq.StatementBuilderType
Postgres uses $1, $2, etc. for placeholders
func WrapIfKnownInvalidQueryErr ¶
Get helpful error message for PostgreSQL violation
Types ¶
type Client ¶
type Client struct { Pgx PgxIface // This is the stdlib connection that is used for transactions SQLDB *sql.DB // contains filtered or unexported fields }
func (*Client) MigrationDown ¶
func (*Client) MigrationStatus ¶
func (*Client) RunMigrations ¶
RunMigrations runs the migrations for the schema Schema will be created if it doesn't exist
type Config ¶
type Config struct { Host string `yaml:"host" default:"localhost"` Port int `yaml:"port" default:"5432"` Database string `yaml:"database" default:"opentdf"` User string `yaml:"user" default:"postgres"` Password string `yaml:"password" default:"changeme"` RunMigrations bool `yaml:"runMigrations" default:"true"` SSLMode string `yaml:"sslmode" default:"prefer"` Schema string `yaml:"schema" default:"opentdf"` VerifyConnection bool `yaml:"verifyConnection" default:"true"` MigrationsFS *embed.FS }
type DBError ¶
type DBError string //nolint:revive // DBError is a valid name for this type
const ( ErrUniqueConstraintViolation DBError = "ErrUniqueConstraintViolation: value must be unique" ErrNotNullViolation DBError = "ErrNotNullViolation: value cannot be null" ErrForeignKeyViolation DBError = "ErrForeignKeyViolation: value is referenced by another table" ErrRestrictViolation DBError = "ErrRestrictViolation: value cannot be deleted due to restriction" ErrNotFound DBError = "ErrNotFound: value not found" ErrEnumValueInvalid DBError = "ErrEnumValueInvalid: not a valid enum value" ErrUUIDInvalid DBError = "ErrUUIDInvalid: value not a valid UUID" ErrFqnMissingValue DBError = "ErrFqnMissingValue: FQN must include a value" ErrMissingValue DBError = "ErrMissingValue: value must be included" )
type PgxIface ¶
type PgxIface interface { Acquire(ctx context.Context) (*pgxpool.Conn, error) Exec(context.Context, string, ...any) (pgconn.CommandTag, error) QueryRow(context.Context, string, ...any) pgx.Row Query(context.Context, string, ...any) (pgx.Rows, error) Ping(context.Context) error Close() Config() *pgxpool.Config }
We can rename this but wanted to get mocks working.
Click to show internal directories.
Click to hide internal directories.