Documentation
¶
Overview ¶
Package kanbans manages per-tenant Vikunja kanban board provisioning.
Index ¶
- Constants
- type Kanban
- type KanbanCredentials
- type Manager
- func (m *Manager) Create(ctx context.Context, tenantID string) (*Kanban, error)
- func (m *Manager) Delete(ctx context.Context, tenantID string) error
- func (m *Manager) Get(ctx context.Context, tenantID string) (*Kanban, error)
- func (m *Manager) GetAdminToken(ctx context.Context, tenantID string) (string, error)
- func (m *Manager) PortRange() (start, end int)
- func (m *Manager) ReconcileStale()
- func (m *Manager) SetBaseURL(url string)
- func (m *Manager) SetHealthCheckTimeout(d time.Duration)
- func (m *Manager) StartForTenant(ctx context.Context, tenantID string)
- func (m *Manager) StopForTenant(ctx context.Context, tenantID string)
Constants ¶
const ( DefaultPortStart = 7100 DefaultPortEnd = 9100 )
Default port range for kanban containers.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kanban ¶
type Kanban struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
Status string `json:"status"`
ContainerID string `json:"-"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
URL string `json:"url,omitempty"`
Credentials *KanbanCredentials `json:"credentials,omitempty"` // only on create
VolumeName string `json:"-"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
Kanban represents a provisioned Vikunja kanban board instance.
type KanbanCredentials ¶
type KanbanCredentials struct {
Username string `json:"username"`
Password string `json:"password"`
JWT string `json:"jwt,omitempty"`
SetupSuccess bool `json:"setup_success"`
}
KanbanCredentials holds the admin credentials returned on create.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages kanban board lifecycle.
func NewManager ¶
NewManager creates a kanban manager with the default port range.
func NewManagerWithPortRange ¶
func NewManagerWithPortRange(db *sql.DB, dockerClient docker.Client, masterKey []byte, portStart, portEnd int) *Manager
NewManagerWithPortRange creates a kanban manager with a custom port range. portStart and portEnd are inclusive bounds. If portStart >= portEnd the defaults are used.
func (*Manager) Create ¶
Create provisions a new Vikunja kanban board for a tenant. It returns immediately with status "provisioning"; a background goroutine handles health checks, Vikunja setup, and status transitions to "ready" or "failed". Callers should poll GET /v1/kanban for the final status.
func (*Manager) Delete ¶
Delete destroys a kanban board: stops container, removes volume, deletes record.
func (*Manager) GetAdminToken ¶
GetAdminToken returns the decrypted admin token.
func (*Manager) ReconcileStale ¶
func (m *Manager) ReconcileStale()
ReconcileStale marks kanbans stuck in "provisioning" as "failed" and attempts to clean up their Docker resources. Called on startup.
func (*Manager) SetBaseURL ¶
SetBaseURL overrides the default base URL (for testing).
func (*Manager) SetHealthCheckTimeout ¶
SetHealthCheckTimeout overrides the default health check timeout (for testing).
func (*Manager) StartForTenant ¶
StartForTenant recreates the container of a tenant's stopped kanban board (see StopForTenant) on its existing volume and port. Vikunja's data and admin user live in the volume; only the JWT secret is regenerated, which just invalidates old login tokens. Best-effort: failures mark the board "failed".
func (*Manager) StopForTenant ¶
StopForTenant stops the kanban container for a tenant without deleting the DB record, so it can be restarted if the tenant is ever reactivated. Errors are logged but not returned — suspension should be best-effort.