Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v0.1.61 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClickHousePropertyMaxExecutionTime    = "max_execution_time"
	ClickHousePropertyMaxRowsToRead       = "max_rows_to_read"
	ClickHousePropertyMaxBytesToRead      = "max_bytes_to_read"
	ClickHousePropertyMaxMemoryUsage      = "max_memory_usage"
	ClickHousePropertyMaxThreads          = "max_threads"
	ClickHousePropertyReadOverflowMode    = "read_overflow_mode"
	ClickHousePropertyTimeoutOverflowMode = "timeout_overflow_mode"

	ClickHouseDefaultMaxExecutionTime    = "10"
	ClickHouseDefaultMaxRowsToRead       = "1000000"
	ClickHouseDefaultMaxBytesToRead      = "268435456"
	ClickHouseDefaultMaxMemoryUsage      = "536870912"
	ClickHouseDefaultMaxThreads          = "4"
	ClickHouseDefaultReadOverflowMode    = "throw"
	ClickHouseDefaultTimeoutOverflowMode = "throw"
)
View Source
const (
	ConnectionTypeAnthropic      = "anthropic"
	ConnectionTypeAWS            = "aws"
	ConnectionTypeAWSKMS         = "aws_kms"
	ConnectionTypeAzure          = "azure"
	ConnectionTypeAzureDevops    = "azure_devops"
	ConnectionTypeAzureKeyVault  = "azure_key_vault"
	ConnectionTypeClickHouse     = "clickhouse"
	ConnectionTypeDiscord        = "discord"
	ConnectionTypeDynatrace      = "dynatrace"
	ConnectionTypeElasticSearch  = "elasticsearch"
	ConnectionTypeEmail          = "email"
	ConnectionTypeFacet          = "facet"
	ConnectionTypeFolder         = "folder"
	ConnectionTypeGCP            = "google_cloud"
	ConnectionTypeGCPKMS         = "gcp_kms"
	ConnectionTypeGCS            = "gcs"
	ConnectionTypeGemini         = "gemini"
	ConnectionTypeGenericWebhook = "generic_webhook"
	ConnectionTypeGit            = "git"
	ConnectionTypeGithub         = "github"
	ConnectionTypeGitlab         = "gitlab"
	ConnectionTypeGoogleChat     = "google_chat"
	ConnectionTypeHTTP           = "http"
	ConnectionTypeIFTTT          = "ifttt"
	ConnectionTypeJaeger         = "jaeger"
	ConnectionTypeJMeter         = "jmeter"
	ConnectionTypeKubernetes     = "kubernetes"
	ConnectionTypeLDAP           = "ldap"
	ConnectionTypeLocalKMS       = "local_kms"
	ConnectionTypeLoki           = "loki"
	ConnectionTypeMatrix         = "matrix"
	ConnectionTypeMattermost     = "mattermost"
	ConnectionTypeMongo          = "mongo"
	ConnectionTypeMySQL          = "mysql"
	ConnectionTypeNtfy           = "ntfy"
	ConnectionTypeOllama         = "ollama"
	ConnectionTypeOpenAI         = "openai"
	ConnectionTypeOpenTelemetry  = "opentelemetry"
	ConnectionTypeOpenSearch     = "opensearch"
	ConnectionTypeOpsGenie       = "opsgenie"
	ConnectionTypePostgres       = "postgres"
	ConnectionTypePrometheus     = "prometheus"
	ConnectionTypePushbullet     = "pushbullet"
	ConnectionTypePushover       = "pushover"
	ConnectionTypeRedis          = "redis"
	ConnectionTypeSQLite         = "sqlite"
	ConnectionTypeRestic         = "restic"
	ConnectionTypeRocketchat     = "rocketchat"
	ConnectionTypeS3             = "s3"
	ConnectionTypeSFTP           = "sftp"
	ConnectionTypeSlack          = "slack"
	ConnectionTypeSlackWebhook   = "slackwebhook"
	ConnectionTypeSMB            = "smb"
	ConnectionTypeSQLServer      = "sql_server"
	ConnectionTypeTeams          = "teams"
	ConnectionTypeTelegram       = "telegram"
	ConnectionTypeWebhook        = "webhook"
	ConnectionTypeWindows        = "windows"
	ConnectionTypeZulipChat      = "zulip_chat"
)

List of all connection types

View Source
const (
	OpenSearchPropertyPagingMode = "paging_mode"

	OpenSearchPagingModeScroll = "scroll"
	OpenSearchPagingModePIT    = "pit"
)

Variables

This section is empty.

Functions

func ConvertRowToNativeTypes

func ConvertRowToNativeTypes(row map[string]any, columnDef map[string]ColumnType) (map[string]any, map[string]string)

ConvertRowToNativeTypes converts a database row to native go types

func ErrorContext

func ErrorContext(items ...Contextable) []any

func GetIDs

func GetIDs[T DBTable](items ...T) []string

Types

type ABACAttribute

type ABACAttribute struct {
	Connection Connection
}

ABACAttribute is the object passed to authorization checks. Consumers can extend this with their own types.

type AppProperty

type AppProperty struct {
	Name      string     `json:"name,omitempty"`
	Value     string     `json:"value,omitempty"`
	CreatedBy *uuid.UUID `json:"created_by,omitempty"`
	CreatedAt time.Time  `json:"created_at,omitempty" time_format:"postgres_timestamp" gorm:"default:CURRENT_TIMESTAMP()"`
	UpdatedAt time.Time  `json:"updated_at,omitempty" time_format:"postgres_timestamp" gorm:"default:CURRENT_TIMESTAMP()"`
	DeletedAt *time.Time `json:"deleted_at,omitempty" time_format:"postgres_timestamp" gorm:"default:CURRENT_TIMESTAMP()"`
}

func (AppProperty) TableName

func (p AppProperty) TableName() string

type ColumnType

type ColumnType string
const (
	ColumnTypeBoolean  ColumnType = "boolean"
	ColumnTypeDateTime ColumnType = "datetime"
	ColumnTypeDecimal  ColumnType = "decimal"
	ColumnTypeDuration ColumnType = "duration"
	ColumnTypeInteger  ColumnType = "integer"
	ColumnTypeJSONB    ColumnType = "jsonb"
	ColumnTypeString   ColumnType = "string"
)

func (ColumnType) SQLiteType

func (t ColumnType) SQLiteType() string

type Connection

type Connection struct {
	ID          uuid.UUID           `gorm:"primaryKey;unique_index;not null;column:id;default:generate_ulid()" json:"id" faker:"uuid_hyphenated"  `
	Name        string              `gorm:"column:name" json:"name" faker:"name"  `
	Namespace   string              `gorm:"column:namespace" json:"namespace"`
	Source      string              `json:"source"`
	Type        string              `gorm:"column:type" json:"type" faker:"oneof:  postgres, mysql, aws, gcp, http" `
	URL         string              `gorm:"column:url" json:"url,omitempty" faker:"url" template:"true"`
	Username    string              `gorm:"column:username" json:"username,omitempty" faker:"username"  `
	Password    string              `gorm:"column:password" json:"password,omitempty" faker:"password"  `
	Properties  types.JSONStringMap `gorm:"column:properties" json:"properties,omitempty" faker:"-" template:"true"`
	Certificate string              `gorm:"column:certificate" json:"certificate,omitempty" faker:"-"  `
	InsecureTLS bool                `gorm:"column:insecure_tls;default:false" json:"insecure_tls,omitempty" faker:"-"  `
	CreatedAt   time.Time           `gorm:"column:created_at;default:now();<-:create" json:"created_at,omitempty" faker:"-"  `
	UpdatedAt   time.Time           `gorm:"column:updated_at;default:now()" json:"updated_at,omitempty" faker:"-"  `
	CreatedBy   *uuid.UUID          `gorm:"column:created_by" json:"created_by,omitempty" faker:"-"  `
	Virtual     bool                `gorm:"-" json:"virtual,omitempty" faker:"-"`
	ReadOnly    bool                `gorm:"-" json:"read_only,omitempty" faker:"-"`
	ExpiresAt   *time.Time          `gorm:"-" json:"expires_at,omitempty" faker:"-"`
}

func ConnectionFromURL

func ConnectionFromURL(url url.URL) *Connection

func (Connection) AsEnv

func (c Connection) AsEnv(ctx context.Context) EnvPrep

AsEnv generates environment variables and a configuration file content based on the connection type.

func (Connection) AsGoGetterURL

func (c Connection) AsGoGetterURL() (string, error)

AsGoGetterURL returns the connection as a url that's supported by https://github.com/hashicorp/go-getter Connection details are added to the url as query params

func (Connection) AsMap

func (c Connection) AsMap(removeFields ...string) map[string]any

func (*Connection) GetFieldsMatcher

func (c *Connection) GetFieldsMatcher() fields.Fields

func (*Connection) GetHealth

func (c *Connection) GetHealth() (string, error)

func (*Connection) GetID

func (c *Connection) GetID() string

func (*Connection) GetLabelsMatcher

func (c *Connection) GetLabelsMatcher() labels.Labels

func (*Connection) GetName

func (c *Connection) GetName() string

func (*Connection) GetNamespace

func (c *Connection) GetNamespace() string

func (*Connection) GetStatus

func (c *Connection) GetStatus() (string, error)

func (*Connection) GetType

func (c *Connection) GetType() string

func (Connection) Merge

func (c Connection) Merge(ctx types.GetEnvVarFromCache, from any) (*Connection, error)

func (Connection) PK

func (c Connection) PK() string

func (*Connection) SetProperty

func (c *Connection) SetProperty(key, value string)

func (Connection) String

func (c Connection) String() string

func (Connection) TableName

func (c Connection) TableName() string

type Contextable

type Contextable interface {
	Context() map[string]any
}

type DBTable

type DBTable interface {
	PK() string
	TableName() string
}

type Deleteable

type Deleteable interface {
	Delete(db *gorm.DB) error
}

type EnvPrep

type EnvPrep struct {
	// Env is the connection credentials in environment variables
	Env []string

	// CmdEnvs is a list of env vars that will be passed to the command
	CmdEnvs []string

	// List of commands that need to be run before the actual command.
	// These commands will setup the connection.
	PreRuns []*exec.Cmd

	// File contains the content of the configuration file based on the connection
	Files map[string]bytes.Buffer
}

func (*EnvPrep) Inject

func (c *EnvPrep) Inject(ctx context.Context, cmd *exec.Cmd) ([]*exec.Cmd, error)

Inject creates the config file & injects the necessary environment variable into the command

type ExtendedDBTable

type ExtendedDBTable interface {
	DBTable
	Value() any
	PKCols() []clause.Column
}

TODO: Find a better way to handle this

type Health

type Health string
const (
	HealthHealthy   Health = "healthy"
	HealthUnhealthy Health = "unhealthy"
	HealthUnknown   Health = "unknown"
	HealthWarning   Health = "warning"
)

func WorseHealth

func WorseHealth(healths ...Health) Health

type LabelableModel

type LabelableModel interface {
	GetLabels() map[string]string
}

type LogNameAccessor

type LogNameAccessor interface {
	LoggerName() string
}

type LoggingBackend

type LoggingBackend struct {
	ID        uuid.UUID           `json:"id" gorm:"default:generate_ulid()"`
	Name      string              `json:"name"`
	Labels    types.JSONStringMap `json:"labels" gorm:"type:jsonstringmap"`
	Spec      string              `json:"spec,omitempty"`
	Source    string              `json:"source,omitempty"`
	AgentID   *uuid.UUID          `json:"agent_id,omitempty"`
	CreatedAt time.Time           `json:"created_at,omitempty"`
	UpdatedAt time.Time           `json:"updated_at,omitempty"`
	DeletedAt *time.Time          `json:"deleted_at,omitempty"`
}

func (LoggingBackend) PK

func (l LoggingBackend) PK() string

func (LoggingBackend) TableName

func (l LoggingBackend) TableName() string

type NamespaceScopeAccessor

type NamespaceScopeAccessor interface {
	GetNamespace() string
}

type Severity

type Severity string
const (
	SeverityInfo     Severity = "info"
	SeverityLow      Severity = "low"
	SeverityMedium   Severity = "medium"
	SeverityHigh     Severity = "high"
	SeverityCritical Severity = "critical"
)

type TaggableModel

type TaggableModel interface {
	GetTags() map[string]string
}

Jump to

Keyboard shortcuts

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