projects

package
v0.0.0-...-d39b1a8 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusCreated = iota + 1000
	StatusCloning
	StatusCloned
	StatusCheckingOut
	StatusCheckedOut
	StatusPulling // Currently pulling the latest changes from the repository
	StatusPulled  // Successfully pulled the latest changes from the repository
	StatusBuilding
	StatusBuilt
	StatusRunning
	StatusRun
	StatusStopping
	StatusStopped
	StatusDeleting
	StatusDeleted
	StatusTagging
	StatusTagged
	StatusFailed
	StatusError
)
View Source
const (
	TaskNameList  = "list"  // TaskNameList is used to list all tasks in the taskfile
	TaskNameBuild = "build" // TaskNameBuild is used to build the project
	TaskNameStart = "start" // TaskNameStart is used to start the task
	TaskNameStop  = "stop"  // TaskNameStop is used to stop the task
	TaskNameInfo  = "info"  // TaskNameInfo is used to get information about tasks

	DefaultTaskfileName = "Taskfile.yml"
)
View Source
const DbConnMaxLifetime = 0 // Maximum amount of time a connection may be reused
View Source
const DbMaxIdleConnections = 10 // Maximum number of idle connections in the pool
View Source
const DbMaxOpenConnections = 100 // Maximum number of open connections to the database
View Source
const StatusUnknown = -1

StatusUnknown is used to represent an unknown status.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchInfo

type BranchInfo struct {
	Branch string `json:"branch"`
	Place  string `json:"place"`
	Active bool   `json:"active"`
}

type BranchListResponse

type BranchListResponse struct {
	Branches []*BranchInfo `json:"branches"`
	Messages []string      `json:"messages"`
}

type ChangeTaskfilePayload

type ChangeTaskfilePayload struct {
	Taskfile string `json:"taskfile" validate:"required"`
}

type CheckoutPayload

type CheckoutPayload struct {
	Branch  string `json:"branch" validate:"required"`
	Place   string `json:"place" validate:"required"`
	Message string `json:"message" validate:"required"`
}

type CommandMap

type CommandMap map[ProjectCommand]bool

CommandMap is a map that associates ProjectCommand with a boolean value indicating whether the command can be executed for a given status.

type CommandPayload

type CommandPayload struct {
	Message string `json:"message" validate:"required"`
}

type CreatePayload

type CreatePayload struct {
	Name        string `json:"name" validate:"required"`
	Description string `json:"description"`
	Path        string `json:"path" validate:"required"`
	GitUrl      string `json:"giturl" validate:"required,url"`
	User        string `json:"user" validate:"required"`
	Token       string `json:"token" validate:"required"`
}

type DbEvent

type DbEvent struct {
	ID        string `json:"id" gorm:"primaryKey;index:uni_event_id;not null"`       // Unique event ID
	Group     string `json:"group" gorm:"not null"`                                  // required: Group to identify related events e.g "project", "docker", "system"
	Event     string `json:"event" gorm:"not null"`                                  // required: The event name, e.g., "checkout-repository", "build-project"
	ValueID   string `json:"value_id" gorm:"primaryKey;index:idx_value_id;not null"` // required: ID of the related entity, e.g., project ID, docker container ID
	Value     string `json:"value" gorm:"not null"`                                  // JSON serialized value of the event
	Timestamp int64  `json:"timestamp" gorm:"not null"`                              // The unix epoch timestamp when the event occurred
}

DbEvent represents an event in the system, such as project changed, docker started, etc.

func (*DbEvent) BeforeCreate

func (e *DbEvent) BeforeCreate(tx *gorm.DB) error

func (*DbEvent) TableName

func (e *DbEvent) TableName() string

type DbProject

type DbProject struct {
	ID          string        `json:"id" gorm:"primaryKey;index:uni_project_id;not null"`
	Name        string        `json:"name" gorm:"not null"`
	Description string        `json:"description" gorm:"default:''"`
	Path        string        `json:"path" gorm:"not null"`
	GitUrl      string        `json:"gitUrl" gorm:"not null"`
	Branch      string        `json:"branch" gorm:"default:''"`   // Branch: default: main
	Taskfile    string        `json:"taskfile" gorm:"default:''"` // Taskfile: default: Taskfile.yml
	User        string        `json:"user" gorm:"not null"`
	Token       string        `json:"token" gorm:"not null"`
	Creation    int64         `json:"creation" gorm:"autoCreateTime"`
	Modified    int64         `json:"updated" gorm:"autoUpdateTime"`
	Status      ProjectStatus `json:"status" gorm:"not null"`
}

func (*DbProject) BeforeCreate

func (p *DbProject) BeforeCreate(tx *gorm.DB) error

func (*DbProject) TableName

func (p *DbProject) TableName() string

type ProjectBranchMessageListResponse

type ProjectBranchMessageListResponse struct {
	ProjectResponse
	Branch   *BranchInfo `json:"branch"`
	Messages []string    `json:"messages"`
}

type ProjectCommand

type ProjectCommand string
const (
	// CommandCreateProject create a new project
	// It is the first command to be executed when creating a project.
	// It is always allowed to be executed, regardless of the current status of the project.
	CommandCreateProject      ProjectCommand = "create-project"
	CommandCloneRepository    ProjectCommand = "clone-repository"
	CommandCheckoutRepository ProjectCommand = "checkout-repository"
	CommandBuildProject       ProjectCommand = "build-project"
	CommandPullRepository     ProjectCommand = "pull-repository" // Update repository to the latest version
	CommandStartProject       ProjectCommand = "start-project"
	CommandStopProject        ProjectCommand = "stop-project"
	CommandDeleteProject      ProjectCommand = "delete-project"
	CommandTaggingVersion     ProjectCommand = "tagging-version"

	CommandTaskList   ProjectCommand = "task-list"   // Not directly a command, but used to list tasks in a task file
	CommandBranchList ProjectCommand = "branch-list" // Not directly a command, but used to list branches in a repository
)

func (ProjectCommand) Event

func (c ProjectCommand) Event() string

func (ProjectCommand) Message

func (c ProjectCommand) Message() string

func (ProjectCommand) String

func (c ProjectCommand) String() string

type ProjectError

type ProjectError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*ProjectError) Error

func (e *ProjectError) Error() string

func (*ProjectError) JSON

func (e *ProjectError) JSON(ctx echo.Context) error

type ProjectManager

type ProjectManager struct {
	// contains filtered or unexported fields
}

func NewProjectManager

func NewProjectManager(basePath, dbPath string, dockerActions []events.Action) (*ProjectManager, error)

NewProjectManager creates a new instance of ProjectManager.

The database is under the specified `dbPath` within the `basePath`. The `basePath` is the root directory where all project repositories will be managed. The `dockerActions` parameter specifies which Docker actions to listen for.

func (*ProjectManager) BuildProject

func (pm *ProjectManager) BuildProject(ctx echo.Context) error

BuildProject build the project using the specified task file.

The query parameter "force" can be used to force the build even if the project status is not suitable for building.

func (*ProjectManager) CheckoutProjectBranch

func (pm *ProjectManager) CheckoutProjectBranch(ctx echo.Context) error

func (*ProjectManager) CloneRepositoryProject

func (pm *ProjectManager) CloneRepositoryProject(ctx echo.Context) error

CloneRepositoryProject try to clone the project into the filesystem with git

func (*ProjectManager) CreateProject

func (pm *ProjectManager) CreateProject(ctx echo.Context) error

func (*ProjectManager) GetProjectBranchList

func (pm *ProjectManager) GetProjectBranchList(ctx echo.Context) error

func (*ProjectManager) GetProjectBranchPull

func (pm *ProjectManager) GetProjectBranchPull(ctx echo.Context) error

func (*ProjectManager) GetProjectDetail

func (pm *ProjectManager) GetProjectDetail(ctx echo.Context) error

func (*ProjectManager) GetProjectList

func (pm *ProjectManager) GetProjectList(ctx echo.Context) error

func (*ProjectManager) GetTaskFileList

func (pm *ProjectManager) GetTaskFileList(ctx echo.Context) error

func (*ProjectManager) GetTaskNameList

func (pm *ProjectManager) GetTaskNameList(ctx echo.Context) error

GetTaskNameList retrieves the list of task names from the task file of a project.

func (*ProjectManager) ListenForComposeEvents

func (pm *ProjectManager) ListenForComposeEvents() error

ListenForComposeEvents starts listening for Docker Compose events and handles them.

It spawns a goroutine to process incoming events.

func (*ProjectManager) ProjectEventConnect

func (pm *ProjectManager) ProjectEventConnect(ctx echo.Context) error

func (*ProjectManager) ProjectEventPing

func (pm *ProjectManager) ProjectEventPing(ctx echo.Context) error

func (*ProjectManager) StartProject

func (pm *ProjectManager) StartProject(ctx echo.Context) error

StartProject starts the project using the specified task file.

The query parameter "force" can be used to force the start even if the project status is not suitable for starting.

func (*ProjectManager) StopProject

func (pm *ProjectManager) StopProject(ctx echo.Context) error

func (*ProjectManager) UpdateTaskfile

func (pm *ProjectManager) UpdateTaskfile(ctx echo.Context) error

UpdateTaskfile updates the taskfile of a project.

The payload ChangeTaskfilePayload includes the new taskfile to be set for the project.

type ProjectMessageListResponse

type ProjectMessageListResponse struct {
	ProjectResponse
	Messages []string `json:"messages"`
}

type ProjectResponse

type ProjectResponse struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Path        string     `json:"path"`
	GitUrl      string     `json:"gitUrl"`
	Branch      string     `json:"branch"`
	Taskfile    string     `json:"taskfile"`
	User        string     `json:"user"`
	Creation    string     `json:"creation"`
	Modified    string     `json:"modified"`
	Status      string     `json:"status"`
	CommandMap  CommandMap `json:"commandMap,omitempty"`
}

type ProjectStatus

type ProjectStatus int

ProjectStatus represents the status of a project in the system. It is an integer type that can be used to represent various states of a project, such as created, cloning, built, running, etc. The values are defined as constants for easy reference and comparison.

func ProjectStatusFrom

func ProjectStatusFrom(s string) ProjectStatus

func (ProjectStatus) String

func (s ProjectStatus) String() string

type ProjectTaskMessageListResponse

type ProjectTaskMessageListResponse struct {
	ProjectResponse
	TaskFile string   `json:"taskfile"`
	TaskName string   `json:"taskname"`
	Messages []string `json:"messages"`
}

Jump to

Keyboard shortcuts

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