store

package
v0.6.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RoleLevel = map[Role]int{
	RoleOwner:     3,
	RoleAdmin:     2,
	RoleDeveloper: 1,
	RoleViewer:    0,
}

Functions

This section is empty.

Types

type Blueprint

type Blueprint struct {
	Name        string            `json:"name" db:"name"`
	Desc        string            `json:"description" db:"description"`
	Source      Source            `json:"source" db:"source"`
	Type        ServiceType       `json:"type" db:"type"`
	Runtime     RuntimeObj        `json:"runtime" db:"runtime"`
	Remote      RemoteObj         `json:"remote" db:"remote"`
	RunCmd      string            `json:"run_cmd,omitempty" db:"run_cmd"`
	BuildCmd    string            `json:"build_cmd,omitempty" db:"build_cmd"`
	Port        int               `json:"port" db:"port"`
	WorkingDir  string            `json:"working_dir,omitempty" db:"working_dir"`
	StaticDir   string            `json:"static_dir,omitempty" db:"static_dir"`
	Image       string            `json:"image,omitempty" db:"image"`
	EnvVars     map[string]string `json:"env_vars,omitempty" db:"env_vars"`
	Secrets     map[string]string `json:"secrets,omitempty" db:"secrets"`
	Status      string            `json:"status" db:"status"`
	ProjectID   *string           `json:"project_id,omitempty" db:"project_id"`
	HealthCheck *HealthCheck      `json:"health_check,omitempty" db:"health_check"`
}

type Deployment

type Deployment struct {
	ID        string    `json:"id" db:"id"`
	Name      string    `json:"name" db:"name"`
	UserId    *string   `json:"user_id,omitempty" db:"user_id"`
	Blueprint Blueprint `json:"config" db:"config"`
	Status    Status    `json:"status" db:"status"`
	Metadata  string    `json:"metadata" db:"metadata"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

type DeploymentStore

type DeploymentStore interface {
	UpsertDeployment(ctx context.Context, d *Deployment) error
	GetDeployment(ctx context.Context, id string) (*Deployment, error)
	ListDeployments(ctx context.Context, limit, offset int) ([]*Deployment, error)
	UpdateDeploymentStatus(ctx context.Context, id string, status string) error
}

type HealthCheck added in v0.6.21

type HealthCheck struct {
	Path     string `json:"path"`
	Interval int    `json:"interval,omitempty"`
	Timeout  int    `json:"timeout,omitempty"`
	Retries  int    `json:"retries,omitempty"`
}

type Instance

type Instance struct {
	ID              string    `json:"id" db:"id"`
	BootstrapToken  string    `json:"bootstrap_token" db:"bootstrap_token"`
	AccessToken     string    `json:"access_token" db:"access_token"`
	InstanceID      string    `json:"instance_id" db:"instance_id"`
	Issuer          string    `json:"issuer" db:"issuer"`
	Audience        string    `json:"audience" db:"audience"`
	RegisteredAt    time.Time `json:"registered_at" db:"registered_at"`
	LastInstalledAt time.Time `json:"last_installed_at" db:"last_installed_at"`
}

Instance table for this dployr server

type InstanceStore

type InstanceStore interface {
	GetInstance(ctx context.Context) (*Instance, error)
	RegisterInstance(ctx context.Context, i *Instance) error
	UpdateLastInstalledAt(ctx context.Context) error
	SetBootstrapToken(ctx context.Context, token string) error
	GetBootstrapToken(ctx context.Context) (string, error)
	SetAccessToken(ctx context.Context, token string) error
	GetAccessToken(ctx context.Context) (string, error)
}

InstanceStore provides access to the instance record stored in SQLite.

type NodeRole added in v0.6.21

type NodeRole string
const (
	NodeRoleInstance NodeRole = "instance"
	NodeRoleBuild    NodeRole = "build"
)

type RemoteObj

type RemoteObj struct {
	Url        string `json:"url" db:"url"`
	Branch     string `json:"branch" db:"branch"`
	CommitHash string `json:"commit_hash" db:"commit_hash"`
	Token      string `json:"token,omitempty" db:"-"`
}

type Role

type Role string
const (
	RoleOwner     Role = "owner"     // uninstall dployr, manage admins
	RoleAdmin     Role = "admin"     // delete infrastructure, secrets, users, proxies; manage deployr versions; shell access
	RoleDeveloper Role = "developer" // deploy apps, view logs, view events, view resource graph
	RoleViewer    Role = "viewer"    // view services
)

owner > admin > developer > viewer

func (Role) IsPermitted

func (r Role) IsPermitted(required Role) bool

type Runtime

type Runtime string
const (
	RuntimeGo     Runtime = "golang"
	RuntimePHP    Runtime = "php"
	RuntimePython Runtime = "python"
	RuntimeNodeJS Runtime = "nodejs"
	RuntimeRuby   Runtime = "ruby"
	RuntimeDotnet Runtime = "dotnet"
	RuntimeJava   Runtime = "java"
)

type RuntimeObj

type RuntimeObj struct {
	Type    Runtime `json:"type" db:"type" validate:"required,oneof=golang php python nodejs ruby dotnet java"`
	Version string  `json:"version,omitempty" db:"version"`
}

type Service

type Service struct {
	ID             string            `json:"id" db:"id"`
	Name           string            `json:"name" db:"name"`
	Description    string            `json:"description" db:"description"`
	Source         Source            `json:"source" db:"source"`
	Type           ServiceType       `json:"type" db:"type"`
	Runtime        Runtime           `json:"runtime" db:"runtime"`
	RuntimeVersion string            `json:"runtime_version,omitempty" db:"runtime_version"`
	RunCmd         string            `json:"run_cmd,omitempty" db:"run_cmd"`
	BuildCmd       string            `json:"build_cmd,omitempty" db:"build_cmd"`
	Port           int               `json:"port"`
	WorkingDir     string            `json:"working_dir,omitempty" db:"working_dir"`
	StaticDir      string            `json:"static_dir,omitempty" db:"static_dir"`
	Image          string            `json:"image,omitempty" db:"image"`
	EnvVars        map[string]string `json:"env_vars,omitempty"`
	Secrets        map[string]string `json:"secrets,omitempty"`
	Remote         string            `json:"remote,omitempty" db:"remote_url"`
	Branch         string            `json:"branch" db:"remote_branch"`
	CommitHash     string            `json:"commit_hash" db:"remote_commit_hash"`
	DeploymentId   string            `json:"-" db:"deployment_id"`
	Blueprint      *Blueprint        `json:"blueprint,omitempty"`
	CreatedAt      time.Time         `json:"created_at" db:"created_at"`
	UpdatedAt      time.Time         `json:"updated_at" db:"updated_at"`
}

type ServiceStore

type ServiceStore interface {
	GetService(ctx context.Context, name string) (*Service, error)
	ListServices(ctx context.Context, limit, offset int) ([]*Service, error)
	UpsertService(ctx context.Context, svc *Service) (*Service, error)
	DeleteService(ctx context.Context, name string) error
}

type ServiceType added in v0.6.0

type ServiceType string
const (
	TypeStatic ServiceType = "static"
	TypeWorker ServiceType = "worker"
	TypeWeb    ServiceType = "web"
	TypeJob    ServiceType = "job"
)

type Source added in v0.6.0

type Source string
const (
	SourceRemote Source = "remote"
	SourceImage  Source = "image"
)

type Status

type Status string
const (
	StatusPending    Status = "pending"
	StatusInProgress Status = "in_progress"
	StatusFailed     Status = "failed"
	StatusCompleted  Status = "completed"
)

type TaskResult

type TaskResult struct {
	ID     string `db:"id"`
	Status string `db:"status"`
	Result any    `db:"result"`
	Error  string `db:"error"`
}

TaskResult represents the outcome of executing a remote task.

type TaskResultStore

type TaskResultStore interface {
	// ListUnsent returns all results that have not yet been marked as synced.
	ListUnsent(ctx context.Context) ([]*TaskResult, error)
	// SaveResults persists new task results as unsynced.
	SaveResults(ctx context.Context, results []*TaskResult) error
	// MarkSynced marks the given result IDs as synced.
	MarkSynced(ctx context.Context, ids []string) error
}

TaskResultStore provides access to persisted task results.

type User

type User struct {
	ID        string    `json:"id" db:"id"`
	Email     string    `json:"email" db:"email"`
	Role      Role      `json:"role" db:"role"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

type UserStore

type UserStore interface {
	FindOrCreateUser(email string, role Role) (*User, error)
	GetUserByEmail(ctx context.Context, email string) (*User, error)
	UpdateUserRole(ctx context.Context, email string, role Role) error
	HasOwner() (bool, error) // Returns true if owner exists
	GetRole(ctx context.Context, email string) (Role, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL