Documentation ¶
Overview ¶
Package sqlite implements the sqlite repository.
Index ¶
- func MigrateAndSeed(db *gorm.DB, logger *slog.Logger, options *MigrationOptions) error
- type APIKey
- type APIKeyRepository
- func (r *APIKeyRepository) CreateAPIKey(ctx context.Context, createAPIKeyRequest *domain.CreateAPIKeyRequest) (*domain.APIKey, error)
- func (r *APIKeyRepository) DeleteAPIKey(ctx context.Context, id uuid.UUID) error
- func (r *APIKeyRepository) GetForNameAndUserID(ctx context.Context, ...) (*domain.APIKey, error)
- func (r *APIKeyRepository) UpdateKey(ctx context.Context, updateAPIKeyRequest *domain.UpdateAPIKeyRequest) error
- func (r *APIKeyRepository) Validate(ctx context.Context, s string) (uuid.UUID, error)
- type BaseModel
- type MigrationOptions
- type Project
- type ProjectRepository
- func (r *ProjectRepository) Create(ctx context.Context, project *domain.CreateProjectRequest) (*domain.Project, error)
- func (r *ProjectRepository) GetByID(ctx context.Context, id uuid.UUID) (*domain.Project, error)
- func (r *ProjectRepository) GetByName(ctx context.Context, name string) (*domain.Project, error)
- func (r *ProjectRepository) List(ctx context.Context, getProjectsRequest *domain.ListProjectsRequest) ([]*domain.Project, error)
- type Repository
- type Run
- type RunRepository
- func (r *RunRepository) Create(ctx context.Context, createRunRequest *domain.CreateRunRequest) (*domain.Run, error)
- func (r *RunRepository) Get(ctx context.Context, id uuid.UUID) (*domain.Run, error)
- func (r *RunRepository) ListForProject(ctx context.Context, getForProjectRequest *domain.ListRunsForProjectRequest) ([]*domain.Run, error)
- func (r *RunRepository) Update(ctx context.Context, updateRunRequest *domain.UpdateRunRequest) (*domain.Run, error)
- type RunState
- type Scenario
- type ScenarioDetails
- type ScenarioRepository
- type Step
- type User
- type UserRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateAndSeed ¶
MigrateAndSeed migrates the sqlite database and seeds it with initial data.
Types ¶
type APIKey ¶
type APIKey struct { BaseModel Name string `gorm:"index:idx_api_key_name_user_id_unique,unique"` Key string `gorm:"uniqueIndex"` UserID uuid.UUID `gorm:"index:idx_api_key_name_user_id_unique,unique"` IsDefault bool }
APIKey is the sqlite model for storing API Keys.
type APIKeyRepository ¶
type APIKeyRepository struct {
// contains filtered or unexported fields
}
APIKeyRepository is the sqlite repository for storing API Keys.
func NewAPIKeyRepository ¶
func NewAPIKeyRepository(conn *gorm.DB) *APIKeyRepository
NewAPIKeyRepository initialises the sqlite API Key repository.
func (*APIKeyRepository) CreateAPIKey ¶
func (r *APIKeyRepository) CreateAPIKey(ctx context.Context, createAPIKeyRequest *domain.CreateAPIKeyRequest) (*domain.APIKey, error)
CreateAPIKey creates an API Key in sqlite.
func (*APIKeyRepository) DeleteAPIKey ¶
DeleteAPIKey deletes an API Key from sqlite.
func (*APIKeyRepository) GetForNameAndUserID ¶
func (r *APIKeyRepository) GetForNameAndUserID(ctx context.Context, getAPIKeyForNameAndUserIDRequest *domain.GetAPIKeyForNameAndUserIDRequest) (*domain.APIKey, error)
GetForNameAndUserID returns an API Key for a given name and user id.
func (*APIKeyRepository) UpdateKey ¶
func (r *APIKeyRepository) UpdateKey(ctx context.Context, updateAPIKeyRequest *domain.UpdateAPIKeyRequest) error
UpdateKey updates the key of an API Key.
type MigrationOptions ¶
type MigrationOptions struct {
APIKey string
}
MigrationOptions represents the options for the sqlite migration.
type ProjectRepository ¶
type ProjectRepository struct {
// contains filtered or unexported fields
}
ProjectRepository is the sqlite repository for projects.
func NewProjectRepository ¶
func NewProjectRepository(conn *gorm.DB) *ProjectRepository
NewProjectRepository initialises the sqlite project repository.
func (*ProjectRepository) Create ¶
func (r *ProjectRepository) Create(ctx context.Context, project *domain.CreateProjectRequest) (*domain.Project, error)
Create creates a new project in sqlite.
func (*ProjectRepository) List ¶
func (r *ProjectRepository) List(ctx context.Context, getProjectsRequest *domain.ListProjectsRequest) ([]*domain.Project, error)
List returns all projects from sqlite.
type Repository ¶
type Repository struct { ProjectRepository *ProjectRepository ScenarioRepository *ScenarioRepository RunRepository *RunRepository APIKeyRepository *APIKeyRepository UserRepository *UserRepository }
Repository is the sqlite repository.
func NewRepository ¶
func NewRepository(dsn string, logger *slog.Logger, options *MigrationOptions) (*Repository, error)
NewRepository initialises the sqlite repository.
type Run ¶
type Run struct { BaseModel ProjectID uuid.UUID `gorm:"type:uuid;index:idx_project_id"` Success bool State RunState ErrorMessage string ScenarioDetails []byte }
Run is the sqlite model for runs.
type RunRepository ¶
type RunRepository struct {
// contains filtered or unexported fields
}
RunRepository is the sqlite repository for runs.
func NewRunRepository ¶
func NewRunRepository(conn *gorm.DB) *RunRepository
NewRunRepository initialises the sqlite run repository.
func (*RunRepository) Create ¶
func (r *RunRepository) Create(ctx context.Context, createRunRequest *domain.CreateRunRequest) (*domain.Run, error)
Create creates a new run in sqlite.
func (*RunRepository) ListForProject ¶
func (r *RunRepository) ListForProject(ctx context.Context, getForProjectRequest *domain.ListRunsForProjectRequest) ([]*domain.Run, error)
ListForProject returns all runs for a given project list runs request.
func (*RunRepository) Update ¶
func (r *RunRepository) Update(ctx context.Context, updateRunRequest *domain.UpdateRunRequest) (*domain.Run, error)
Update updates a run in sqlite.
type Scenario ¶
type Scenario struct { BaseModel Name string `gorm:"index:idx_project_id_name_unique,unique"` SpecType string Spec string ProjectID uuid.UUID `gorm:"index:idx_project_id_name_unique,unique"` }
Scenario is the sqlite model for scenarios.
type ScenarioDetails ¶
type ScenarioDetails struct { Name string `json:"name"` Duration time.Duration `json:"duration"` Assertions int `json:"assertions"` Steps []*Step `json:"steps"` Success bool `json:"success"` }
ScenarioDetails is the json model for scenario run details.
type ScenarioRepository ¶
type ScenarioRepository struct {
// contains filtered or unexported fields
}
ScenarioRepository is the sqlite repository for projects.
func NewScenarioRepository ¶
func NewScenarioRepository(conn *gorm.DB) *ScenarioRepository
NewScenarioRepository initialises the sqlite scenario repository.
func (*ScenarioRepository) Create ¶
func (r *ScenarioRepository) Create(ctx context.Context, createScenarioRequest *domain.CreateScenarioRequest) (*domain.Scenario, error)
Create creates a new scenario in sqlite.
func (*ScenarioRepository) GetForProject ¶
func (r *ScenarioRepository) GetForProject(ctx context.Context, getForProjectRequest *domain.GetScenariosForProjectRequest) ([]*domain.Scenario, error)
GetForProject returns all scenarios for a given project.
type Step ¶
type Step struct { Name string `json:"name"` Assertions int `json:"assertions"` URL string `json:"url"` RequestDuration time.Duration `json:"request_duration"` Duration time.Duration `json:"duration"` Retries int `json:"retries"` Success bool `json:"success"` }
Step is the json model for scenario step run details.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository is the sqlite repository for users.
func NewUserRepository ¶
func NewUserRepository(conn *gorm.DB) *UserRepository
NewUserRepository initialises the sqlite user repository.
func (*UserRepository) CreateUser ¶
CreateUser creates a user in sqlite.
func (*UserRepository) GetUserByName ¶
GetUserByName returns a user from sqlite by name.