core

package
v0.0.0-...-ad0c36a Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const IPV4Regex = `^(?:\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b)$`

IPV4Regex : regex for IPv4

Variables

View Source
var DebianDependenciesInstallCommands = map[string]string{
	"init":    "apt -y update",
	"awk":     "apt install -y gawk",
	"curl":    "apt install -y curl",
	"unzip":   "apt install -y unzip",
	"git":     "apt install -y git",
	"tar":     "apt install -y tar",
	"iproute": "apt install -y iproute2",
	"nfs":     "apt install -y nfs-common && systemctl stop rpcbind.socket && systemctl stop rpcbind && systemctl disable rpcbind.socket && systemctl disable rpcbind",
	"cifs":    "apt install -y cifs-utils",
	"rsync":   "apt install -y rsync",
	"docker":  "curl -fsSL get.docker.com | sh -",
}
View Source
var DependencyCheckCommands = map[string]string{
	"init":    "echo hi",
	"awk":     "which awk",
	"curl":    "which curl",
	"unzip":   "which unzip",
	"git":     "which git",
	"tar":     "which tar",
	"iproute": "which ip",
	"nfs":     "which nfsstat",
	"cifs":    "which mount.cifs",
	"rsync":   "which rsync",
	"docker":  "which docker",
}
View Source
var FedoraDependenciesInstallCommands = map[string]string{
	"init":    "dnf -y update",
	"awk":     "dnf install -y gawk",
	"curl":    "dnf install -y curl",
	"unzip":   "dnf install -y unzip",
	"git":     "dnf install -y git",
	"tar":     "dnf install -y tar",
	"iproute": "dnf install -y iproute",
	"nfs":     "dnf install -y nfs-utils && systemctl stop rpcbind.socket && systemctl stop rpcbind && systemctl disable rpcbind.socket && systemctl disable rpcbind",
	"cifs":    "dnf install -y cifs-utils",
	"rsync":   "dnf install -y rsync",
	"docker":  "curl -fsSL get.docker.com | sh -",
}
View Source
var IngressRuleDeletingError = errors.New("ingress rule is deleting")
View Source
var RequiredServerDependencies = []string{
	"init",
	"awk",
	"curl",
	"unzip",
	"git",
	"tar",
	"iproute",
	"nfs",
	"cifs",
	"rsync",
	"docker",
}

Functions

func ChangePassword

func ChangePassword(ctx context.Context, db gorm.DB, username string, oldPassword string, newPassword string) error

ChangePassword : change user password

func ChangeProxyType

func ChangeProxyType(db *gorm.DB, server *Server, proxyType ProxyType) error

ChangeProxyType changes the proxy type of server in the database

func ChangeSSHPort

func ChangeSSHPort(db *gorm.DB, server *Server, newPort int) error

ChangeSSHPort changes the SSH port of a server in the database

func ChangeServerIP

func ChangeServerIP(db *gorm.DB, server *Server, newIp string) error

ChangeServerIP changes the IP of a server in the database

func CreateApplicationServiceResourceStat

func CreateApplicationServiceResourceStat(_ context.Context, db gorm.DB, appStats []*ApplicationServiceResourceStat) error

func CreateServer

func CreateServer(db *gorm.DB, server *Server) error

CreateServer creates a new server in the database

func CreateServerLog

func CreateServerLog(db *gorm.DB, serverLog *ServerLog) error

CreateServerLog is a function to create a new server log in the database.

func DeleteAnalyticsServiceToken

func DeleteAnalyticsServiceToken(ctx context.Context, db gorm.DB, serverId uint) error

func DeleteBuildArgsByDeploymentId

func DeleteBuildArgsByDeploymentId(ctx context.Context, db gorm.DB, deploymentId string) error

func DeleteBuildLogsByDeploymentId

func DeleteBuildLogsByDeploymentId(ctx context.Context, db gorm.DB, deploymentId string) error

func DeleteEnvironmentVariablesByApplicationId

func DeleteEnvironmentVariablesByApplicationId(ctx context.Context, db gorm.DB, applicationId string) error

func DeletePersistentVolumeBackupsByPersistentVolumeId

func DeletePersistentVolumeBackupsByPersistentVolumeId(ctx context.Context, db gorm.DB, persistentVolumeId uint, dataDir string, config system_config.S3BackupConfig) error

func DeletePersistentVolumeBindingsByApplicationId

func DeletePersistentVolumeBindingsByApplicationId(ctx context.Context, db gorm.DB, applicationId string) error

func DeletePersistentVolumeRestoresByPersistentVolumeId

func DeletePersistentVolumeRestoresByPersistentVolumeId(ctx context.Context, db gorm.DB, persistentVolumeId uint, dataDir string) error

func DeleteServer

func DeleteServer(db *gorm.DB, id uint) error

DeleteServer deletes a server from the database

func DeleteUser

func DeleteUser(ctx context.Context, db gorm.DB, id uint) error

DeleteUser : delete user by id

func DisableTotp

func DisableTotp(ctx context.Context, db gorm.DB, username string) error

DisableTotp : disable Totp for user

func FetchAllExposedTCPPorts

func FetchAllExposedTCPPorts(ctx context.Context, db gorm.DB) ([]int, error)

func FetchAllExposedUDPPorts

func FetchAllExposedUDPPorts(ctx context.Context, db gorm.DB) ([]int, error)

func FetchDisabledDeploymentServerHostNames

func FetchDisabledDeploymentServerHostNames(db *gorm.DB) ([]string, error)

FetchDisabledDeploymentServerHostNames fetches the hostnames of all servers that are not in deployment mode

func FetchServerIDByHostName

func FetchServerIDByHostName(db *gorm.DB, hostName string) (uint, error)

FetchServerIDByHostName fetches a server by its hostname from the database

func FetchServerLogContentByID

func FetchServerLogContentByID(db *gorm.DB, id uint) (string, error)

FetchServerLogContentByID is a function to fetch the content of a server log from the database by its id.

func FindCurrentDeployedDeploymentIDByApplicationId

func FindCurrentDeployedDeploymentIDByApplicationId(ctx context.Context, db gorm.DB, id string) (string, error)

func FindLatestDeploymentIDByApplicationId

func FindLatestDeploymentIDByApplicationId(ctx context.Context, db gorm.DB, id string) (string, error)

func IsAnyActiveProxyServerOffline

func IsAnyActiveProxyServerOffline(db *gorm.DB) (bool, error)

IsAnyActiveProxyServerOffline checks if any active proxy server is offline

func IsDeploymentFailed

func IsDeploymentFailed(ctx context.Context, db gorm.DB, id string) (bool, error)

func IsExistApplicationName

func IsExistApplicationName(_ context.Context, db gorm.DB, dockerManager containermanger.Manager, name string) (bool, error)

func IsExistPersistentVolume

func IsExistPersistentVolume(_ context.Context, db gorm.DB, name string, dockerManager containermanger.Manager) (bool, error)

func IsPreparedServerExists

func IsPreparedServerExists(db *gorm.DB) (bool, error)

IsPreparedServerExists checks if a prepared server exists in the database

func MarkServerAsOffline

func MarkServerAsOffline(db *gorm.DB, server *Server) error

MarkServerAsOffline marks a server as offline in the database

func MarkServerAsOnline

func MarkServerAsOnline(db *gorm.DB, server *Server) error

MarkServerAsOnline marks a server as online in the database

func NoOfPreparedServers

func NoOfPreparedServers(db *gorm.DB) (int, error)

NoOfPreparedServers returns the number of prepared servers in the database

func NoOfServers

func NoOfServers(db *gorm.DB) (int, error)

NoOfServers returns the number of servers in the database

func UpdateServer

func UpdateServer(db *gorm.DB, server *Server) error

UpdateServer updates a server in the database

func ValidateAnalyticsServiceToken

func ValidateAnalyticsServiceToken(ctx context.Context, db gorm.DB, id string, token string) (verified bool, serverHostName string, err error)

Types

type AnalyticsServiceToken

type AnalyticsServiceToken struct {
	ID        string    `json:"id" gorm:"primaryKey"`
	Token     string    `json:"token" gorm:"unique"`
	ServerID  uint      `json:"server_id"`
	CreatedAt time.Time `json:"created_at"`
}

func FetchAnalyticsServiceToken

func FetchAnalyticsServiceToken(ctx context.Context, db gorm.DB, serverId uint) (*AnalyticsServiceToken, error)

func RotateAnalyticsServiceToken

func RotateAnalyticsServiceToken(ctx context.Context, db gorm.DB, serverId uint) (*AnalyticsServiceToken, error)

RotateAnalyticsServiceToken : delete existing token and create a new token. [Recommended to use transaction]

func (*AnalyticsServiceToken) IDToken

func (token *AnalyticsServiceToken) IDToken() (string, error)

type AppBasicAuthAccessControlList

type AppBasicAuthAccessControlList struct {
	ID            uint                            `json:"id" gorm:"primaryKey"`
	Name          string                          `json:"name"`
	GeneratedName string                          `json:"generated_name" gorm:"unique"`
	Users         []AppBasicAuthAccessControlUser `json:"users" gorm:"foreignKey:AppBasicAuthAccessControlListID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	IngressRules  []IngressRule                   `json:"ingress_rules" gorm:"foreignKey:AppBasicAuthAccessControlListID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func FindAllAppBasicAuthAccessControlLists

func FindAllAppBasicAuthAccessControlLists(_ context.Context, db *gorm.DB) ([]*AppBasicAuthAccessControlList, error)

func (*AppBasicAuthAccessControlList) Create

func (*AppBasicAuthAccessControlList) Delete

func (*AppBasicAuthAccessControlList) FindById

func (l *AppBasicAuthAccessControlList) FindById(_ context.Context, db *gorm.DB, id uint) error

type AppBasicAuthAccessControlUser

type AppBasicAuthAccessControlUser struct {
	ID                              uint   `json:"id" gorm:"primaryKey"`
	Username                        string `json:"username"`
	PlainTextPassword               string `gorm:"-"`
	EncryptedPassword               string `json:"encrypted_password"`
	AppBasicAuthAccessControlListID uint   `json:"app_basic_auth_access_control_list_id"`
}

func FetchAppBasicAuthAccessControlUsers

func FetchAppBasicAuthAccessControlUsers(_ context.Context, db *gorm.DB, appBasicAuthAccessControlListID uint) ([]*AppBasicAuthAccessControlUser, error)

func (*AppBasicAuthAccessControlUser) Create

func (*AppBasicAuthAccessControlUser) Delete

func (*AppBasicAuthAccessControlUser) FindById

func (u *AppBasicAuthAccessControlUser) FindById(_ context.Context, db *gorm.DB, id uint) error

func (*AppBasicAuthAccessControlUser) Update

type Application

type Application struct {
	ID   string `json:"id" gorm:"primaryKey"`
	Name string `json:"name" gorm:"unique"`
	// ApplicationGroupID - if set, this application will be part of the application group
	ApplicationGroupID *string `json:"application_group_id"`
	// Environment Variables
	// On change of environment variables, deployment will be triggered by force update
	EnvironmentVariables []EnvironmentVariable `json:"environment_variables" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// Config Mounts
	// On change of config mounts, deployment will be triggered by force update
	ConfigMounts []ConfigMount `json:"config_mounts" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// Persistent Volumes
	// On change of persistent volumes, deployment will be triggered by force update
	PersistentVolumeBindings []PersistentVolumeBinding `json:"persistent_volume_bindings" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// No of replicas to be deployed
	DeploymentMode DeploymentMode `json:"deployment_mode"`
	Replicas       uint           `json:"replicas"`
	// Deployments
	Deployments []Deployment `json:"deployments" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// Latest Deployment
	LatestDeployment Deployment `json:"-"`
	// Ingress Rules
	IngressRules []IngressRule `json:"ingress_rules" gorm:"foreignKey:ApplicationID"`
	// Command
	Command string `json:"command"`
	// Capabilities
	Capabilities pq.StringArray `json:"capabilities" gorm:"type:text[]"`
	// Sysctls
	Sysctls pq.StringArray `json:"sysctls" gorm:"type:text[]"`
	// Resource Limit
	ResourceLimit ApplicationResourceLimit `json:"resource_limit" gorm:"embedded;embeddedPrefix:resource_limit_"`
	// Reserved Resource
	ReservedResource ApplicationReservedResource `json:"reserved_resource" gorm:"embedded;embeddedPrefix:reserved_resource_"`
	// ConsoleTokens
	ConsoleTokens []ConsoleToken `json:"console_tokens" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// Is deleted - soft delete - will be deleted from database in background
	IsDeleted bool `json:"is_deleted" gorm:"default:false"`
	// Webhook token
	WebhookToken string `json:"webhook_token"`
	// Sleeping
	IsSleeping bool `json:"is_sleeping" gorm:"default:false"`
	// Resource Stats
	ResourceStats []ApplicationServiceResourceStat `json:"resource_stats" gorm:"foreignKey:ApplicationID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// PreferredServerHostnames - if set, we will schedule deployments to this server
	PreferredServerHostnames pq.StringArray `json:"preferred_server_hostnames" gorm:"type:text[]"`
	// CustomHealthCheck - if set, we will use this custom health check
	CustomHealthCheck ApplicationCustomHealthCheck `json:"custom_health_check" gorm:"embedded;embeddedPrefix:custom_health_check_"`
	// DockerProxy configuration
	DockerProxy DockerProxyConfig `json:"docker_proxy" gorm:"embedded;embeddedPrefix:docker_proxy_"`
}

Application hold information about application

func FindAllApplications

func FindAllApplications(_ context.Context, db gorm.DB, includeGroupedApplications bool) ([]*Application, error)

func FindApplicationsByApplicationGroupID

func FindApplicationsByApplicationGroupID(_ context.Context, db gorm.DB, groupId string) ([]*Application, error)

func (*Application) Create

func (application *Application) Create(ctx context.Context, db gorm.DB, dockerManager containermanger.Manager, codeTarballDir string) error

func (*Application) DockerProxyServiceName

func (application *Application) DockerProxyServiceName() string

func (*Application) FindById

func (application *Application) FindById(_ context.Context, db gorm.DB, id string) error

func (*Application) FindByName

func (application *Application) FindByName(_ context.Context, db gorm.DB, name string) error

func (*Application) HardDelete

func (application *Application) HardDelete(ctx context.Context, db gorm.DB, _ containermanger.Manager) error

func (*Application) IsApplicationDeleted

func (application *Application) IsApplicationDeleted(_ context.Context, db gorm.DB) (bool, error)

func (*Application) MarkAsSleeping

func (application *Application) MarkAsSleeping(ctx context.Context, db gorm.DB) error

func (*Application) MarkAsWake

func (application *Application) MarkAsWake(ctx context.Context, db gorm.DB) error

func (*Application) RebuildApplication

func (application *Application) RebuildApplication(ctx context.Context, db gorm.DB) (deploymentId string, error error)

func (*Application) RegenerateWebhookToken

func (application *Application) RegenerateWebhookToken(ctx context.Context, db gorm.DB) error

func (*Application) ReplicaCount

func (application *Application) ReplicaCount() uint

ReplicaCount : get replica count

func (*Application) SoftDelete

func (application *Application) SoftDelete(ctx context.Context, db gorm.DB, _ containermanger.Manager) error

func (*Application) Update

func (*Application) UpdateGroup

func (application *Application) UpdateGroup(ctx context.Context, db gorm.DB, groupId *string) error

type ApplicationCustomHealthCheck

type ApplicationCustomHealthCheck struct {
	Enabled              bool   `json:"enabled" gorm:"default:false"`
	TestCommand          string `json:"test_command"`
	IntervalSeconds      uint64 `json:"interval_seconds" gorm:"default:10"`      // Time between running the check in seconds
	TimeoutSeconds       uint64 `json:"timeout_seconds" gorm:"default:5"`        // Maximum time to allow one check to run in seconds
	StartPeriodSeconds   uint64 `json:"start_period_seconds" gorm:"default:5"`   // Start period for the container to initialize before counting retries towards unstable
	StartIntervalSeconds uint64 `json:"start_interval_seconds" gorm:"default:5"` // Time between running the check during the start period
	Retries              uint64 `json:"retries" gorm:"default:0"`                // Consecutive failures needed to report unhealthy
}

func (*ApplicationCustomHealthCheck) Equal

type ApplicationDeploymentInfo

type ApplicationDeploymentInfo struct {
	ApplicationID string
	DeploymentID  string
}

func FindApplicationsForForceUpdate

func FindApplicationsForForceUpdate(_ context.Context, db gorm.DB) ([]*ApplicationDeploymentInfo, error)

type ApplicationGroup

type ApplicationGroup struct {
	ID           string        `json:"id" gorm:"primaryKey"`
	Name         string        `json:"name"`
	StackContent string        `json:"stack_content"`
	Applications []Application `json:"applications" gorm:"foreignKey:ApplicationGroupID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

ApplicationGroup hold information about application-group

func FindAllApplicationGroups

func FindAllApplicationGroups(_ context.Context, db gorm.DB) ([]*ApplicationGroup, error)

func (*ApplicationGroup) Create

func (applicationGroup *ApplicationGroup) Create(_ context.Context, db gorm.DB) error

func (*ApplicationGroup) Delete

func (applicationGroup *ApplicationGroup) Delete(_ context.Context, db gorm.DB) error

func (*ApplicationGroup) FindById

func (applicationGroup *ApplicationGroup) FindById(ctx context.Context, db gorm.DB, id string) error

func (*ApplicationGroup) IsAnyApplicationAssociatedWithGroup

func (applicationGroup *ApplicationGroup) IsAnyApplicationAssociatedWithGroup(ctx context.Context, db gorm.DB) (bool, error)

type ApplicationReservedResource

type ApplicationReservedResource struct {
	MemoryMB int `json:"memory_mb" gorm:"default:0"`
}

type ApplicationResourceLimit

type ApplicationResourceLimit struct {
	MemoryMB int `json:"memory_mb" gorm:"default:0"`
}

type ApplicationServiceNetStat

type ApplicationServiceNetStat struct {
	SentKB   uint64 `json:"sent_kb"`
	RecvKB   uint64 `json:"recv_kb"`
	SentKBPS uint64 `json:"sent_kbps"`
	RecvKBPS uint64 `json:"recv_kbps"`
}

type ApplicationServiceResourceStat

type ApplicationServiceResourceStat struct {
	ID                   uint                      `json:"id" gorm:"primaryKey"`
	ApplicationID        string                    `json:"application_id"`
	ServiceCpuTime       uint64                    `json:"service_cpu_time"`
	SystemCpuTime        uint64                    `json:"system_cpu_time"`
	CpuUsagePercent      uint8                     `json:"cpu_used_percent"`
	ReportingServerCount uint                      `json:"reporting_server_count"` // to help in calculating average
	UsedMemoryMB         uint64                    `json:"used_memory_mb"`
	NetStat              ApplicationServiceNetStat `json:"network" gorm:"embedded;embeddedPrefix:network_"`
	RecordedAt           time.Time                 `json:"recorded_at"`
}

ApplicationServiceResourceStat struct to hold service resource stats

func FetchApplicationServiceResourceAnalytics

func FetchApplicationServiceResourceAnalytics(_ context.Context, db gorm.DB, applicationId string, tillTime uint) ([]*ApplicationServiceResourceStat, error)

FetchApplicationServiceResourceAnalytics fetches the application service resource analytics

type ApplicationUpdateResult

type ApplicationUpdateResult struct {
	RebuildRequired bool
	ReloadRequired  bool
	DeploymentId    string
}

ApplicationUpdateResult : result of application update

type BackupStatus

type BackupStatus string

BackupStatus : status of backup

const (
	BackupPending BackupStatus = "pending"
	BackupFailed  BackupStatus = "failed"
	BackupSuccess BackupStatus = "success"
)

type BackupType

type BackupType string

BackupType : type of backup

const (
	LocalBackup BackupType = "local"
	S3Backup    BackupType = "s3"
)

type BuildArg

type BuildArg struct {
	ID           uint   `json:"id" gorm:"primaryKey"`
	DeploymentID string `json:"deployment_id"`
	Key          string `json:"key"`
	Value        string `json:"value"`
}

BuildArg hold information about build args

func FindBuildArgsByDeploymentId

func FindBuildArgsByDeploymentId(ctx context.Context, db gorm.DB, deploymentId string) ([]*BuildArg, error)

type CIFSConfig

type CIFSConfig struct {
	Share    string `json:"share"`
	Host     string `json:"host"`
	Username string `json:"username"`
	Password string `json:"password"`
	FileMode string `json:"file_mode"`
	DirMode  string `json:"dir_mode"`
	Uid      int    `json:"uid" gorm:"default:0"`
	Gid      int    `json:"gid" gorm:"default:0"`
}

CIFSConfig : configuration for CIFS Storage

type ConfigMount

type ConfigMount struct {
	ID            uint   `json:"id" gorm:"primaryKey"`
	ApplicationID string `json:"application_id"`
	ConfigID      string `json:"config_id"`
	Content       string `json:"content"`
	MountingPath  string `json:"mounting_path"`
	Uid           uint   `json:"uid" gorm:"default:0"`
	Gid           uint   `json:"gid" gorm:"default:0"`
	FileMode      uint   `json:"file_mode" gorm:"default:444"`
}

ConfigMount hold information of config mount

func FindConfigMountsByApplicationId

func FindConfigMountsByApplicationId(_ context.Context, db gorm.DB, applicationId string) ([]*ConfigMount, error)

func (*ConfigMount) Create

func (c *ConfigMount) Create(_ context.Context, db gorm.DB) error

func (*ConfigMount) Delete

func (c *ConfigMount) Delete(_ context.Context, db gorm.DB) error

func (*ConfigMount) Update

func (c *ConfigMount) Update(_ context.Context, db gorm.DB) error

func (*ConfigMount) UpdateConfigID

func (c *ConfigMount) UpdateConfigID(_ context.Context, db gorm.DB, configID string) error

type ConsoleTarget

type ConsoleTarget string

ConsoleTarget : type of console target

const (
	ConsoleTargetTypeServer      ConsoleTarget = "server"
	ConsoleTargetTypeApplication ConsoleTarget = "application"
)

type ConsoleToken

type ConsoleToken struct {
	ID            string        `json:"id" gorm:"primaryKey"`
	Target        ConsoleTarget `json:"target_type"`
	ServerID      *uint         `json:"server_id"`
	ApplicationID *string       `json:"application_id"`
	Token         string        `json:"token" gorm:"unique"`
	ExpiresAt     time.Time     `json:"expires_at"`
}

ConsoleToken hold information about console auth tokens, used in establishing websocket connection Note this If Target == ConsoleTargetTypeServer, ServerID denote which server to ssh into If Target == ConsoleTargetTypeApplication, ApplicationID denote which application to connect to and ServerID denote which server to connect to. In case of ConsoleTargetTypeApplication, we will connect to ServerID and try to ssh into the application container If ServerID server has no container for the application, we will return error

func FindConsoleToken

func FindConsoleToken(db gorm.DB, id string, token string) (*ConsoleToken, error)

func GenerateConsoleTokenForApplication

func GenerateConsoleTokenForApplication(db gorm.DB, applicationId string, targetServerId uint) (*ConsoleToken, error)

func GenerateConsoleTokenForServer

func GenerateConsoleTokenForServer(db gorm.DB, serverId uint) (*ConsoleToken, error)

type Deployment

type Deployment struct {
	ID            string       `json:"id" gorm:"primaryKey"`
	ApplicationID string       `json:"application_id"`
	UpstreamType  UpstreamType `json:"upstream_type"`
	// Fields for UpstreamType = Git
	GitCredentialID  *uint   `json:"git_credential_id"`
	GitProvider      string  `json:"git_provider"`
	GitType          GitType `json:"git_type" gorm:"default:'http'"`
	RepositoryOwner  string  `json:"repository_owner"`
	RepositoryName   string  `json:"repository_name"`
	RepositoryBranch string  `json:"repository_branch"`
	GitEndpoint      string  `json:"git_endpoint"`
	GitSshUser       string  `json:"git_ssh_user"`
	CodePath         string  `json:"code_path"`
	CommitHash       string  `json:"commit_hash"`
	CommitMessage    string  `json:"commit_message"`
	// Fields for UpstreamType = SourceCode
	SourceCodeCompressedFileName string `json:"source_code_compressed_file_name"`
	// Fields for UpstreamType = Image
	DockerImage               string `json:"docker_image"`
	ImageRegistryCredentialID *uint  `json:"image_registry_credential_id"`
	// Common Fields
	BuildArgs  []BuildArg `json:"build_args" gorm:"foreignKey:DeploymentID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Dockerfile string     `json:"dockerfile"`
	// Logs
	Logs []DeploymentLog `json:"logs" gorm:"foreignKey:DeploymentID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	// Deployment Status
	Status DeploymentStatus `json:"status"`
	// Created At
	CreatedAt time.Time `json:"created_at"`
}

Deployment hold information about deployment of application

func FindCurrentDeployedDeploymentByApplicationId

func FindCurrentDeployedDeploymentByApplicationId(ctx context.Context, db gorm.DB, id string) (*Deployment, error)

func FindDeploymentsByApplicationId

func FindDeploymentsByApplicationId(ctx context.Context, db gorm.DB, id string) ([]*Deployment, error)

func FindDeploymentsByGitCredentialId

func FindDeploymentsByGitCredentialId(ctx context.Context, db gorm.DB, id uint) ([]*Deployment, error)

func FindDeploymentsByImageRegistryCredentialId

func FindDeploymentsByImageRegistryCredentialId(ctx context.Context, db gorm.DB, id uint) ([]*Deployment, error)

func FindLatestDeploymentByApplicationId

func FindLatestDeploymentByApplicationId(ctx context.Context, db gorm.DB, id string) (*Deployment, error)

func (*Deployment) Create

func (deployment *Deployment) Create(ctx context.Context, db gorm.DB) error

func (*Deployment) Delete

func (deployment *Deployment) Delete(ctx context.Context, db gorm.DB) error

func (*Deployment) DeployableDockerImageURI

func (deployment *Deployment) DeployableDockerImageURI(remoteRegistryPrefix string) string

func (*Deployment) FindById

func (deployment *Deployment) FindById(ctx context.Context, db gorm.DB, id string) error

func (*Deployment) GitRepositoryURL

func (deployment *Deployment) GitRepositoryURL() string

func (*Deployment) Update

func (deployment *Deployment) Update(ctx context.Context, db gorm.DB) (*DeploymentUpdateResult, error)

Update : it will works like a total ledger always recreate deployment, no update [except status] fetch latest deployment the `deployment` object seem to be updated by the caller and ID should be the old one

func (*Deployment) UpdateStatus

func (deployment *Deployment) UpdateStatus(ctx context.Context, db gorm.DB, status DeploymentStatus) error

type DeploymentLog

type DeploymentLog struct {
	ID           uint      `json:"id" gorm:"primaryKey"`
	DeploymentID string    `json:"deployment_id"`
	Content      string    `json:"content"`
	CreatedAt    time.Time `json:"created_at"`
}

DeploymentLog hold logs of deployment

func FindAllDeploymentLogsByDeploymentId

func FindAllDeploymentLogsByDeploymentId(ctx context.Context, db gorm.DB, id string) ([]DeploymentLog, error)

type DeploymentMode

type DeploymentMode string

DeploymentMode : mode of deployment of application (replicated or global)

const (
	DeploymentModeReplicated DeploymentMode = "replicated"
	DeploymentModeGlobal     DeploymentMode = "global"
)

type DeploymentStatus

type DeploymentStatus string

DeploymentStatus : status of the deployment

const (
	DeploymentStatusPending       DeploymentStatus = "pending"
	DeploymentStatusDeployPending DeploymentStatus = "deployPending"
	DeploymentStatusDeployed      DeploymentStatus = "deployed"
	DeploymentStatusStopped       DeploymentStatus = "stopped"
	DeploymentStatusFailed        DeploymentStatus = "failed"
	DeploymentStalled             DeploymentStatus = "stalled"
)

func FindDeploymentStatusByID

func FindDeploymentStatusByID(ctx context.Context, db gorm.DB, id string) (*DeploymentStatus, error)

type DeploymentUpdateResult

type DeploymentUpdateResult struct {
	RebuildRequired bool
	DeploymentId    string
}

DeploymentUpdateResult : result of deployment update

type DockerProxyConfig

type DockerProxyConfig struct {
	Enabled    bool                  `json:"enabled" gorm:"default:false"`
	Permission DockerProxyPermission `json:"permissions" gorm:"embedded;embeddedPrefix:permission_"`
}

func (*DockerProxyConfig) Equal

func (d *DockerProxyConfig) Equal(other *DockerProxyConfig) bool

type DockerProxyPermission

type DockerProxyPermission struct {
	Ping         DockerProxyPermissionType `json:"ping" gorm:"default:read"`
	Version      DockerProxyPermissionType `json:"version" gorm:"default:none"`
	Info         DockerProxyPermissionType `json:"info" gorm:"default:none"`
	Events       DockerProxyPermissionType `json:"events" gorm:"default:none"`
	Auth         DockerProxyPermissionType `json:"auth" gorm:"default:none"`
	Secrets      DockerProxyPermissionType `json:"secrets" gorm:"default:none"`
	Build        DockerProxyPermissionType `json:"build" gorm:"default:none"`
	Commit       DockerProxyPermissionType `json:"commit" gorm:"default:none"`
	Configs      DockerProxyPermissionType `json:"configs" gorm:"default:none"`
	Containers   DockerProxyPermissionType `json:"containers" gorm:"default:none"`
	Distribution DockerProxyPermissionType `json:"distribution" gorm:"default:none"`
	Exec         DockerProxyPermissionType `json:"exec" gorm:"default:none"`
	Grpc         DockerProxyPermissionType `json:"grpc" gorm:"default:none"`
	Images       DockerProxyPermissionType `json:"images" gorm:"default:none"`
	Networks     DockerProxyPermissionType `json:"networks" gorm:"default:none"`
	Nodes        DockerProxyPermissionType `json:"nodes" gorm:"default:none"`
	Plugins      DockerProxyPermissionType `json:"plugins" gorm:"default:none"`
	Services     DockerProxyPermissionType `json:"services" gorm:"default:none"`
	Session      DockerProxyPermissionType `json:"session" gorm:"default:none"`
	Swarm        DockerProxyPermissionType `json:"swarm" gorm:"default:none"`
	System       DockerProxyPermissionType `json:"system" gorm:"default:none"`
	Tasks        DockerProxyPermissionType `json:"tasks" gorm:"default:none"`
	Volumes      DockerProxyPermissionType `json:"volumes" gorm:"default:none"`
}

type DockerProxyPermissionType

type DockerProxyPermissionType string
const (
	// DockerProxyNoPermission no request will be allowed
	DockerProxyNoPermission DockerProxyPermissionType = "none"
	// DockerProxyReadPermission only [GET, HEAD] requests will be allowed
	DockerProxyReadPermission DockerProxyPermissionType = "read"
	// DockerProxyReadWritePermission all requests will be allowed [GET, HEAD, POST, PUT, DELETE, OPTIONS]
	DockerProxyReadWritePermission DockerProxyPermissionType = "read_write"
)

type Domain

type Domain struct {
	ID            uint            `json:"id" gorm:"primaryKey"`
	Name          string          `json:"name" gorm:"unique"`
	SSLStatus     DomainSSLStatus `json:"ssl_status"`
	SSLPrivateKey string          `json:"ssl_private_key"`
	SSLFullChain  string          `json:"ssl_full_chain"`
	SSLIssuedAt   time.Time       `json:"ssl_issued_at"`
	SSLExpiredAt  time.Time       `json:"ssl_expired_at"`
	SSLIssuer     string          `json:"ssl_issuer"`
	SslAutoRenew  bool            `json:"ssl_auto_renew" gorm:"default:false"`
	IngressRules  []IngressRule   `json:"ingress_rules" gorm:"foreignKey:DomainID"`
	RedirectRules []RedirectRule  `json:"redirect_rules" gorm:"foreignKey:DomainID"`
}

Domain hold information about domain

func FetchDomainsThoseWillExpire

func FetchDomainsThoseWillExpire(_ context.Context, db gorm.DB, daysToExpire int) ([]*Domain, error)

func FindAllDomains

func FindAllDomains(_ context.Context, db gorm.DB) ([]*Domain, error)

func (*Domain) Create

func (domain *Domain) Create(_ context.Context, db gorm.DB) error

func (*Domain) Delete

func (domain *Domain) Delete(_ context.Context, db gorm.DB) error

func (*Domain) FindById

func (domain *Domain) FindById(_ context.Context, db gorm.DB, id uint) error

func (*Domain) IsIPv4

func (domain *Domain) IsIPv4() bool

IsIPv4 : check if the domain is IPv4

func (*Domain) Update

func (domain *Domain) Update(_ context.Context, db gorm.DB) error

func (*Domain) UpdateSSLStatus

func (domain *Domain) UpdateSSLStatus(_ context.Context, db gorm.DB, status DomainSSLStatus) error

type DomainSSLStatus

type DomainSSLStatus string

DomainSSLStatus : status of the ssl certificate for a domain

const (
	DomainSSLStatusNone    DomainSSLStatus = "none"
	DomainSSLStatusPending DomainSSLStatus = "pending"
	DomainSSLStatusFailed  DomainSSLStatus = "failed"
	DomainSSLStatusIssued  DomainSSLStatus = "issued"
)

type EnvironmentVariable

type EnvironmentVariable struct {
	ID            uint   `json:"id" gorm:"primaryKey"`
	ApplicationID string `json:"application_id"`
	Key           string `json:"key"`
	Value         string `json:"value"`
}

EnvironmentVariable hold information about environment variable

func FindEnvironmentVariablesByApplicationId

func FindEnvironmentVariablesByApplicationId(ctx context.Context, db gorm.DB, applicationId string) ([]*EnvironmentVariable, error)

func (*EnvironmentVariable) Create

func (e *EnvironmentVariable) Create(ctx context.Context, db gorm.DB) error

func (*EnvironmentVariable) Delete

func (e *EnvironmentVariable) Delete(ctx context.Context, db gorm.DB) error

func (*EnvironmentVariable) Update

func (e *EnvironmentVariable) Update(ctx context.Context, db gorm.DB) error

type GitCredential

type GitCredential struct {
	ID            uint    `json:"id" gorm:"primaryKey"`
	Name          string  `json:"name"`
	Type          GitType `json:"type" gorm:"default:'http'"`
	Username      string  `json:"username"`
	Password      string  `json:"password"`
	SshPrivateKey string  `json:"ssh_private_key"`
	SshPublicKey  string  `json:"ssh_public_key"`

	Deployments []Deployment `json:"deployments" gorm:"foreignKey:GitCredentialID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" `
}

GitCredential credential for git client

func FindAllGitCredentials

func FindAllGitCredentials(ctx context.Context, db gorm.DB) ([]*GitCredential, error)

func (*GitCredential) Create

func (gitCredential *GitCredential) Create(ctx context.Context, db gorm.DB) error

func (*GitCredential) Delete

func (gitCredential *GitCredential) Delete(ctx context.Context, db gorm.DB) error

func (*GitCredential) FindById

func (gitCredential *GitCredential) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*GitCredential) Update

func (gitCredential *GitCredential) Update(ctx context.Context, db gorm.DB) error

type GitType

type GitType string

GitType type of git credential

const (
	GitHttp GitType = "http"
	GitSsh  GitType = "ssh"
)

type ImageRegistryCredential

type ImageRegistryCredential struct {
	ID          uint         `json:"id" gorm:"primaryKey"`
	Url         string       `json:"url"`
	Username    string       `json:"username"`
	Password    string       `json:"password"`
	Deployments []Deployment `json:"deployments" gorm:"foreignKey:ImageRegistryCredentialID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

ImageRegistryCredential credential for docker image registry

func FindAllImageRegistryCredentials

func FindAllImageRegistryCredentials(ctx context.Context, db gorm.DB) ([]*ImageRegistryCredential, error)

func (*ImageRegistryCredential) Create

func (imageRegistryCredential *ImageRegistryCredential) Create(ctx context.Context, db gorm.DB) error

func (*ImageRegistryCredential) Delete

func (imageRegistryCredential *ImageRegistryCredential) Delete(ctx context.Context, db gorm.DB) error

func (*ImageRegistryCredential) FindById

func (imageRegistryCredential *ImageRegistryCredential) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*ImageRegistryCredential) Update

func (imageRegistryCredential *ImageRegistryCredential) Update(ctx context.Context, db gorm.DB) error

type IngressRule

type IngressRule struct {
	ID              uint                      `json:"id" gorm:"primaryKey"`
	DomainID        *uint                     `json:"domain_id,omitempty" gorm:"default:null"`
	Protocol        ProtocolType              `json:"protocol"`
	Port            uint                      `json:"port"`        // external port
	TargetPort      uint                      `json:"target_port"` // port of the application
	TargetType      IngressRuleTargetType     `json:"target_type" gorm:"default:'application'"`
	ApplicationID   *string                   `json:"application_id"`
	ExternalService string                    `json:"external_service"`
	HttpsRedirect   bool                      `json:"https_redirect" gorm:"default:false"`
	Authentication  IngressRuleAuthentication `json:"authentication" gorm:"embedded;embeddedPrefix:authentication_"`
	Status          IngressRuleStatus         `json:"status"`
	CreatedAt       time.Time                 `json:"created_at"`
	UpdatedAt       time.Time                 `json:"updated_at"`
}

IngressRule hold information about Ingress rule for service

func FetchIngressRulesWithTargetPortAndProtocolOnly

func FetchIngressRulesWithTargetPortAndProtocolOnly(ctx context.Context, db gorm.DB, applicationId string) ([]*IngressRule, error)

func FindAllIngressRules

func FindAllIngressRules(ctx context.Context, db gorm.DB) ([]*IngressRule, error)

func FindIngressRulesByApplicationID

func FindIngressRulesByApplicationID(ctx context.Context, db gorm.DB, applicationID string) ([]*IngressRule, error)

func FindIngressRulesByDomainID

func FindIngressRulesByDomainID(ctx context.Context, db gorm.DB, domainID uint) ([]*IngressRule, error)

func (*IngressRule) Create

func (ingressRule *IngressRule) Create(ctx context.Context, db gorm.DB, restrictedPorts []int) error

func (*IngressRule) Delete

func (ingressRule *IngressRule) Delete(ctx context.Context, db gorm.DB, force bool) error

func (*IngressRule) DisableAuthentication

func (ingressRule *IngressRule) DisableAuthentication(ctx context.Context, db gorm.DB) error

func (*IngressRule) FindById

func (ingressRule *IngressRule) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*IngressRule) IsValidNewIngressRule

func (ingressRule *IngressRule) IsValidNewIngressRule(ctx context.Context, db gorm.DB, restrictedPorts []int) error

func (*IngressRule) ProtectUsingBasicAuth

func (ingressRule *IngressRule) ProtectUsingBasicAuth(ctx context.Context, db gorm.DB, appBasicAuthAccessControlListID uint) error

func (*IngressRule) Update

func (ingressRule *IngressRule) Update(ctx context.Context, db gorm.DB) error

func (*IngressRule) UpdateHttpsRedirectStatus

func (ingressRule *IngressRule) UpdateHttpsRedirectStatus(ctx context.Context, db gorm.DB, enabled bool) error

func (*IngressRule) UpdateStatus

func (ingressRule *IngressRule) UpdateStatus(ctx context.Context, db gorm.DB, status IngressRuleStatus) error

func (*IngressRule) ValidateForHttpsRedirectEnableRequest

func (ingressRule *IngressRule) ValidateForHttpsRedirectEnableRequest(ctx context.Context, db gorm.DB) (bool, error)

type IngressRuleAuthentication

type IngressRuleAuthentication struct {
	AuthType                        IngressRuleAuthenticationType `json:"auth_type" gorm:"default:'none'"`
	AppBasicAuthAccessControlListID *uint                         `json:"app_basic_auth_access_control_list_id" gorm:"default:null"`
}

IngressRuleAuthentication hold information about ingress rule authentication

type IngressRuleAuthenticationType

type IngressRuleAuthenticationType string

IngressRuleAuthenticationType type of authentication for ingress rule

const (
	IngressRuleNoAuthentication    IngressRuleAuthenticationType = "none"
	IngressRuleBasicAuthentication IngressRuleAuthenticationType = "basic"
)

type IngressRuleStatus

type IngressRuleStatus string

IngressRuleStatus : status of the ingress rule

const (
	IngressRuleStatusPending  IngressRuleStatus = "pending"
	IngressRuleStatusApplied  IngressRuleStatus = "applied"
	IngressRuleStatusFailed   IngressRuleStatus = "failed"
	IngressRuleStatusDeleting IngressRuleStatus = "deleting"
)

type IngressRuleTargetType

type IngressRuleTargetType string

IngressRuleTargetType : type of target for ingress rule

const (
	ApplicationIngressRule     IngressRuleTargetType = "application"
	ExternalServiceIngressRule IngressRuleTargetType = "externalService"
)

type NFSConfig

type NFSConfig struct {
	Host    string `json:"host,omitempty"`
	Path    string `json:"path,omitempty"`
	Version int    `json:"version,omitempty"`
}

NFSConfig : configuration for NFS Storage

type PersistentVolume

type PersistentVolume struct {
	ID                       uint                      `json:"id" gorm:"primaryKey"`
	Name                     string                    `json:"name" gorm:"unique"`
	Type                     PersistentVolumeType      `json:"type" gorm:"default:'local'"`
	NFSConfig                NFSConfig                 `json:"nfs_config" gorm:"embedded;embeddedPrefix:nfs_config_"`
	CIFSConfig               CIFSConfig                `json:"cifs_config" gorm:"embedded;embeddedPrefix:cifs_config_"`
	PersistentVolumeBindings []PersistentVolumeBinding `json:"persistent_volume_bindings" gorm:"foreignKey:PersistentVolumeID"`
	PersistentVolumeBackups  []PersistentVolumeBackup  `json:"persistent_volume_backups" gorm:"foreignKey:PersistentVolumeID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	PersistentVolumeRestores []PersistentVolumeRestore `json:"persistent_volume_restores" gorm:"foreignKey:PersistentVolumeID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

PersistentVolume hold information about persistent volume

func FindAllPersistentVolumes

func FindAllPersistentVolumes(_ context.Context, db gorm.DB) ([]*PersistentVolume, error)

func (*PersistentVolume) Create

func (persistentVolume *PersistentVolume) Create(ctx context.Context, db gorm.DB, createDockerClientFromServerRecord createDockerClientFromServerRecord) error

func (*PersistentVolume) Delete

func (persistentVolume *PersistentVolume) Delete(_ context.Context, db gorm.DB) error

func (*PersistentVolume) FindById

func (persistentVolume *PersistentVolume) FindById(_ context.Context, db gorm.DB, id uint) error

func (*PersistentVolume) FindByName

func (persistentVolume *PersistentVolume) FindByName(_ context.Context, db gorm.DB, name string) error

func (*PersistentVolume) Update

func (persistentVolume *PersistentVolume) Update(_ context.Context, _ gorm.DB, _ containermanger.Manager) error

func (*PersistentVolume) ValidateDeletion

func (persistentVolume *PersistentVolume) ValidateDeletion(_ context.Context, db gorm.DB) error

type PersistentVolumeBackup

type PersistentVolumeBackup struct {
	ID                 uint         `json:"id" gorm:"primaryKey"`
	Type               BackupType   `json:"type"`
	Status             BackupStatus `json:"status"`
	File               string       `json:"file"`
	FileSizeMB         float64      `json:"file_size_mb"`
	PersistentVolumeID uint         `json:"persistent_volume_id"`
	CreatedAt          time.Time    `json:"created_at"`
	CompletedAt        time.Time    `json:"completed_at"`
}

PersistentVolumeBackup hold information about persistent volume backup

func FindPersistentVolumeBackupsByPersistentVolumeId

func FindPersistentVolumeBackupsByPersistentVolumeId(ctx context.Context, db gorm.DB, persistentVolumeId uint) ([]*PersistentVolumeBackup, error)

func (*PersistentVolumeBackup) Create

func (persistentVolumeBackup *PersistentVolumeBackup) Create(ctx context.Context, db gorm.DB) error

func (*PersistentVolumeBackup) Delete

func (persistentVolumeBackup *PersistentVolumeBackup) Delete(ctx context.Context, db gorm.DB, dataDir string, config system_config.S3BackupConfig) error

func (*PersistentVolumeBackup) FindById

func (persistentVolumeBackup *PersistentVolumeBackup) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*PersistentVolumeBackup) Update

func (persistentVolumeBackup *PersistentVolumeBackup) Update(ctx context.Context, db gorm.DB) error

type PersistentVolumeBinding

type PersistentVolumeBinding struct {
	ID                 uint   `json:"id" gorm:"primaryKey"`
	ApplicationID      string `json:"application_id"`
	PersistentVolumeID uint   `json:"persistent_volume_id"`
	MountingPath       string `json:"mounting_path"`
}

PersistentVolumeBinding hold information about persistent volume binding

func FindPersistentVolumeBindingsByApplicationId

func FindPersistentVolumeBindingsByApplicationId(ctx context.Context, db gorm.DB, applicationId string) ([]*PersistentVolumeBinding, error)

func FindPersistentVolumeBindingsByPersistentVolumeId

func FindPersistentVolumeBindingsByPersistentVolumeId(ctx context.Context, db gorm.DB, persistentVolumeId uint) ([]*PersistentVolumeBinding, error)

func (*PersistentVolumeBinding) Create

func (p *PersistentVolumeBinding) Create(ctx context.Context, db gorm.DB) error

func (*PersistentVolumeBinding) Delete

func (p *PersistentVolumeBinding) Delete(ctx context.Context, db gorm.DB) error

func (*PersistentVolumeBinding) Update

func (p *PersistentVolumeBinding) Update(ctx context.Context, db gorm.DB) error

type PersistentVolumeRestore

type PersistentVolumeRestore struct {
	ID                 uint          `json:"id" gorm:"primaryKey"`
	Type               RestoreType   `json:"type"`
	File               string        `json:"file"`
	Status             RestoreStatus `json:"status"`
	PersistentVolumeID uint          `json:"persistent_volume_id"`
	CreatedAt          time.Time     `json:"created_at"`
	CompletedAt        time.Time     `json:"completed_at"`
}

PersistentVolumeRestore hold information about persistent volume restore

func FindPersistentVolumeRestoresByPersistentVolumeId

func FindPersistentVolumeRestoresByPersistentVolumeId(ctx context.Context, db gorm.DB, persistentVolumeId uint) ([]*PersistentVolumeRestore, error)

func (*PersistentVolumeRestore) Create

func (persistentVolumeRestore *PersistentVolumeRestore) Create(ctx context.Context, db gorm.DB) error

func (*PersistentVolumeRestore) Delete

func (persistentVolumeRestore *PersistentVolumeRestore) Delete(ctx context.Context, db gorm.DB, dataDir string) error

func (*PersistentVolumeRestore) FindById

func (persistentVolumeRestore *PersistentVolumeRestore) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*PersistentVolumeRestore) Update

func (persistentVolumeRestore *PersistentVolumeRestore) Update(ctx context.Context, db gorm.DB, dataDir string) error

type PersistentVolumeType

type PersistentVolumeType string

PersistentVolumeType : type of persistent volume

const (
	PersistentVolumeTypeLocal PersistentVolumeType = "local"
	PersistentVolumeTypeNFS   PersistentVolumeType = "nfs"
	PersistentVolumeTypeCIFS  PersistentVolumeType = "cifs"
)

type ProtocolType

type ProtocolType string

ProtocolType : type of protocol for ingress rule

const (
	HTTPProtocol  ProtocolType = "http"
	HTTPSProtocol ProtocolType = "https"
	TCPProtocol   ProtocolType = "tcp"
	UDPProtocol   ProtocolType = "udp"
)

type ProxyConfig

type ProxyConfig struct {
	Enabled      bool      `json:"enabled" gorm:"default:false"`
	SetupRunning bool      `json:"setup_running" gorm:"default:false"` // just to show warning to user, that's it
	Type         ProxyType `json:"type" gorm:"default:'active'"`
}

ProxyConfig : hold information about proxy configuration

type ProxyType

type ProxyType string

ProxyType : type of the proxy

const (
	BackupProxy ProxyType = "backup"
	ActiveProxy ProxyType = "active"
)

type RedirectRule

type RedirectRule struct {
	ID          uint               `json:"id" gorm:"primaryKey"`
	DomainID    uint               `json:"domain_id"`
	Protocol    ProtocolType       `json:"protocol"`
	RedirectURL string             `json:"redirect_url"`
	Status      RedirectRuleStatus `json:"status"`
	CreatedAt   time.Time          `json:"created_at"`
	UpdatedAt   time.Time          `json:"updated_at"`
}

RedirectRule hold information about Redirect rules for domain

func FindAllRedirectRules

func FindAllRedirectRules(ctx context.Context, db gorm.DB) ([]*RedirectRule, error)

func FindRedirectRulesByDomainID

func FindRedirectRulesByDomainID(ctx context.Context, db gorm.DB, domainID uint) ([]*RedirectRule, error)

func (*RedirectRule) Create

func (redirectRule *RedirectRule) Create(ctx context.Context, db gorm.DB) error

func (*RedirectRule) Delete

func (redirectRule *RedirectRule) Delete(ctx context.Context, db gorm.DB, force bool) error

func (*RedirectRule) FindById

func (redirectRule *RedirectRule) FindById(ctx context.Context, db gorm.DB, id uint) error

func (*RedirectRule) Update

func (redirectRule *RedirectRule) Update(ctx context.Context, db gorm.DB) error

func (*RedirectRule) UpdateStatus

func (redirectRule *RedirectRule) UpdateStatus(ctx context.Context, db gorm.DB, status RedirectRuleStatus) error

type RedirectRuleStatus

type RedirectRuleStatus string

RedirectRuleStatus : status of the redirect rule

const (
	RedirectRuleStatusPending  RedirectRuleStatus = "pending"
	RedirectRuleStatusApplied  RedirectRuleStatus = "applied"
	RedirectRuleStatusFailed   RedirectRuleStatus = "failed"
	RedirectRuleStatusDeleting RedirectRuleStatus = "deleting"
)

type RestoreStatus

type RestoreStatus string

RestoreStatus : status of restore

const (
	RestorePending RestoreStatus = "pending"
	RestoreFailed  RestoreStatus = "failed"
	RestoreSuccess RestoreStatus = "success"
)

type RestoreType

type RestoreType string

RestoreType : type of restore

const (
	LocalRestore RestoreType = "local"
)

type Server

type Server struct {
	ID                    uint                   `json:"id" gorm:"primaryKey"`
	IP                    string                 `json:"ip" gorm:"unique"`
	HostName              string                 `json:"host_name"`
	User                  string                 `json:"user"`
	SSHPort               int                    `json:"ssh_port" gorm:"default:22"`
	MaintenanceMode       bool                   `json:"maintenance_mode" gorm:"default:false"`
	ScheduleDeployments   bool                   `json:"schedule_deployments" gorm:"default:true"`
	DockerUnixSocketPath  string                 `json:"docker_unix_socket_path"`
	SwarmMode             SwarmMode              `json:"swarm_mode"`
	ProxyConfig           ProxyConfig            `json:"proxy_config" gorm:"embedded;embeddedPrefix:proxy_"`
	Status                ServerStatus           `json:"status"`
	LastPing              time.Time              `json:"last_ping"`
	Logs                  []ServerLog            `json:"logs" gorm:"foreignKey:ServerID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ConsoleTokens         []ConsoleToken         `json:"console_tokens" gorm:"foreignKey:ServerID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	AnalyticsServiceToken *AnalyticsServiceToken `json:"analytics_service_token" gorm:"foreignKey:ServerID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ResourceStats         []ServerResourceStat   `json:"resource_stats" gorm:"foreignKey:ServerID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

Server hold information about server

func FetchAllOnlineServers

func FetchAllOnlineServers(db *gorm.DB) ([]Server, error)

FetchAllOnlineServers fetches all servers from the database

func FetchAllProxyServers

func FetchAllProxyServers(db *gorm.DB) ([]Server, error)

FetchAllProxyServers fetches all proxy servers from the database

func FetchAllProxyServersIrrespectiveOfStatus

func FetchAllProxyServersIrrespectiveOfStatus(db *gorm.DB) ([]Server, error)

FetchAllProxyServersIrrespectiveOfStatus fetches all proxy servers from the database irrespective of status

func FetchAllServers

func FetchAllServers(db *gorm.DB) ([]Server, error)

FetchAllServers fetches all servers from the database

func FetchBackupProxyServers

func FetchBackupProxyServers(db *gorm.DB) ([]Server, error)

FetchBackupProxyServers fetches all backup servers from the database

func FetchProxyActiveServers

func FetchProxyActiveServers(db *gorm.DB) ([]Server, error)

FetchProxyActiveServers fetches all active servers from the database

func FetchRandomActiveProxyServer

func FetchRandomActiveProxyServer(db *gorm.DB) (Server, error)

FetchRandomActiveProxyServer fetches a random active server from the database

func FetchServerByID

func FetchServerByID(db *gorm.DB, id uint) (*Server, error)

FetchServerByID fetches a server by its ID from the database

func FetchSwarmManager

func FetchSwarmManager(db *gorm.DB) (Server, error)

FetchSwarmManager fetches the swarm manager from the database

func FetchSwarmManagerExceptServer

func FetchSwarmManagerExceptServer(db *gorm.DB, serverId uint) (Server, error)

FetchSwarmManagerExceptServer fetches the swarm manager from the database except the given server

func (*Server) IsLocalhost

func (server *Server) IsLocalhost() bool

IsLocalhost check if the domain is localhost

type ServerDiskStat

type ServerDiskStat struct {
	Path       string  `json:"path"`
	MountPoint string  `json:"mount_point"`
	TotalGB    float32 `json:"total_gb"`
	UsedGB     float32 `json:"used_gb"`
}

type ServerDiskStats

type ServerDiskStats []ServerDiskStat

func FetchLatestServerDiskUsage

func FetchLatestServerDiskUsage(_ context.Context, db gorm.DB, serverId uint) (*ServerDiskStats, *time.Time, error)

FetchLatestServerDiskUsage fetches the latest server disk usage

func (*ServerDiskStats) Scan

func (d *ServerDiskStats) Scan(value interface{}) error

Scan implement value scanner interface for gorm

func (ServerDiskStats) Value

func (d ServerDiskStats) Value() (driver.Value, error)

Value implement driver.Valuer interface for gorm

type ServerLog

type ServerLog struct {
	*gorm.Model
	ID       uint   `json:"id" gorm:"primaryKey"`
	ServerID uint   `json:"serverID"`
	Title    string `json:"title"` // can be empty, but will be useful if we want to
	Content  string `json:"content"`
}

ServerLog hold logs of server

func FetchServerLogByID

func FetchServerLogByID(db *gorm.DB, id uint) (*ServerLog, error)

FetchServerLogByID is a function to fetch a single server log from the database by its id.

func FetchServerLogByServerID

func FetchServerLogByServerID(db *gorm.DB, serverID uint) ([]ServerLog, error)

FetchServerLogByServerID is a function to fetch all server logs from the database by server id. This will not send the log content.

func (*ServerLog) Update

func (serverLog *ServerLog) Update(db *gorm.DB) error

Update is a function to update a server log in the database.

type ServerMemoryStat

type ServerMemoryStat struct {
	TotalGB  float32 `json:"total_gb"`
	UsedGB   float32 `json:"used_gb"`
	CachedGB float32 `json:"cached_gb"`
}

type ServerNetStat

type ServerNetStat struct {
	SentKB   uint64 `json:"sent_kb"`
	RecvKB   uint64 `json:"recv_kb"`
	SentKBPS uint64 `json:"sent_kbps"`
	RecvKBPS uint64 `json:"recv_kbps"`
}

type ServerResourceStat

type ServerResourceStat struct {
	ID              uint             `json:"id" gorm:"primaryKey"`
	ServerID        uint             `json:"server_id"`
	CpuUsagePercent uint8            `json:"cpu_used_percent"`
	MemStat         ServerMemoryStat `json:"memory" gorm:"embedded;embeddedPrefix:memory_"`
	DiskStats       ServerDiskStats  `json:"disks"`
	NetStat         ServerNetStat    `json:"network" gorm:"embedded;embeddedPrefix:network_"`
	RecordedAt      time.Time        `json:"recorded_at"`
}

ServerResourceStat struct to hold host resource stats

func FetchLatestServerResourceAnalytics

func FetchLatestServerResourceAnalytics(_ context.Context, db gorm.DB, serverId uint) (*ServerResourceStat, error)

FetchLatestServerResourceAnalytics fetches the latest server resource analytics

func FetchServerDiskUsage

func FetchServerDiskUsage(_ context.Context, db gorm.DB, serverId uint) ([]*ServerResourceStat, error)

FetchServerDiskUsage fetches the server disk usage of last 24 hours

func FetchServerResourceAnalytics

func FetchServerResourceAnalytics(_ context.Context, db gorm.DB, serverId uint, tillTime uint) ([]*ServerResourceStat, error)

FetchServerResourceAnalytics fetches the server resource analytics

func (*ServerResourceStat) Create

func (s *ServerResourceStat) Create(_ context.Context, db gorm.DB) error

type ServerStatus

type ServerStatus string

ServerStatus : status of the server

const (
	ServerNeedsSetup ServerStatus = "needs_setup"
	ServerPreparing  ServerStatus = "preparing"
	ServerOnline     ServerStatus = "online"
	ServerOffline    ServerStatus = "offline"
)

type SwarmMode

type SwarmMode string

SwarmMode : mode of the swarm

const (
	SwarmManager SwarmMode = "manager"
	SwarmWorker  SwarmMode = "worker"
)

type UpstreamType

type UpstreamType string

UpstreamType : type of source for the codebase of the application

const (
	UpstreamTypeGit        UpstreamType = "git"
	UpstreamTypeSourceCode UpstreamType = "sourceCode"
	UpstreamTypeImage      UpstreamType = "image"
)

type User

type User struct {
	ID           uint     `json:"id" gorm:"primaryKey"`
	Username     string   `json:"username" gorm:"unique"`
	Role         UserRole `json:"role" gorm:"default:'user'"`
	PasswordHash string   `json:"password_hash"`
	TotpEnabled  bool     `json:"totp_enabled" gorm:"default:false"`
	TotpSecret   string   `json:"totp_secret"`
}

User hold information about user

func CreateUser

func CreateUser(ctx context.Context, db gorm.DB, user User) (User, error)

CreateUser : create user

func FindAllUsers

func FindAllUsers(ctx context.Context, db gorm.DB) ([]User, error)

FindAllUsers : find all users

func FindUserByID

func FindUserByID(ctx context.Context, db gorm.DB, id uint) (User, error)

FindUserByID : find user by id

func FindUserByUsername

func FindUserByUsername(ctx context.Context, db gorm.DB, username string) (User, error)

FindUserByUsername : find user by username

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

CheckPassword : check password for user

func (*User) GenerateJWT

func (user *User) GenerateJWT(jwtSecret string) (string, error)

GenerateJWT : generate jwt token for user

func (*User) SetPassword

func (user *User) SetPassword(password string) error

SetPassword : set password for user

type UserRole

type UserRole string

UserRole : role of the registered user

const (
	// AdministratorRole : admin user can perform any operation on the system
	AdministratorRole UserRole = "admin"
	// ManagerRole : manager user can perform any operation on the system
	// except user management, system configuration and server management
	ManagerRole UserRole = "manager"
)

Jump to

Keyboard shortcuts

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