Documentation
¶
Overview ¶
Package app orchestrates GitLab project backup and restore operations.
This package serves as the main application layer, coordinating between:
- GitLab API client (pkg/gitlab)
- Storage backends (pkg/storage)
- Configuration management (pkg/config)
- Hooks execution (pkg/hooks)
The package implements two main workflows:
1. Backup (App.BackupProjects):
- Exports projects using GitLab Export API
- Stores archives to local or S3 storage
- Executes pre/post backup hooks
- Supports concurrent group exports
2. Restore (restore subpackage):
- Validates target project is empty
- Downloads archives from storage
- Imports projects via GitLab Import API
- Reports progress and handles interruption
Architecture follows clean architecture principles:
Command Layer (cmd/)
↓
Application Layer (pkg/app)
↓
Domain Layer (pkg/gitlab, pkg/storage)
↓
Infrastructure Layer (GitLab API, AWS SDK)
Rate Limiting:
- Download API: 5 requests/minute
- Export API: 6 requests/minute
- Import API: 6 requests/minute
Example usage:
cfg, err := config.Load("config.yaml")
if err != nil {
log.Fatal(err)
}
app, err := app.New(cfg)
if err != nil {
log.Fatal(err)
}
if err := app.BackupProjects(ctx); err != nil {
log.Fatal(err)
}
Index ¶
- Variables
- type App
- func (a *App) ExportGroup(ctx context.Context) error
- func (a *App) ExportProject(ctx context.Context, projectID int64) error
- func (a *App) Run(ctx context.Context) error
- func (a *App) SetGitlabEndpoint(gitlabAPIEndpoint string)
- func (a *App) SetLogger(l Logger)
- func (a *App) SetToken(token string)
- func (a *App) StoreArchive(ctx context.Context, archiveFilePath string) error
- type Logger
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoStorageDefined is returned when no storage configuration is provided. ErrNoStorageDefined = errors.New("no storage defined") // ErrBackupErrors is returned when errors occur during backup process. ErrBackupErrors = errors.New("errors occurred during backup") // ErrNotDirectory is returned when a path is not a directory. ErrNotDirectory = errors.New("path is not a directory") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App represents the main application structure.
func NewApp ¶
NewApp returns a new App struct. The context is used for S3 client initialization and may respect timeout/cancellation.
func (*App) ExportGroup ¶
ExportGroup will export all projects of the group.
func (*App) ExportProject ¶
ExportProject exports the project of the given ID.
func (*App) SetGitlabEndpoint ¶
SetGitlabEndpoint sets the gitlab endpoint.
Click to show internal directories.
Click to hide internal directories.