Documentation
¶
Index ¶
- Constants
- Variables
- func Register(name string, driver Driver)
- type AuthClient
- type AuthCode
- type AuthCodeState
- type DB
- type Deployment
- type DeploymentStatus
- type Driver
- type Entity
- type InsertDeploymentOptions
- type InsertProjectOptions
- type InsertUserAuthTokenOptions
- type Organization
- type Project
- type RuntimeSlotsUsed
- type Tx
- type UpdateProjectOptions
- type User
- type UserAuthToken
- type UserGithubInstallation
- type Variables
Constants ¶
const ( AuthClientIDRillWeb = "12345678-0000-0000-0000-000000000001" AuthClientIDRillCLI = "12345678-0000-0000-0000-000000000002" )
Hard-coded auth client IDs (created in the migrations).
Variables ¶
var Drivers = make(map[string]Driver)
Drivers is a registry of drivers
var ErrNotFound = errors.New("database: not found")
ErrNotFound is returned for single row queries that return no values.
var ErrNotUnique = errors.New("database: violates unique constraint")
ErrNotUnique is returned when a unique constraint is violated
Functions ¶
Types ¶
type AuthClient ¶ added in v0.23.0
type AuthClient struct {
ID string
DisplayName string
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
AuthClient is a client that requests and consumes auth tokens.
type AuthCode ¶ added in v0.23.0
type AuthCode struct {
ID string `db:"id"`
DeviceCode string `db:"device_code"`
UserCode string `db:"user_code"`
Expiry time.Time `db:"expires_on"`
ApprovalState AuthCodeState `db:"approval_state"`
ClientID string `db:"client_id"`
UserID *string `db:"user_id"`
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
AuthCode represents a user authentication code as part of the OAuth2 device flow. They're currently used for authenticating users in the CLI.
type AuthCodeState ¶ added in v0.23.1
type AuthCodeState int
AuthCodeState is an enum representing the approval state of an AuthCode
const ( AuthCodeStatePending AuthCodeState = 0 AuthCodeStateApproved AuthCodeState = 1 AuthCodeStateRejected AuthCodeState = 2 )
type DB ¶
type DB interface {
Close() error
NewTx(ctx context.Context) (context.Context, Tx, error)
Migrate(ctx context.Context) error
FindMigrationVersion(ctx context.Context) (int, error)
FindOrganizations(ctx context.Context) ([]*Organization, error)
FindOrganizationByName(ctx context.Context, name string) (*Organization, error)
InsertOrganization(ctx context.Context, name string, description string) (*Organization, error)
InsertOrganizationFromSeeds(ctx context.Context, nameSeeds []string, description string) (*Organization, error)
UpdateOrganization(ctx context.Context, name string, description string) (*Organization, error)
DeleteOrganization(ctx context.Context, name string) error
FindProjects(ctx context.Context, orgName string) ([]*Project, error)
FindProjectByName(ctx context.Context, orgName string, name string) (*Project, error)
FindProjectByGithubURL(ctx context.Context, githubURL string) (*Project, error)
InsertProject(ctx context.Context, opts *InsertProjectOptions) (*Project, error)
UpdateProject(ctx context.Context, id string, opts *UpdateProjectOptions) (*Project, error)
DeleteProject(ctx context.Context, id string) error
FindUsers(ctx context.Context) ([]*User, error)
FindUser(ctx context.Context, id string) (*User, error)
FindUserByEmail(ctx context.Context, email string) (*User, error)
InsertUser(ctx context.Context, email, displayName, photoURL string) (*User, error)
UpdateUser(ctx context.Context, id, displayName, photoURL string) (*User, error)
DeleteUser(ctx context.Context, id string) error
FindUserAuthTokens(ctx context.Context, userID string) ([]*UserAuthToken, error)
FindUserAuthToken(ctx context.Context, id string) (*UserAuthToken, error)
InsertUserAuthToken(ctx context.Context, opts *InsertUserAuthTokenOptions) (*UserAuthToken, error)
DeleteUserAuthToken(ctx context.Context, id string) error
// InsertAuthCode inserts the authorization code data into the store.
InsertAuthCode(ctx context.Context, deviceCode, userCode, clientID string, expiresOn time.Time) (*AuthCode, error)
// FindAuthCodeByDeviceCode retrieves the authorization code data from the store
FindAuthCodeByDeviceCode(ctx context.Context, deviceCode string) (*AuthCode, error)
// FindAuthCodeByUserCode retrieves the authorization code data from the store
FindAuthCodeByUserCode(ctx context.Context, userCode string) (*AuthCode, error)
// UpdateAuthCode updates the authorization code data in the store
UpdateAuthCode(ctx context.Context, userCode, userID string, approvalState AuthCodeState) error
// DeleteAuthCode deletes the authorization code data from the store
DeleteAuthCode(ctx context.Context, deviceCode string) error
FindUserGithubInstallation(ctx context.Context, userID string, installationID int64) (*UserGithubInstallation, error)
UpsertUserGithubInstallation(ctx context.Context, userID string, installationID int64) error
DeleteUserGithubInstallations(ctx context.Context, installationID int64) error
FindDeployments(ctx context.Context, projectID string) ([]*Deployment, error)
FindDeployment(ctx context.Context, id string) (*Deployment, error)
InsertDeployment(ctx context.Context, opts *InsertDeploymentOptions) (*Deployment, error)
UpdateDeploymentStatus(ctx context.Context, id string, status DeploymentStatus, logs string) (*Deployment, error)
DeleteDeployment(ctx context.Context, id string) error
QueryRuntimeSlotsUsed(ctx context.Context) ([]*RuntimeSlotsUsed, error)
}
DB is the interface for a database connection.
type Deployment ¶ added in v0.23.0
type Deployment struct {
ID string `db:"id"`
ProjectID string `db:"project_id"`
Slots int `db:"slots"`
Branch string `db:"branch"`
RuntimeHost string `db:"runtime_host"`
RuntimeInstanceID string `db:"runtime_instance_id"`
RuntimeAudience string `db:"runtime_audience"`
Status DeploymentStatus `db:"status"`
Logs string `db:"logs"`
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
Deployment is a single deployment of a git branch. Deployments belong to a project.
type DeploymentStatus ¶ added in v0.23.0
type DeploymentStatus int
DeploymentStatus is an enum representing the state of a deployment
const ( DeploymentStatusUnspecified DeploymentStatus = 0 DeploymentStatusPending DeploymentStatus = 1 DeploymentStatusOK DeploymentStatus = 2 DeploymentStatusReconciling DeploymentStatus = 3 DeploymentStatusError DeploymentStatus = 4 )
type Entity ¶ added in v0.23.0
type Entity string
Entity is an enum representing the entities in this package.
type InsertDeploymentOptions ¶ added in v0.23.1
type InsertDeploymentOptions struct {
ProjectID string
Slots int
Branch string
RuntimeHost string
RuntimeInstanceID string
RuntimeAudience string
Status DeploymentStatus
Logs string
}
InsertDeploymentOptions defines options for inserting a new Deployment.
type InsertProjectOptions ¶ added in v0.23.1
type InsertProjectOptions struct {
OrganizationID string
Name string
Description string
Public bool
ProductionSlots int
ProductionBranch string
GithubURL *string
GithubInstallationID *int64
ProductionVariables map[string]string
}
InsertProjectOptions defines options for inserting a new Project.
type InsertUserAuthTokenOptions ¶ added in v0.23.1
type InsertUserAuthTokenOptions struct {
ID string
SecretHash []byte
UserID string
DisplayName string
AuthClientID *string
}
InsertUserAuthTokenOptions defines options for creating a UserAuthToken.
type Organization ¶
type Organization struct {
ID string
Name string
Description string
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
Organization represents a tenant.
type Project ¶
type Project struct {
ID string
OrganizationID string `db:"organization_id"`
Name string
Description string
Public bool
ProductionSlots int `db:"production_slots"`
ProductionBranch string `db:"production_branch"`
ProductionVariables Variables `db:"production_variables"`
GithubURL *string `db:"github_url"`
GithubInstallationID *int64 `db:"github_installation_id"`
ProductionDeploymentID *string `db:"production_deployment_id"`
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
Project represents one Git connection. Projects belong to an organization.
type RuntimeSlotsUsed ¶ added in v0.23.0
type RuntimeSlotsUsed struct {
RuntimeHost string `db:"runtime_host"`
SlotsUsed int `db:"slots_used"`
}
RuntimeSlotsUsed is the result of a QueryRuntimeSlotsUsed query.
type Tx ¶ added in v0.23.0
type Tx interface {
// Commit commits the transaction
Commit() error
// Rollback discards the transaction *unless* it has already been committed.
// It does nothing if Commit has already been called.
// This means that a call to Rollback should almost always be defer'ed right after a call to NewTx.
Rollback() error
}
Tx represents a database transaction. It can only be used to commit and rollback transactions. Actual database calls should be made by passing the ctx returned from DB.NewTx to functions on the DB.
type UpdateProjectOptions ¶ added in v0.23.1
type UpdateProjectOptions struct {
Description string
Public bool
ProductionBranch string
ProductionVariables map[string]string
GithubURL *string
GithubInstallationID *int64
ProductionDeploymentID *string
}
UpdateProjectOptions defines options for updating a Project.
type User ¶ added in v0.23.0
type User struct {
ID string
Email string
DisplayName string `db:"display_name"`
PhotoURL string `db:"photo_url"`
CreatedOn time.Time `db:"created_on"`
UpdatedOn time.Time `db:"updated_on"`
}
User is a person registered in Rill. Users may belong to multiple organizations and projects.
type UserAuthToken ¶ added in v0.23.0
type UserAuthToken struct {
ID string
SecretHash []byte `db:"secret_hash"`
UserID string `db:"user_id"`
DisplayName string `db:"display_name"`
AuthClientID *string `db:"auth_client_id"`
CreatedOn time.Time `db:"created_on"`
}
UserAuthToken is a persistent API token for a user.
type UserGithubInstallation ¶ added in v0.23.0
type UserGithubInstallation struct {
ID string `db:"id"`
UserID string `db:"user_id"`
InstallationID int64 `db:"installation_id"`
CreatedOn time.Time `db:"created_on"`
}
UserGithubInstallation represents a confirmed user relationship to an installation of our Github app