app

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

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

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

func NewApp(ctx context.Context, cfg *config.Config) (*App, error)

NewApp returns a new App struct. The context is used for S3 client initialization and may respect timeout/cancellation.

func (*App) ExportGroup

func (a *App) ExportGroup(ctx context.Context) error

ExportGroup will export all projects of the group.

func (*App) ExportProject

func (a *App) ExportProject(ctx context.Context, projectID int64) error

ExportProject exports the project of the given ID.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run runs the app.

func (*App) SetGitlabEndpoint

func (a *App) SetGitlabEndpoint(gitlabAPIEndpoint string)

SetGitlabEndpoint sets the gitlab endpoint.

func (*App) SetLogger

func (a *App) SetLogger(l Logger)

SetLogger sets the logger.

func (*App) SetToken

func (a *App) SetToken(token string)

SetToken sets the gitlab token.

func (*App) StoreArchive

func (a *App) StoreArchive(ctx context.Context, archiveFilePath string) error

StoreArchive stores the archive.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	Info(msg string, args ...any)
}

Logger interface defines the logging methods used by the application.

Directories

Path Synopsis
Package restore implements the 5-phase GitLab project restore workflow.
Package restore implements the 5-phase GitLab project restore workflow.

Jump to

Keyboard shortcuts

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