model

package
v0.0.0-...-b9703bf Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GroupProjectOwnerPerm defines the permission for an owner on group projects.
	GroupProjectOwnerPerm = OwnerPerm

	// GroupProjectAdminPerm defines the permission for an admin on group projects.
	GroupProjectAdminPerm = AdminPerm

	// GroupProjectUserPerm defines the permission for an user on group projects.
	GroupProjectUserPerm = UserPerm
)
View Source
const (
	// OwnerPerm defines the general permission for an owner.
	OwnerPerm = "owner"

	// AdminPerm defines the general permission for an admin.
	AdminPerm = "admin"

	// UserPerm defines the general permission for an user.
	UserPerm = "user"
)
View Source
const (
	// UserGroupOwnerPerm defines the permission for an owner on user groups.
	UserGroupOwnerPerm = OwnerPerm

	// UserGroupAdminPerm defines the permission for an admin on user groups.
	UserGroupAdminPerm = AdminPerm

	// UserGroupUserPerm defines the permission for an user on user groups.
	UserGroupUserPerm = UserPerm
)
View Source
const (
	// UserProjectOwnerPerm defines the permission for an owner on user projects.
	UserProjectOwnerPerm = OwnerPerm

	// UserProjectAdminPerm defines the permission for an admin on user projects.
	UserProjectAdminPerm = AdminPerm

	// UserProjectUserPerm defines the permission for an user on user projects.
	UserProjectUserPerm = UserPerm
)

Variables

View Source
var (
	// ErrWrongEncryptionPassphrase defines the error if it fails to validate the encryption passphrase.
	ErrWrongEncryptionPassphrase = fmt.Errorf("wrong encryption passphrase")
)

Functions

This section is empty.

Types

type Credential

type Credential struct {
	bun.BaseModel `bun:"table:credentials"`

	ID        string          `bun:",pk,type:varchar(20)"`
	ProjectID string          `bun:"type:varchar(20)"`
	Project   *Project        `bun:"rel:belongs-to,join:project_id=id"`
	Slug      string          `bun:"type:varchar(255)"`
	Name      string          `bun:"type:varchar(255)"`
	Kind      string          `bun:"type:varchar(255)"`
	Override  bool            `bun:"type:bool"`
	Shell     CredentialShell `bun:"embed:shell_"`
	Login     CredentialLogin `bun:"embed:login_"`
	CreatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
}

Credential defines the model for credentials table.

func (*Credential) BeforeAppendModel

func (m *Credential) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Credential) DeserializeSecret

func (m *Credential) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Credential) SerializeSecret

func (m *Credential) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type CredentialLogin

type CredentialLogin struct {
	Username string `bun:"type:varchar(255)"`
	Password string `bun:"type:varchar(255)"`
}

CredentialLogin represents credentials for logins.

func (*CredentialLogin) DeserializeSecret

func (m *CredentialLogin) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*CredentialLogin) SerializeSecret

func (m *CredentialLogin) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type CredentialShell

type CredentialShell struct {
	Username   string `bun:"type:varchar(255)"`
	Password   string `bun:"type:varchar(255)"`
	PrivateKey string `bun:"type:text"`
}

CredentialShell represents credentials for shells.

func (*CredentialShell) DeserializeSecret

func (m *CredentialShell) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*CredentialShell) SerializeSecret

func (m *CredentialShell) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Environment

type Environment struct {
	bun.BaseModel `bun:"table:environments"`

	ID        string               `bun:",pk,type:varchar(20)"`
	ProjectID string               `bun:"type:varchar(20)"`
	Project   *Project             `bun:"rel:belongs-to,join:project_id=id"`
	Slug      string               `bun:"type:varchar(255)"`
	Name      string               `bun:"type:varchar(255)"`
	Secrets   []*EnvironmentSecret `bun:"rel:has-many,join:id=environment_id"`
	Values    []*EnvironmentValue  `bun:"rel:has-many,join:id=environment_id"`
	CreatedAt time.Time            `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time            `bun:",nullzero,notnull,default:current_timestamp"`
}

Environment defines the model for environments table.

func (*Environment) BeforeAppendModel

func (m *Environment) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Environment) DeserializeSecret

func (m *Environment) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Environment) SerializeSecret

func (m *Environment) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type EnvironmentSecret

type EnvironmentSecret struct {
	bun.BaseModel `bun:"table:environment_secrets"`

	ID            string    `bun:",pk,type:varchar(20)"`
	EnvironmentID string    `bun:"type:varchar(20)"`
	Kind          string    `bun:"type:varchar(255)"`
	Name          string    `bun:"type:varchar(255)"`
	Content       string    `bun:"type:text"`
	CreatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

EnvironmentSecret defines the model for environment_secrets table.

func (*EnvironmentSecret) BeforeAppendModel

func (m *EnvironmentSecret) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*EnvironmentSecret) DeserializeSecret

func (m *EnvironmentSecret) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*EnvironmentSecret) SerializeSecret

func (m *EnvironmentSecret) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type EnvironmentValue

type EnvironmentValue struct {
	bun.BaseModel `bun:"table:environment_values"`

	ID            string    `bun:",pk,type:varchar(20)"`
	EnvironmentID string    `bun:"type:varchar(20)"`
	Kind          string    `bun:"type:varchar(255)"`
	Name          string    `bun:"type:varchar(255)"`
	Content       string    `bun:"type:text"`
	CreatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt     time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

EnvironmentValue defines the model for environment_values table.

func (*EnvironmentValue) BeforeAppendModel

func (m *EnvironmentValue) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*EnvironmentValue) DeserializeSecret

func (m *EnvironmentValue) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*EnvironmentValue) SerializeSecret

func (m *EnvironmentValue) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Event

type Event struct {
	bun.BaseModel `bun:"table:events"`

	ID             string                 `bun:",pk,type:varchar(20)"`
	UserID         string                 `bun:"type:varchar(20)"`
	UserHandle     string                 `bun:"type:varchar(255)"`
	UserDisplay    string                 `bun:"type:varchar(255)"`
	ProjectID      string                 `bun:"type:varchar(20)"`
	ProjectDisplay string                 `bun:"type:varchar(255)"`
	ObjectID       string                 `bun:"type:varchar(20)"`
	ObjectDisplay  string                 `bun:"type:varchar(255)"`
	ObjectType     EventType              `bun:"type:varchar(255)"`
	Action         EventAction            `bun:"type:varchar(255)"`
	Attrs          map[string]interface{} `bun:"-"`
	RawAttrs       string                 `bun:"attrs,nullzero,type:text"`
	CreatedAt      time.Time              `bun:",nullzero,notnull,default:current_timestamp"`
}

Event defines the model for events table.

func PrepareEvent

func PrepareEvent(principal *User, event *Event) *Event

PrepareEvent prefills the event model with principal information if available.

func (*Event) AfterScanRow

func (m *Event) AfterScanRow(_ context.Context) error

AfterScanRow implements the bun hook interface.

func (*Event) BeforeAppendModel

func (m *Event) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Event) DeserializeSecret

func (m *Event) DeserializeSecret(_ string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Event) SerializeSecret

func (m *Event) SerializeSecret(_ string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type EventAction

type EventAction string

EventAction defines a custom type for event actions.

const (
	// EventActionCreate defines the action create.
	EventActionCreate EventAction = "create"

	// EventActionUpdate defines the action update.
	EventActionUpdate EventAction = "update"

	// EventActionDelete defines the action delete.
	EventActionDelete EventAction = "delete"
)

type EventType

type EventType string

EventType defines a custom type for event types.

const (
	// EventTypeUser defines event type for users.
	EventTypeUser EventType = "user"

	// EventTypeUserGroup defines event type for user groups.
	EventTypeUserGroup EventType = "user_group"

	// EventTypeUserProject defines event type for user projects.
	EventTypeUserProject EventType = "user_project"

	// EventTypeGroup defines event type for groups.
	EventTypeGroup EventType = "group"

	// EventTypeGroupUser defines event type for group users.
	EventTypeGroupUser EventType = "group_user"

	// EventTypeGroupProject defines event type for group projects.
	EventTypeGroupProject EventType = "group_project"

	// EventTypeProject defines event type for projects.
	EventTypeProject EventType = "project"

	// EventTypeProjectUser defines event type for project users.
	EventTypeProjectUser EventType = "project_user"

	// EventTypeProjectGroup defines event type for project groups.
	EventTypeProjectGroup EventType = "project_group"

	// EventTypeRunner defines event type for runners.
	EventTypeRunner EventType = "runner"

	// EventTypeCredential defines event type for credentials.
	EventTypeCredential EventType = "credential"

	// EventTypeRepository defines event type for repositories.
	EventTypeRepository EventType = "repository"

	// EventTypeInventory defines event type for inventories.
	EventTypeInventory EventType = "inventory"

	// EventTypeEnvironment defines event type for environments.
	EventTypeEnvironment EventType = "environment"

	// EventTypeEnvironmentSecret defines event type for environment secrets.
	EventTypeEnvironmentSecret EventType = "environment_secret"

	// EventTypeEnvironmentValue defines event type for environment vaules.
	EventTypeEnvironmentValue EventType = "environment_value"

	// EventTypeTemplate defines event type for templates.
	EventTypeTemplate EventType = "template"

	// EventTypeTemplateSurvey defines event type for template surveys.
	EventTypeTemplateSurvey EventType = "template_survey"

	// EventTypeTemplateVault defines event type for template vaults.
	EventTypeTemplateVault EventType = "template_vault"

	// EventTypeSchedule defines event type for schedules.
	EventTypeSchedule EventType = "schedule"

	// EventTypeExecution defines event type for executions.
	EventTypeExecution EventType = "execution"

	// EventTypeOutput defines event type for outputs.
	EventTypeOutput EventType = "output"
)

type Execution

type Execution struct {
	bun.BaseModel `bun:"table:executions"`

	ID          string    `bun:",pk,type:varchar(20)"`
	ProjectID   string    `bun:"type:varchar(20)"`
	Project     *Project  `bun:"rel:belongs-to,join:project_id=id"`
	TemplateID  string    `bun:"type:varchar(20)"`
	Template    *Template `bun:"rel:belongs-to,join:template_id=id"`
	Name        string    `bun:"-"`
	Status      string    `bun:"type:varchar(255)"`
	Playbook    string    `bun:"type:varchar(255)"`
	Environment string    `bun:"type:varchar(255)"`
	Secret      string    `bun:"type:varchar(255)"`
	Limit       string    `bun:"type:varchar(255)"`
	Branch      string    `bun:"type:varchar(255)"`
	Debug       bool      `bun:"type:bool"`
	CreatedAt   time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt   time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

Execution defines the model for executions table.

func (*Execution) AfterScanRow

func (m *Execution) AfterScanRow(_ context.Context) error

AfterScanRow implements the bun hook interface.

func (*Execution) BeforeAppendModel

func (m *Execution) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Execution) DeserializeSecret

func (m *Execution) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Execution) SerializeSecret

func (m *Execution) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Group

type Group struct {
	bun.BaseModel `bun:"table:groups"`

	ID        string          `bun:",pk,type:varchar(20)"`
	Scim      string          `bun:"type:varchar(255)"`
	Slug      string          `bun:",unique,type:varchar(255)"`
	Name      string          `bun:"type:varchar(255)"`
	CreatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
	Users     []*UserGroup    `bun:"rel:has-many,join:id=group_id"`
	Projects  []*GroupProject `bun:"rel:has-many,join:id=group_id"`
}

Group defines the model for groups table.

func (*Group) BeforeAppendModel

func (m *Group) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type GroupProject

type GroupProject struct {
	bun.BaseModel `bun:"table:group_projects"`

	GroupID   string    `bun:",pk,type:varchar(20)"`
	Group     *Group    `bun:"rel:belongs-to,join:group_id=id"`
	ProjectID string    `bun:",pk,type:varchar(20)"`
	Project   *Project  `bun:"rel:belongs-to,join:project_id=id"`
	Perm      string    `bun:"type:varchar(32)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

GroupProject defines the model for group_projects table.

func (*GroupProject) BeforeAppendModel

func (m *GroupProject) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type GroupProjectParams

type GroupProjectParams struct {
	ListParams

	GroupID   string
	ProjectID string
	Perm      string
}

GroupProjectParams defines parameters for group projects.

type Inventory

type Inventory struct {
	bun.BaseModel `bun:"table:inventories"`

	ID           string      `bun:",pk,type:varchar(20)"`
	ProjectID    string      `bun:"type:varchar(20)"`
	Project      *Project    `bun:"rel:belongs-to,join:project_id=id"`
	RepositoryID string      `bun:",nullzero,type:varchar(20)"`
	Repository   *Repository `bun:"rel:belongs-to,join:repository_id=id"`
	CredentialID string      `bun:",nullzero,type:varchar(20)"`
	Credential   *Credential `bun:"rel:belongs-to,join:credential_id=id"`
	BecomeID     string      `bun:",nullzero,type:varchar(20)"`
	Become       *Credential `bun:"rel:belongs-to,join:become_id=id"`
	Slug         string      `bun:"type:varchar(255)"`
	Name         string      `bun:"type:varchar(255)"`
	Kind         string      `bun:"type:varchar(255)"`
	Content      string      `bun:"type:text"`
	CreatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
}

Inventory defines the model for inventories table.

func (*Inventory) BeforeAppendModel

func (m *Inventory) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Inventory) DeserializeSecret

func (m *Inventory) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Inventory) SerializeSecret

func (m *Inventory) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type ListParams

type ListParams struct {
	Search string
	Sort   string
	Order  string
	Limit  int64
	Offset int64
}

ListParams defines optional list attributes.

type Output

type Output struct {
	bun.BaseModel `bun:"table:outputs"`

	ID          string     `bun:",pk,type:varchar(20)"`
	ExecutionID string     `bun:"type:varchar(20)"`
	Execution   *Execution `bun:"rel:belongs-to,join:execution_id=id"`
	Content     string     `bun:"type:text"`
	CreatedAt   time.Time  `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt   time.Time  `bun:",nullzero,notnull,default:current_timestamp"`
}

Output defines the model for outputs table.

func (*Output) BeforeAppendModel

func (m *Output) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type Project

type Project struct {
	bun.BaseModel `bun:"table:projects"`

	ID        string          `bun:",pk,type:varchar(20)"`
	Demo      bool            `bun:"-"`
	Slug      string          `bun:",unique,type:varchar(255)"`
	Name      string          `bun:"type:varchar(255)"`
	CreatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time       `bun:",nullzero,notnull,default:current_timestamp"`
	Groups    []*GroupProject `bun:"rel:has-many,join:id=project_id"`
	Users     []*UserProject  `bun:"rel:has-many,join:id=project_id"`
}

Project defines the model for projects table.

func (*Project) BeforeAppendModel

func (m *Project) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type Repository

type Repository struct {
	bun.BaseModel `bun:"table:repositories"`

	ID           string      `bun:",pk,type:varchar(20)"`
	ProjectID    string      `bun:"type:varchar(20)"`
	Project      *Project    `bun:"rel:belongs-to,join:project_id=id"`
	CredentialID string      `bun:"type:varchar(20)"`
	Credential   *Credential `bun:"rel:belongs-to,join:credential_id=id"`
	Slug         string      `bun:"type:varchar(255)"`
	Name         string      `bun:"type:varchar(255)"`
	URL          string      `bun:"type:text"`
	Branch       string      `bun:"type:varchar(255)"`
	CreatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
}

Repository defines the model for repositories table.

func (*Repository) BeforeAppendModel

func (m *Repository) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Repository) DeserializeSecret

func (m *Repository) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Repository) SerializeSecret

func (m *Repository) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Runner

type Runner struct {
	bun.BaseModel `bun:"table:runners"`

	ID        string    `bun:",pk,type:varchar(20)"`
	ProjectID string    `bun:"type:varchar(20)"`
	Project   *Project  `bun:"rel:belongs-to,join:project_id=id"`
	Slug      string    `bun:"type:varchar(255)"`
	Name      string    `bun:"type:varchar(255)"`
	Token     string    `bun:"type:varchar(255)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

Runner defines the model for runners table.

func (*Runner) BeforeAppendModel

func (m *Runner) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Runner) DeserializeSecret

func (m *Runner) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Runner) SerializeSecret

func (m *Runner) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Schedule

type Schedule struct {
	bun.BaseModel `bun:"table:schedules"`

	ID         string    `bun:",pk,type:varchar(20)"`
	ProjectID  string    `bun:"type:varchar(20)"`
	Project    *Project  `bun:"rel:belongs-to,join:project_id=id"`
	TemplateID string    `bun:"type:varchar(20)"`
	Template   *Template `bun:"rel:belongs-to,join:template_id=id"`
	Slug       string    `bun:"type:varchar(255)"`
	Name       string    `bun:"type:varchar(255)"`
	Cron       string    `bun:"type:varchar(255)"`
	Active     bool      `bun:"type:bool"`
	CreatedAt  time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt  time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

Schedule defines the model for schedules table.

func (*Schedule) BeforeAppendModel

func (m *Schedule) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Schedule) DeserializeSecret

func (m *Schedule) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Schedule) SerializeSecret

func (m *Schedule) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type Template

type Template struct {
	bun.BaseModel `bun:"table:templates"`

	ID            string            `bun:",pk,type:varchar(20)"`
	ProjectID     string            `bun:"type:varchar(20)"`
	Project       *Project          `bun:"rel:belongs-to,join:project_id=id"`
	RepositoryID  string            `bun:"type:varchar(20)"`
	Repository    *Repository       `bun:"rel:belongs-to,join:repository_id=id"`
	InventoryID   string            `bun:"type:varchar(20)"`
	Inventory     *Inventory        `bun:"rel:belongs-to,join:inventory_id=id"`
	EnvironmentID string            `bun:"type:varchar(20)"`
	Environment   *Environment      `bun:"rel:belongs-to,join:environment_id=id"`
	Slug          string            `bun:"type:varchar(255)"`
	Name          string            `bun:"type:varchar(255)"`
	Description   string            `bun:"type:text"`
	Playbook      string            `bun:"type:varchar(255)"`
	Arguments     string            `bun:"type:varchar(255)"`
	Limit         string            `bun:"type:varchar(255)"`
	Executor      string            `bun:"type:varchar(255)"`
	Branch        string            `bun:"type:varchar(255)"`
	Override      bool              `bun:"type:bool"`
	CreatedAt     time.Time         `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt     time.Time         `bun:",nullzero,notnull,default:current_timestamp"`
	Surveys       []*TemplateSurvey `bun:"rel:has-many,join:id=template_id"`
	Vaults        []*TemplateVault  `bun:"rel:has-many,join:id=template_id"`
}

Template defines the model for templates table.

func (*Template) BeforeAppendModel

func (m *Template) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*Template) DeserializeSecret

func (m *Template) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*Template) SerializeSecret

func (m *Template) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type TemplateSurvey

type TemplateSurvey struct {
	bun.BaseModel `bun:"table:template_surveys"`

	ID          string           `bun:",pk,type:varchar(20)"`
	TemplateID  string           `bun:"type:varchar(20)"`
	Name        string           `bun:"type:varchar(255)"`
	Title       string           `bun:"type:varchar(255)"`
	Description string           `bun:"type:text"`
	Kind        string           `bun:"type:varchar(255)"`
	Required    bool             `bun:"type:bool"`
	Values      []*TemplateValue `bun:"rel:has-many,join:id=survey_id"`
	CreatedAt   time.Time        `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt   time.Time        `bun:",nullzero,notnull,default:current_timestamp"`
}

TemplateSurvey defines the model for template_surveys table.

func (*TemplateSurvey) BeforeAppendModel

func (m *TemplateSurvey) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*TemplateSurvey) DeserializeSecret

func (m *TemplateSurvey) DeserializeSecret(passphrase string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*TemplateSurvey) SerializeSecret

func (m *TemplateSurvey) SerializeSecret(passphrase string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type TemplateValue

type TemplateValue struct {
	bun.BaseModel `bun:"table:template_values"`

	ID        string    `bun:",pk,type:varchar(20)"`
	SurveyID  string    `bun:"type:varchar(20)"`
	Name      string    `bun:"type:varchar(255)"`
	Value     string    `bun:"type:text"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

TemplateValue defines the model for template:values table.

func (*TemplateValue) BeforeAppendModel

func (m *TemplateValue) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*TemplateValue) DeserializeSecret

func (m *TemplateValue) DeserializeSecret(_ string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*TemplateValue) SerializeSecret

func (m *TemplateValue) SerializeSecret(_ string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type TemplateVault

type TemplateVault struct {
	bun.BaseModel `bun:"table:template_vaults"`

	ID           string      `bun:",pk,type:varchar(20)"`
	TemplateID   string      `bun:"type:varchar(20)"`
	CredentialID string      `bun:",nullzero,type:varchar(20)"`
	Credential   *Credential `bun:"rel:belongs-to,join:credential_id=id"`
	Name         string      `bun:"type:varchar(255)"`
	Kind         string      `bun:"type:varchar(255)"`
	Script       string      `bun:"type:text"`
	CreatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt    time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
}

TemplateVault defines the model for template_vaults table.

func (*TemplateVault) BeforeAppendModel

func (m *TemplateVault) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

func (*TemplateVault) DeserializeSecret

func (m *TemplateVault) DeserializeSecret(_ string) error

DeserializeSecret ensures to decrypt all related secrets stored on the database.

func (*TemplateVault) SerializeSecret

func (m *TemplateVault) SerializeSecret(_ string) error

SerializeSecret ensures to encrypt all related secrets stored on the database.

type User

type User struct {
	bun.BaseModel `bun:"table:users"`

	ID        string         `bun:",pk,type:varchar(20)"`
	Scim      string         `bun:"type:varchar(255)"`
	Username  string         `bun:",unique,type:varchar(255)"`
	Password  string         `bun:"-"`
	Hashword  string         `bun:"type:varchar(255)"`
	Email     string         `bun:"type:varchar(255)"`
	Fullname  string         `bun:"type:varchar(255)"`
	Profile   string         `bun:"-"`
	Active    bool           `bun:"default:false"`
	Admin     bool           `bun:"default:false"`
	CreatedAt time.Time      `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time      `bun:",nullzero,notnull,default:current_timestamp"`
	Auths     []*UserAuth    `bun:"rel:has-many,join:id=user_id"`
	Groups    []*UserGroup   `bun:"rel:has-many,join:id=user_id"`
	Projects  []*UserProject `bun:"rel:has-many,join:id=user_id"`
}

User defines the model for users table.

func (*User) BeforeAppendModel

func (m *User) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserAuth

type UserAuth struct {
	bun.BaseModel `bun:"table:user_auths"`

	ID        string    `bun:",pk,type:varchar(20)"`
	UserID    string    `bun:"type:varchar(20)"`
	User      *User     `bun:"rel:belongs-to,join:user_id=id"`
	Provider  string    `bun:"type:varchar(255)"`
	Ref       string    `bun:"type:varchar(255)"`
	Login     string    `bun:"type:varchar(255)"`
	Email     string    `bun:"type:varchar(255)"`
	Name      string    `bun:"type:varchar(255)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

UserAuth defines the model for user_auths table.

func (*UserAuth) BeforeAppendModel

func (m *UserAuth) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserGroup

type UserGroup struct {
	bun.BaseModel `bun:"table:user_groups"`

	UserID    string    `bun:",pk,type:varchar(20)"`
	User      *User     `bun:"rel:belongs-to,join:user_id=id"`
	GroupID   string    `bun:",pk,type:varchar(20)"`
	Group     *Group    `bun:"rel:belongs-to,join:group_id=id"`
	Perm      string    `bun:"type:varchar(32)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

UserGroup defines the model for user_groups table.

func (*UserGroup) BeforeAppendModel

func (m *UserGroup) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserGroupParams

type UserGroupParams struct {
	ListParams

	UserID  string
	GroupID string
	Perm    string
}

UserGroupParams defines parameters for user groups.

type UserProject

type UserProject struct {
	bun.BaseModel `bun:"table:user_projects"`

	UserID    string    `bun:",pk,type:varchar(20)"`
	User      *User     `bun:"rel:belongs-to,join:user_id=id"`
	ProjectID string    `bun:",pk,type:varchar(20)"`
	Project   *Project  `bun:"rel:belongs-to,join:project_id=id"`
	Perm      string    `bun:"type:varchar(32)"`
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
}

UserProject defines the model for user_projects table.

func (*UserProject) BeforeAppendModel

func (m *UserProject) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserProjectParams

type UserProjectParams struct {
	ListParams

	UserID    string
	ProjectID string
	Perm      string
}

UserProjectParams defines parameters for user projects.

type UserToken

type UserToken struct {
	bun.BaseModel `bun:"table:user_tokens"`

	ID        string        `bun:",pk,type:varchar(20)"`
	UserID    string        `bun:"type:varchar(20)"`
	User      *User         `bun:"rel:belongs-to,join:user_id=id"`
	Kind      UserTokenKind `bun:"type:varchar(128)"`
	Token     string        `bun:",unique,type:varchar(128)"`
	CreatedAt time.Time     `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time     `bun:",nullzero,notnull,default:current_timestamp"`
}

UserToken defines the model for user_tokens table.

func (*UserToken) BeforeAppendModel

func (m *UserToken) BeforeAppendModel(_ context.Context, query bun.Query) error

BeforeAppendModel implements the bun hook interface.

type UserTokenKind

type UserTokenKind string

UserTokenKind is the custom type for kind of tokens.

const (
	// UserTokenKindRedirect defines the kind used for redirects.
	UserTokenKindRedirect UserTokenKind = "redirect"
)

Jump to

Keyboard shortcuts

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