Documentation
¶
Overview ¶
Package project owns compose project persistence, lifecycle, discovery, and routes.
Index ¶
- func BuildConfiguredUpdateInfo(projectID string, services []types.ServiceConfig, ...) *projecttypes.UpdateInfo
- func BuildUpdateInfoSummary(imageRefs []string, updateInfoByRef map[string]*imagetypes.UpdateInfo) *projecttypes.UpdateInfo
- func EncodeSyncedFiles(files []string) *string
- func IconCatalogForContext(ctx context.Context) string
- func ParseEnvText(raw *string) (map[string]string, error)
- func ParseExtraMountsText(raw *string) ([]lifecycletype.ExtraMount, error)
- func RegisterProjects(api huma.API, projectService *ProjectService, ...)
- type ArchiveProjectInput
- type BuildProjectInput
- type CreateProjectInput
- type DeployProjectInput
- type DestroyProjectInput
- type DownProjectInput
- type GetProjectInput
- type GetProjectStatusCountsInput
- type GetProjectWorkspaceFileInput
- type GetProjectWorkspaceInput
- type GitOpsSync
- type LifecycleService
- type ListProjectTagsInput
- type ListProjectsInput
- type Module
- type Project
- type ProjectHandler
- func (h *ProjectHandler) ArchiveProject(ctx context.Context, input *ArchiveProjectInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) BuildProjectImages(ctx context.Context, input *BuildProjectInput) (*huma.StreamResponse, error)
- func (h *ProjectHandler) CreateProject(ctx context.Context, input *CreateProjectInput) (*handlerutil.Out[project.CreateReponse], error)
- func (h *ProjectHandler) DeployProject(ctx context.Context, input *DeployProjectInput) (*huma.StreamResponse, error)
- func (h *ProjectHandler) DestroyProject(ctx context.Context, input *DestroyProjectInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) DownProject(ctx context.Context, input *DownProjectInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) DownloadProjectWorkspaceFile(ctx context.Context, input *GetProjectWorkspaceFileInput) (*huma.StreamResponse, error)
- func (h *ProjectHandler) GetProject(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
- func (h *ProjectHandler) GetProjectCompose(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
- func (h *ProjectHandler) GetProjectRuntime(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
- func (h *ProjectHandler) GetProjectStatusCounts(ctx context.Context, input *GetProjectStatusCountsInput) (*handlerutil.Out[project.StatusCounts], error)
- func (h *ProjectHandler) GetProjectUpdates(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
- func (h *ProjectHandler) GetProjectWorkspace(ctx context.Context, input *GetProjectWorkspaceInput) (*handlerutil.Out[workspacetypes.Workspace], error)
- func (h *ProjectHandler) GetProjectWorkspaceFile(ctx context.Context, input *GetProjectWorkspaceFileInput) (*handlerutil.Out[workspacetypes.FileContent], error)
- func (h *ProjectHandler) ListProjectTags(ctx context.Context, _ *ListProjectTagsInput) (*handlerutil.Out[[]project.TagOption], error)
- func (h *ProjectHandler) ListProjects(ctx context.Context, input *ListProjectsInput) (*handlerutil.Page[project.Details], error)
- func (h *ProjectHandler) PullProjectImages(ctx context.Context, input *PullProjectImagesInput) (*huma.StreamResponse, error)
- func (h *ProjectHandler) RedeployProject(ctx context.Context, input *RedeployProjectInput) (*huma.StreamResponse, error)
- func (h *ProjectHandler) RestartProject(ctx context.Context, input *RestartProjectInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) UnarchiveProject(ctx context.Context, input *UnarchiveProjectInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) UpdateProject(ctx context.Context, input *UpdateProjectInput) (*handlerutil.Out[project.Details], error)
- func (h *ProjectHandler) UpdateProjectServices(ctx context.Context, input *UpdateProjectServicesInput) (*handlerutil.Out[base.MessageResponse], error)
- func (h *ProjectHandler) UpdateProjectTag(ctx context.Context, input *UpdateProjectTagInput) (*handlerutil.Out[project.UpdateTagResponse], error)
- func (h *ProjectHandler) UpdateProjectWorkspace(ctx context.Context, input *UpdateProjectWorkspaceInput) (*handlerutil.Out[workspacetypes.Workspace], error)
- type ProjectService
- func (s *ProjectService) ApplyGitSyncEnvToDirectory(ctx context.Context, projectPath, projectsDirectory string, ...) (before, after string, err error)
- func (s *ProjectService) ApplyGitSyncProjectFiles(ctx context.Context, projectID, composeContent string, ...) (*Project, bool, error)
- func (s *ProjectService) ArchiveProject(ctx context.Context, projectID string, user usertypes.Actor) error
- func (s *ProjectService) BackfillProjectImageRefs(ctx context.Context) (int, error)
- func (s *ProjectService) BuildProjectServices(ctx context.Context, projectID string, options projecttypes.BuildOptions, ...) error
- func (s *ProjectService) CountProjectsWithPendingUpdates(ctx context.Context, allContainers []container.Summary) (int, error)
- func (s *ProjectService) CountServicesFromCompose(ctx context.Context, p Project) (int, error)
- func (s *ProjectService) CreateGitOpsManagedProject(ctx context.Context, gitOpsSync *GitOpsSync, project *Project, ...) error
- func (s *ProjectService) CreateProject(ctx context.Context, name, composeContent string, envContent *string, ...) (*Project, error)
- func (s *ProjectService) DeployProject(ctx context.Context, projectID string, user usertypes.Actor, ...) error
- func (s *ProjectService) DestroyProject(ctx context.Context, projectID string, removeFiles, removeVolumes bool, ...) error
- func (s *ProjectService) DownProject(ctx context.Context, projectID string, user usertypes.Actor) error
- func (s *ProjectService) DownloadProjectWorkspaceFile(ctx context.Context, projectID, relativePath string) (io.ReadCloser, int64, string, error)
- func (s *ProjectService) EnsureGitOpsProjectLinked(ctx context.Context, gitOpsSync *GitOpsSync, project *Project) error
- func (s *ProjectService) EnsureProjectImagesPresent(ctx context.Context, projectID string, progressWriter io.Writer, ...) error
- func (s *ProjectService) EnsureProjectPathUnderRoot(ctx context.Context, proj *Project, persist bool) error
- func (s *ProjectService) FindProjectByID(ctx context.Context, projectID string) (*Project, bool, error)
- func (s *ProjectService) GetProjectByComposeName(ctx context.Context, name string) (*Project, error)
- func (s *ProjectService) GetProjectContent(ctx context.Context, projectID string) (composeContent, envContent, overrideContent string, err error)
- func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID string, opts projecttypes.DetailsOptions) (projecttypes.Details, error)
- func (s *ProjectService) GetProjectFromDatabaseByID(ctx context.Context, id string) (*Project, error)
- func (s *ProjectService) GetProjectRelativePath(ctx context.Context, projectPath string) string
- func (s *ProjectService) GetProjectStatusCounts(ctx context.Context) (projecttypes.StatusCounts, error)
- func (s *ProjectService) GetProjectTags(ctx context.Context, projectID string) ([]projecttypes.Tag, error)
- func (s *ProjectService) GetProjectWorkspace(ctx context.Context, projectID string) (*workspacetypes.Workspace, error)
- func (s *ProjectService) GetProjectWorkspaceFile(ctx context.Context, projectID, relativePath string) (*workspacetypes.FileContent, error)
- func (s *ProjectService) GetProjectsDirectory(ctx context.Context) (string, error)
- func (s *ProjectService) HandleProjectFilesChanged(ctx context.Context, paths []string)
- func (s *ProjectService) ListAllProjects(ctx context.Context) ([]Project, error)
- func (s *ProjectService) ListProjectTagOptions(ctx context.Context) ([]projecttypes.TagOption, error)
- func (s *ProjectService) ListProjects(ctx context.Context, params pagination.QueryParams) ([]projecttypes.Details, pagination.Response, error)
- func (s *ProjectService) ProjectMetadata(ctx context.Context, p Project, env *projectMetadataEnvInternal) projects.ArcaneComposeMetadata
- func (s *ProjectService) PullProjectImages(ctx context.Context, projectID string, progressWriter io.Writer, ...) error
- func (s *ProjectService) RecoverProjectRenameJournals(ctx context.Context) error
- func (s *ProjectService) RedeployProject(ctx context.Context, projectID string, user usertypes.Actor, ...) error
- func (s *ProjectService) ResolveProjectComposeFile(ctx context.Context, proj *Project) (string, error)
- func (s *ProjectService) ResolveRegistryCredentials(ctx context.Context) ([]containerregistry.Credential, error)
- func (s *ProjectService) RestartProject(ctx context.Context, projectID string, services []string, user usertypes.Actor) error
- func (s *ProjectService) StreamProjectLogs(ctx context.Context, projectID string, logsChan chan<- string, follow bool, ...) error
- func (s *ProjectService) SyncProjectsFromFileSystem(ctx context.Context) error
- func (s *ProjectService) UnarchiveProject(ctx context.Context, projectID string, user usertypes.Actor) error
- func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, ...) (*Project, error)
- func (s *ProjectService) UpdateProjectServiceImages(ctx context.Context, projectID string, ...) error
- func (s *ProjectService) UpdateProjectServices(ctx context.Context, projectID string, servicesToUpdate []string, ...) error
- func (s *ProjectService) UpdateProjectTag(ctx context.Context, projectID, name string, color projecttypes.TagColor, ...) ([]projecttypes.Tag, error)
- func (s *ProjectService) UpdateProjectWorkspace(ctx context.Context, projectID string, ...) (*workspacetypes.Workspace, error)
- func (s *ProjectService) ValidateComposeDirectory(ctx context.Context, projectName, projectPath, composeFileName string) (int, error)
- type ProjectStatus
- type ProjectTag
- type PullProjectImagesInput
- type RedeployProjectInput
- type RestartProjectInput
- type UnarchiveProjectInput
- type UpdateProjectInput
- type UpdateProjectServicesInput
- type UpdateProjectTagInput
- type UpdateProjectWorkspaceInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildConfiguredUpdateInfo ¶ added in v2.11.0
func BuildConfiguredUpdateInfo( projectID string, services []types.ServiceConfig, byRef map[string]*imagetypes.UpdateInfo, records []imageupdate.ImageUpdateRecord, runtimeUpdates ...map[string]*imagetypes.UpdateInfo, ) *projecttypes.UpdateInfo
BuildConfiguredUpdateInfo matches checks to current services and aggregates their results.
func BuildUpdateInfoSummary ¶ added in v2.11.0
func BuildUpdateInfoSummary( imageRefs []string, updateInfoByRef map[string]*imagetypes.UpdateInfo, ) *projecttypes.UpdateInfo
BuildUpdateInfoSummary aggregates image checks into a project update summary.
func EncodeSyncedFiles ¶ added in v2.15.0
EncodeSyncedFiles converts tracked synced-file paths to their stored JSON form.
func IconCatalogForContext ¶
IconCatalogForContext resolves the icon catalog of the requesting user. On agent-proxied calls the caller is a synthetic user whose preference is populated from the X-Arcane-Icon-Catalog header the manager forwards. Background jobs have no user attached and fall back to the default catalog.
func ParseEnvText ¶ added in v2.8.1
ParseEnvText reads admin-configured env config as the same KEY=VALUE text format used by .env files: one entry per line, blank and "#"-prefixed lines ignored, keys must match POSIX identifier syntax. Reuses the strict parser also used for stdout-capture.
func ParseExtraMountsText ¶ added in v2.8.1
func ParseExtraMountsText(raw *string) ([]lifecycletype.ExtraMount, error)
ParseExtraMountsText reads admin-configured bind mounts in docker-CLI "src:tgt[:ro|:rw]" form, one per line. Blank and "#"-prefixed lines are ignored. Both source and target must be absolute paths; mode defaults to read-write.
func RegisterProjects ¶
func RegisterProjects(api huma.API, projectService *ProjectService, activityService *activity.ActivityService, appCtx handlerutil.ActivityAppContext)
RegisterProjects registers project management routes using Huma. WebSocket and streaming endpoints live in api/ws.
Types ¶
type ArchiveProjectInput ¶
type BuildProjectInput ¶
type BuildProjectInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
ProjectID string `path:"projectId" doc:"Project ID"`
Body *struct {
Services []string `json:"services,omitempty" doc:"Service names to build"`
Provider string `json:"provider,omitempty" doc:"Build provider override"`
Push *bool `json:"push,omitempty" doc:"Push images"`
Load *bool `json:"load,omitempty" doc:"Load images into Docker"`
}
}
type CreateProjectInput ¶
type DeployProjectInput ¶
type DeployProjectInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
ProjectID string `path:"projectId" doc:"Project ID"`
Body *project.DeployOptions
}
type DestroyProjectInput ¶
type DownProjectInput ¶
type GetProjectInput ¶
type GetProjectStatusCountsInput ¶
type GetProjectStatusCountsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
}
type GitOpsSync ¶ added in v2.8.1
type GitOpsSync struct {
database.BaseModel
Environment *environment.Environment `json:"environment,omitempty" gorm:"foreignKey:EnvironmentID"`
Repository *gitrepo.GitRepository `json:"repository,omitempty" gorm:"foreignKey:RepositoryID"`
ProjectID *string `json:"projectId,omitempty" sortable:"true"` // Set after project is created
Project *Project `json:"project,omitempty" gorm:"foreignKey:ProjectID"`
SyncedFiles *string `json:"syncedFiles,omitempty" gorm:"column:synced_files"` // JSON array of synced file paths
LastSyncAt *time.Time `json:"lastSyncAt,omitempty" sortable:"true"`
LastSyncStatus *string `json:"lastSyncStatus,omitempty" search:"status,success,failed,pending,error"`
LastSyncError *string `json:"lastSyncError,omitempty"`
LastSyncCommit *string `json:"lastSyncCommit,omitempty" search:"commit,hash,sha,revision"`
// Pre-deploy lifecycle hook (configuration)
// When PreDeployScriptPath is set, the named script is executed in a
// throwaway container before each deploy of the linked project. The script,
// runner image, and execution context together act as repo-trusted code —
// any push to the repo that changes the script will run unreviewed on the
// next deploy. See docs for details.
PreDeployScriptPath *string `json:"preDeployScriptPath,omitempty" gorm:"column:pre_deploy_script_path" search:"lifecycle,hook,pre-deploy,script,path"`
PreDeployRunnerImage *string `json:"preDeployRunnerImage,omitempty" gorm:"column:pre_deploy_runner_image"`
PreDeployEnv *string `json:"preDeployEnv,omitempty" gorm:"column:pre_deploy_env"` // KEY=VALUE lines, one per line; same format as .env files
PreDeployExtraMounts *string `json:"preDeployExtraMounts,omitempty" gorm:"column:pre_deploy_extra_mounts"` // docker -v style "src:tgt[:ro|:rw]" entries, one per line
// Pre-deploy lifecycle hook (last-run state)
PreDeployLastRunAt *time.Time `json:"preDeployLastRunAt,omitempty" gorm:"column:pre_deploy_last_run_at" sortable:"true"`
PreDeployLastRunStatus *string `json:"preDeployLastRunStatus,omitempty" gorm:"column:pre_deploy_last_run_status" sortable:"true"` // "success" | "failed" | "timeout"
PreDeployLastRunOutput *string `json:"preDeployLastRunOutput,omitempty" gorm:"column:pre_deploy_last_run_output"` // truncated stdout+stderr
Name string `json:"name" sortable:"true" search:"sync,gitops,automation,deploy,deployment,continuous"`
EnvironmentID string `json:"environmentId" sortable:"true"`
RepositoryID string `json:"repositoryId" sortable:"true"`
Branch string `json:"branch" sortable:"true" search:"branch,main,master,develop,feature,release"`
ComposePath string `json:"composePath" sortable:"true" search:"compose,docker-compose,path,file,yaml,yml"`
TargetType string `json:"targetType" gorm:"column:target_type;default:'project'"` // "project" or "swarm_stack"
ProjectName string `json:"projectName" sortable:"true" search:"project,name,stack,application,service"` // Name of project to create/update
// Docker network mode for the runner: "none" denies access; "bridge", "host", or a named network enables it.
PreDeployNetworkMode string `json:"preDeployNetworkMode" gorm:"column:pre_deploy_network_mode;default:'none'"`
SyncInterval int `json:"syncInterval" sortable:"true" search:"interval,frequency,schedule,cron,minutes"` // in minutes
MaxSyncFiles int `json:"maxSyncFiles" gorm:"column:max_sync_files;default:500"` // 0 = unlimited; env var overrides take precedence
MaxSyncTotalSize int64 `json:"maxSyncTotalSize" gorm:"column:max_sync_total_size;default:52428800"` // bytes; 0 = unlimited; env var overrides take precedence
MaxSyncBinarySize int64 `json:"maxSyncBinarySize" gorm:"column:max_sync_binary_size;default:10485760"` // bytes; 0 = unlimited; env var overrides take precedence
PreDeployTimeoutSec int `json:"preDeployTimeoutSec" gorm:"column:pre_deploy_timeout_sec;default:60"`
AutoSync bool `json:"autoSync" sortable:"true" search:"auto,automatic,sync,continuous,scheduled"`
SyncDirectory bool `json:"syncDirectory" gorm:"column:sync_directory"` // Sync entire directory containing compose file
PullImageAfterSync bool `json:"pullImageAfterSync" gorm:"column:pull_image_after_sync;default:false"`
RedeployAfterSync bool `json:"redeployAfterSync" gorm:"column:redeploy_after_sync;default:false"`
// Backup mode ("backup" commits saved project files to the repository;
// "deploy" is the original pull direction).
Mode string `json:"mode" gorm:"column:mode;default:'deploy'" sortable:"true" search:"mode,backup,deploy,direction"`
BackupDirectory string `json:"backupDirectory" gorm:"column:backup_directory" sortable:"true" search:"backup,directory,destination,folder"`
BackupPaths database.StringSlice `json:"backupPaths" gorm:"column:backup_paths;type:text"`
BackupOnSave bool `json:"backupOnSave" gorm:"column:backup_on_save;default:true"`
BackupPending bool `json:"backupPending" gorm:"column:backup_pending;default:false"`
BackupPendingSince *time.Time `json:"backupPendingSince,omitempty" gorm:"column:backup_pending_since"`
BackupConflict bool `json:"backupConflict" gorm:"column:backup_conflict;default:false"`
BackupFailureReason *string `json:"backupFailureReason,omitempty" gorm:"column:backup_failure_reason"`
LastBackupAt *time.Time `json:"lastBackupAt,omitempty" gorm:"column:last_backup_at" sortable:"true"`
LastBackupSnapshot *string `json:"-" gorm:"column:last_backup_snapshot"`
}
func (GitOpsSync) BackupSnapshot ¶ added in v2.15.0
func (s GitOpsSync) BackupSnapshot() map[string]string
BackupSnapshot decodes the file hashes recorded by the last backup push.
func (GitOpsSync) BackupState ¶ added in v2.12.0
func (s GitOpsSync) BackupState() string
BackupState derives the persisted backup lifecycle state.
func (GitOpsSync) SyncedFileList ¶ added in v2.15.0
func (s GitOpsSync) SyncedFileList() []string
SyncedFileList decodes the tracked synced-file paths.
func (GitOpsSync) TableName ¶ added in v2.8.1
func (GitOpsSync) TableName() string
type LifecycleService ¶ added in v2.8.1
type LifecycleService struct {
// contains filtered or unexported fields
}
LifecycleService runs pre-deploy lifecycle hooks declared on a project's GitOps sync. A hook is a script in the synced repo executed in a throwaway container immediately before the project is deployed, with optional capture of stdout as environment variables merged into the compose env.
Trust model: the script is repo-trusted code, equivalent to compose.yaml in the same repo. Anyone who can push to that repo can change what the script does on the next deploy. The trust event is configuring a script path on the GitOps sync, not each individual deploy.
func NewLifecycleService ¶ added in v2.8.1
func NewLifecycleService( db *database.DB, settingsService *settings.SettingsService, eventService *event.EventService, dockerService *docker.DockerClientService, imageService *image.ImageService, ) *LifecycleService
NewLifecycleService constructs a LifecycleService wired against shared infrastructure. The Docker client is obtained lazily on each hook run via dockerService.GetClient so reconnects are transparent. Runner image pulls go through imageService so configured registry credentials apply.
func (*LifecycleService) RunPreDeploy ¶ added in v2.8.1
func (s *LifecycleService) RunPreDeploy(ctx context.Context, project *Project, actor usertypes.Actor) error
RunPreDeploy executes the pre-deploy lifecycle hook for a project, if one is configured on its GitOps sync.
Callers should invoke this unconditionally before deploying — when no hook is configured, when lifecycle hooks are disabled globally, or when the project is not GitOps-managed, this is a no-op and returns nil.
A non-zero exit code, a script timeout, or any infrastructure failure returns an error that aborts the deploy. The last-run state on the GitOpsSync row is updated on every invocation that reaches the run step, regardless of outcome.
type ListProjectTagsInput ¶
type ListProjectTagsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
}
ListProjectTagsInput identifies the environment whose tag catalog is requested.
type ListProjectsInput ¶
type ListProjectsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
Search string `query:"search" doc:"Search query"`
Sort string `query:"sort" doc:"Column to sort by"`
Order string `query:"order" default:"asc" doc:"Sort direction (asc or desc)"`
Start int `query:"start" default:"0" doc:"Start index for pagination"`
Limit int `query:"limit" default:"20" doc:"Number of items per page"`
Status string `query:"status" doc:"Filter by status (comma-separated: running,stopped,partially running)"`
Updates string `query:"updates" doc:"Filter by update status (has_update, up_to_date, error, unknown)"`
Archived string `query:"archived" doc:"Archived filter: 'true' (only archived), 'all' (include archived). Default excludes archived."`
Tags string `query:"tags" doc:"Filter by tag names (comma-separated, OR semantics)"`
Label string `query:"label" doc:"Filter by container label key or key=value on any running service"`
}
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func New ¶
func New(service *ProjectService, activityService *activity.ActivityService) *Module
func (*Module) RegisterRoutes ¶
func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)
func (*Module) Service ¶
func (m *Module) Service() *ProjectService
type Project ¶ added in v2.8.1
type Project struct {
database.BaseModel
Name string `json:"name" sortable:"true" gorm:"index:idx_projects_name"`
DirName *string `json:"dir_name"`
Path string `json:"path" sortable:"true" gorm:"uniqueIndex"`
Status ProjectStatus `json:"status" sortable:"true"`
StatusReason *string `json:"status_reason"`
ServiceCount int `json:"service_count" sortable:"true"`
RunningCount int `json:"running_count" sortable:"true"`
GitOpsManagedBy *string `json:"gitops_managed_by,omitempty" gorm:"column:gitops_managed_by"`
ComposeProjectName *string `json:"compose_project_name,omitempty" gorm:"column:compose_project_name"`
ImageRefsJSON string `json:"image_refs_json,omitempty" gorm:"column:image_refs_json"`
BuildImageRefsJSON *string `json:"-" gorm:"column:build_image_refs_json"`
IsArchived bool `json:"is_archived" gorm:"column:is_archived;default:false;index"`
ArchivedAt *time.Time `json:"archived_at,omitempty" gorm:"column:archived_at"`
}
func LockProjectForSync ¶ added in v2.15.0
LockProjectForSync row-locks the project so the one-Git-relationship check and the insert are atomic.
type ProjectHandler ¶
type ProjectHandler struct {
// contains filtered or unexported fields
}
ProjectHandler provides Huma-based project management endpoints.
func (*ProjectHandler) ArchiveProject ¶
func (h *ProjectHandler) ArchiveProject(ctx context.Context, input *ArchiveProjectInput) (*handlerutil.Out[base.MessageResponse], error)
func (*ProjectHandler) BuildProjectImages ¶
func (h *ProjectHandler) BuildProjectImages(ctx context.Context, input *BuildProjectInput) (*huma.StreamResponse, error)
BuildProjectImages builds compose services with build directives.
func (*ProjectHandler) CreateProject ¶
func (h *ProjectHandler) CreateProject(ctx context.Context, input *CreateProjectInput) (*handlerutil.Out[project.CreateReponse], error)
CreateProject creates a new Docker Compose project.
func (*ProjectHandler) DeployProject ¶
func (h *ProjectHandler) DeployProject(ctx context.Context, input *DeployProjectInput) (*huma.StreamResponse, error)
func (*ProjectHandler) DestroyProject ¶
func (h *ProjectHandler) DestroyProject(ctx context.Context, input *DestroyProjectInput) (*handlerutil.Out[base.MessageResponse], error)
DestroyProject destroys a Docker Compose project.
func (*ProjectHandler) DownProject ¶
func (h *ProjectHandler) DownProject(ctx context.Context, input *DownProjectInput) (*handlerutil.Out[base.MessageResponse], error)
DownProject brings down a Docker Compose project.
func (*ProjectHandler) DownloadProjectWorkspaceFile ¶
func (h *ProjectHandler) DownloadProjectWorkspaceFile(ctx context.Context, input *GetProjectWorkspaceFileInput) (*huma.StreamResponse, error)
func (*ProjectHandler) GetProject ¶
func (h *ProjectHandler) GetProject(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
GetProject returns a project by ID.
func (*ProjectHandler) GetProjectCompose ¶
func (h *ProjectHandler) GetProjectCompose(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
func (*ProjectHandler) GetProjectRuntime ¶
func (h *ProjectHandler) GetProjectRuntime(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
func (*ProjectHandler) GetProjectStatusCounts ¶
func (h *ProjectHandler) GetProjectStatusCounts(ctx context.Context, input *GetProjectStatusCountsInput) (*handlerutil.Out[project.StatusCounts], error)
GetProjectStatusCounts returns counts of projects by status.
func (*ProjectHandler) GetProjectUpdates ¶
func (h *ProjectHandler) GetProjectUpdates(ctx context.Context, input *GetProjectInput) (*handlerutil.Out[project.Details], error)
func (*ProjectHandler) GetProjectWorkspace ¶
func (h *ProjectHandler) GetProjectWorkspace(ctx context.Context, input *GetProjectWorkspaceInput) (*handlerutil.Out[workspacetypes.Workspace], error)
func (*ProjectHandler) GetProjectWorkspaceFile ¶
func (h *ProjectHandler) GetProjectWorkspaceFile(ctx context.Context, input *GetProjectWorkspaceFileInput) (*handlerutil.Out[workspacetypes.FileContent], error)
func (*ProjectHandler) ListProjectTags ¶
func (h *ProjectHandler) ListProjectTags(ctx context.Context, _ *ListProjectTagsInput) (*handlerutil.Out[[]project.TagOption], error)
ListProjectTags returns the reusable project tag catalog for an environment.
func (*ProjectHandler) ListProjects ¶
func (h *ProjectHandler) ListProjects(ctx context.Context, input *ListProjectsInput) (*handlerutil.Page[project.Details], error)
ListProjects returns a paginated list of projects.
func (*ProjectHandler) PullProjectImages ¶
func (h *ProjectHandler) PullProjectImages(ctx context.Context, input *PullProjectImagesInput) (*huma.StreamResponse, error)
PullProjectImages pulls all images for a project with streaming progress.
func (*ProjectHandler) RedeployProject ¶
func (h *ProjectHandler) RedeployProject(ctx context.Context, input *RedeployProjectInput) (*huma.StreamResponse, error)
RedeployProject redeploys a Docker Compose project. RedeployProject pulls project images and re-deploys, streaming the raw docker CLI output as NDJSON like DeployProject.
func (*ProjectHandler) RestartProject ¶
func (h *ProjectHandler) RestartProject(ctx context.Context, input *RestartProjectInput) (*handlerutil.Out[base.MessageResponse], error)
RestartProject restarts the given services in a project (all services when none are specified).
func (*ProjectHandler) UnarchiveProject ¶
func (h *ProjectHandler) UnarchiveProject(ctx context.Context, input *UnarchiveProjectInput) (*handlerutil.Out[base.MessageResponse], error)
func (*ProjectHandler) UpdateProject ¶
func (h *ProjectHandler) UpdateProject(ctx context.Context, input *UpdateProjectInput) (*handlerutil.Out[project.Details], error)
UpdateProject updates a Docker Compose project.
func (*ProjectHandler) UpdateProjectServices ¶
func (h *ProjectHandler) UpdateProjectServices(ctx context.Context, input *UpdateProjectServicesInput) (*handlerutil.Out[base.MessageResponse], error)
UpdateProjectServices pulls the latest images for the given services and recreates them.
func (*ProjectHandler) UpdateProjectTag ¶
func (h *ProjectHandler) UpdateProjectTag(ctx context.Context, input *UpdateProjectTagInput) (*handlerutil.Out[project.UpdateTagResponse], error)
UpdateProjectTag applies one UI-managed project tag association change.
func (*ProjectHandler) UpdateProjectWorkspace ¶
func (h *ProjectHandler) UpdateProjectWorkspace(ctx context.Context, input *UpdateProjectWorkspaceInput) (*handlerutil.Out[workspacetypes.Workspace], error)
type ProjectService ¶
type ProjectService struct {
RegistryCredentialsProvider func(context.Context) ([]containerregistry.Credential, error)
// FilesChanged fires with the project ID after project files are saved
// through Arcane, so Git backups can react without polling.
FilesChanged *concurrency.Signal[string]
// contains filtered or unexported fields
}
func NewProjectService ¶
func NewProjectService( db *database.DB, settingsService *settings.SettingsService, eventService *event.EventService, imageService *image.ImageService, dockerService *docker.DockerClientService, buildService buildServiceInternal, lifecycleService *LifecycleService, containerRegistryService *registry.ContainerRegistryService, cfg *config.Config, kvService *kv.KVService, registryCredentialsProvider func( context.Context, ) ( []containerregistry.Credential, error, ), ) *ProjectService
func (*ProjectService) ApplyGitSyncEnvToDirectory ¶
func (s *ProjectService) ApplyGitSyncEnvToDirectory(ctx context.Context, projectPath, projectsDirectory string, gitEnvContent *string) (before, after string, err error)
ApplyGitSyncEnvToDirectory applies the same managed three-file environment merge used by single-file project syncs and returns the effective content before and after the update.
func (*ProjectService) ApplyGitSyncProjectFiles ¶
func (*ProjectService) ArchiveProject ¶
func (*ProjectService) BackfillProjectImageRefs ¶
func (s *ProjectService) BackfillProjectImageRefs(ctx context.Context) (int, error)
func (*ProjectService) BuildProjectServices ¶
func (s *ProjectService) BuildProjectServices(ctx context.Context, projectID string, options projecttypes.BuildOptions, progressWriter io.Writer, user *usertypes.Actor) error
func (*ProjectService) CountProjectsWithPendingUpdates ¶
func (s *ProjectService) CountProjectsWithPendingUpdates(ctx context.Context, allContainers []container.Summary) (int, error)
CountProjectsWithPendingUpdates counts non-archived projects with at least one visible service with an image update pending, plus compose projects running on the daemon that Arcane does not track. It deliberately avoids the project-list pipeline: that path builds full project DTOs (live status, icons, URLs, GitOps lookups) and then throws all of them away for a single number, costing several full container lists and a compose parse per project on every dashboard load.
allContainers is the caller's already-fetched container list; pass nil to have it fetched here.
func (*ProjectService) CountServicesFromCompose ¶
func (*ProjectService) CreateGitOpsManagedProject ¶
func (s *ProjectService) CreateGitOpsManagedProject(ctx context.Context, gitOpsSync *GitOpsSync, project *Project, actor usertypes.Actor, logEventOptions ...bool) error
CreateGitOpsManagedProject persists a promoted GitOps project, links both records, updates the compose-name cache, and records the creation event.
func (*ProjectService) CreateProject ¶
func ( s *ProjectService, ) CreateProject( ctx context.Context, name, composeContent string, envContent *string, manifest projecttypes.CreateProjectWorkspaceManifest, uploads map[int][]byte, uiTags []string, uiTagColors map[string]projecttypes.TagColor, user usertypes.Actor, allowNameSuffixOptions ...bool, ) ( *Project, error, )
CreateProject creates a project's directory, files, and DB row. When allowNameSuffix is true a directory-name collision is resolved by appending "-N" (the interactive default). When false a collision returns projects.ErrProjectDirExists (wrapped) so GitOps creates fail loudly instead of minting runaway "-N" duplicate projects on a broken binding.
func (*ProjectService) DeployProject ¶
func (s *ProjectService) DeployProject(ctx context.Context, projectID string, user usertypes.Actor, options *projecttypes.DeployOptions) error
func (*ProjectService) DestroyProject ¶
func (*ProjectService) DownProject ¶
func (*ProjectService) DownloadProjectWorkspaceFile ¶
func (s *ProjectService) DownloadProjectWorkspaceFile(ctx context.Context, projectID, relativePath string) (io.ReadCloser, int64, string, error)
func (*ProjectService) EnsureGitOpsProjectLinked ¶
func (s *ProjectService) EnsureGitOpsProjectLinked(ctx context.Context, gitOpsSync *GitOpsSync, project *Project) error
EnsureGitOpsProjectLinked persists the bidirectional GitOps/project binding and refreshes the compose-name cache as one domain operation.
func (*ProjectService) EnsureProjectImagesPresent ¶
func (s *ProjectService) EnsureProjectImagesPresent(ctx context.Context, projectID string, progressWriter io.Writer, user usertypes.Actor, credentials []containerregistry.Credential) error
EnsureProjectImagesPresent checks all compose service images for the project and pulls based on service pull policy: - always/refresh: always pull - missing/if_not_present/default: pull only if local image is missing - never: never pull (fails early if image is missing locally)
func (*ProjectService) EnsureProjectPathUnderRoot ¶
func (s *ProjectService) EnsureProjectPathUnderRoot(ctx context.Context, proj *Project, persist bool) error
EnsureProjectPathUnderRoot validates that the project's path is a safe subdirectory of the configured projects root. If not, it normalizes the path to `<projectsRoot>/<dirName or sanitized project name>`. When persist=true, it saves the updated project path to the database.
func (*ProjectService) FindProjectByID ¶ added in v2.15.0
func (s *ProjectService) FindProjectByID(ctx context.Context, projectID string) (*Project, bool, error)
FindProjectByID reports a missing project as found=false instead of an error.
func (*ProjectService) GetProjectByComposeName ¶
func (*ProjectService) GetProjectContent ¶
func (*ProjectService) GetProjectDetails ¶
func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID string, opts projecttypes.DetailsOptions) (projecttypes.Details, error)
func (*ProjectService) GetProjectFromDatabaseByID ¶
func (*ProjectService) GetProjectRelativePath ¶
func (s *ProjectService) GetProjectRelativePath(ctx context.Context, projectPath string) string
func (*ProjectService) GetProjectStatusCounts ¶
func (s *ProjectService) GetProjectStatusCounts(ctx context.Context) (projecttypes.StatusCounts, error)
func (*ProjectService) GetProjectTags ¶
func (s *ProjectService) GetProjectTags(ctx context.Context, projectID string) ([]projecttypes.Tag, error)
GetProjectTags returns the effective UI and Compose tag associations for a project.
func (*ProjectService) GetProjectWorkspace ¶
func (s *ProjectService) GetProjectWorkspace(ctx context.Context, projectID string) (*workspacetypes.Workspace, error)
func (*ProjectService) GetProjectWorkspaceFile ¶
func (s *ProjectService) GetProjectWorkspaceFile(ctx context.Context, projectID, relativePath string) (*workspacetypes.FileContent, error)
func (*ProjectService) GetProjectsDirectory ¶
func (s *ProjectService) GetProjectsDirectory(ctx context.Context) (string, error)
func (*ProjectService) HandleProjectFilesChanged ¶
func (s *ProjectService) HandleProjectFilesChanged(ctx context.Context, paths []string)
func (*ProjectService) ListAllProjects ¶
func (s *ProjectService) ListAllProjects(ctx context.Context) ([]Project, error)
func (*ProjectService) ListProjectTagOptions ¶
func (s *ProjectService) ListProjectTagOptions(ctx context.Context) ([]projecttypes.TagOption, error)
ListProjectTagOptions returns the distinct tag names and colors available in the current environment.
func (*ProjectService) ListProjects ¶
func (s *ProjectService) ListProjects(ctx context.Context, params pagination.QueryParams) ([]projecttypes.Details, pagination.Response, error)
func (*ProjectService) ProjectMetadata ¶
func (s *ProjectService) ProjectMetadata(ctx context.Context, p Project, env *projectMetadataEnvInternal) projects.ArcaneComposeMetadata
ProjectMetadata resolves a project's icon sets and service URLs. Results are cached until any compose file the parse merged (root, COMPOSE_FILE entries, override, includes) or any env file it read changes on disk, because deriving them is expensive (compose load with interpolation and .env reads, plus a gitops_syncs query for GitOps-managed projects) and every project row on the list page needs it.
env may be nil, in which case the projects directory and autoInjectEnv setting are resolved here; callers iterating over many projects should resolve them once and pass them in.
func (*ProjectService) PullProjectImages ¶
func (s *ProjectService) PullProjectImages(ctx context.Context, projectID string, progressWriter io.Writer, user usertypes.Actor, credentials []containerregistry.Credential) error
func (*ProjectService) RecoverProjectRenameJournals ¶
func (s *ProjectService) RecoverProjectRenameJournals(ctx context.Context) error
RecoverProjectRenameJournals replays renames interrupted by a restart.
func (*ProjectService) RedeployProject ¶
func (s *ProjectService) RedeployProject(ctx context.Context, projectID string, user usertypes.Actor, options *projecttypes.DeployOptions) error
func (*ProjectService) ResolveProjectComposeFile ¶
func (s *ProjectService) ResolveProjectComposeFile(ctx context.Context, proj *Project) (string, error)
ResolveProjectComposeFile returns the base compose file for a project. The precedence mirrors `docker compose`: COMPOSE_FILE in the merged environment (.env.global first, the project's .env on top) wins, then a GitOps sync's configured compose path, then standard detection.
func (*ProjectService) ResolveRegistryCredentials ¶
func (s *ProjectService) ResolveRegistryCredentials(ctx context.Context) ([]containerregistry.Credential, error)
func (*ProjectService) RestartProject ¶
func (*ProjectService) StreamProjectLogs ¶
func (*ProjectService) SyncProjectsFromFileSystem ¶
func (s *ProjectService) SyncProjectsFromFileSystem(ctx context.Context) error
func (*ProjectService) UnarchiveProject ¶
func (*ProjectService) UpdateProject ¶
func (*ProjectService) UpdateProjectServiceImages ¶ added in v2.11.0
func (s *ProjectService) UpdateProjectServiceImages(ctx context.Context, projectID string, changes map[string]updatertypes.ServiceImageChange, user usertypes.Actor) error
UpdateProjectServiceImages persists selected service image tags before recreating them.
func (*ProjectService) UpdateProjectServices ¶
func (*ProjectService) UpdateProjectTag ¶
func (s *ProjectService) UpdateProjectTag(ctx context.Context, projectID, name string, color projecttypes.TagColor, attached bool, user usertypes.Actor) ([]projecttypes.Tag, error)
UpdateProjectTag attaches or detaches a UI-managed tag and rejects Compose-owned names.
func (*ProjectService) UpdateProjectWorkspace ¶
func ( s *ProjectService, ) UpdateProjectWorkspace( ctx context.Context, projectID string, manifest projecttypes.WorkspaceUpdateManifest, uploads map[int][]byte, user usertypes.Actor, ) ( *workspacetypes.Workspace, error, )
func (*ProjectService) ValidateComposeDirectory ¶
func (s *ProjectService) ValidateComposeDirectory(ctx context.Context, projectName, projectPath, composeFileName string) (int, error)
ValidateComposeDirectory loads a staged compose tree with the same settings, Docker path mapping, and validation rules used by managed projects.
type ProjectStatus ¶ added in v2.8.1
type ProjectStatus string
const ( ProjectStatusRunning ProjectStatus = projecttypes.StatusRunning ProjectStatusStopped ProjectStatus = projecttypes.StatusStopped ProjectStatusPartiallyRunning ProjectStatus = projecttypes.StatusPartiallyRunning ProjectStatusUnknown ProjectStatus = projecttypes.StatusUnknown ProjectStatusDeploying ProjectStatus = projecttypes.StatusDeploying ProjectStatusStopping ProjectStatus = projecttypes.StatusStopping ProjectStatusRestarting ProjectStatus = projecttypes.StatusRestarting )
type ProjectTag ¶ added in v2.8.1
type ProjectTag struct {
ProjectID string `json:"projectId" gorm:"column:project_id;primaryKey"`
Name string `json:"name" gorm:"column:name;primaryKey"`
Source string `json:"source" gorm:"column:source;primaryKey"`
Color string `json:"color" gorm:"column:color;not null;default:gray"`
}
ProjectTag stores one normalized tag association and its management source.
func (ProjectTag) TableName ¶ added in v2.8.1
func (ProjectTag) TableName() string
TableName returns the database table used for project tag associations.
type PullProjectImagesInput ¶
type RedeployProjectInput ¶
type RedeployProjectInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
ProjectID string `path:"projectId" doc:"Project ID"`
Body *project.DeployOptions
}
type RestartProjectInput ¶
type UnarchiveProjectInput ¶
type UpdateProjectInput ¶
type UpdateProjectInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
ProjectID string `path:"projectId" doc:"Project ID"`
Body project.UpdateProject
}
Directories
¶
| Path | Synopsis |
|---|---|
|
children
|
|
|
deployment
Package deployment runs the image and bind-directory side of project deployments: pulls, builds, update reconciliation and dependents.
|
Package deployment runs the image and bind-directory side of project deployments: pulls, builds, update reconciliation and dependents. |
|
details
Package details derives project runtime state: service status from Compose and containers, include files, logs and image update checks.
|
Package details derives project runtime state: service status from Compose and containers, include files, logs and image update checks. |
|
lifecycle
Package lifecycle runs pre-deploy hook scripts in isolated runner containers and captures their output.
|
Package lifecycle runs pre-deploy hook scripts in isolated runner containers and captures their output. |
|
listing
Package listing projects stored projects and live Compose containers into paginated list rows, status counts and untracked-project update rows.
|
Package listing projects stored projects and live Compose containers into paginated list rows, status counts and untracked-project update rows. |
|
sync
Package sync manages the project env files a git sync writes: the git source, the Arcane override and the merged effective .env.
|
Package sync manages the project env files a git sync writes: the git source, the Arcane override and the merged effective .env. |
|
tags
Package tags owns project tag rules: UI and Compose sources, colors, per-project limits and the effective tag view.
|
Package tags owns project tag rules: UI and Compose sources, colors, per-project limits and the effective tag view. |
|
update
Package update owns project content updates: compose image edits and the rename journal that makes project renames recoverable.
|
Package update owns project content updates: compose image edits and the rename journal that makes project renames recoverable. |
|
workspace
Package workspace reads and edits project directories as bounded, revision-checked workspaces.
|
Package workspace reads and edits project directories as bounded, revision-checked workspaces. |