gitserver

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitserver runs the optional built-in Git server (§5.8): Forgejo as a system task on the controller node, served at git.<base-domain>. When it is turned on, the controller creates its administrator, mints an API token and registers it as the Git connection "git", so services can build from its repositories with webhooks and commit statuses like any other host.

Index

Constants

View Source
const (

	// ConnectionName is the Git connection of the built-in server.
	ConnectionName = "git"
	// AdminUser is its administrator ("admin" is reserved by Forgejo).
	AdminUser = "syncloud"
)

Variables

View Source
var ErrDumping = errors.New("a dump is already running")

ErrDumping means another dump is under way.

View Source
var ErrInUse = errors.New("services still build from the built-in Git server: disconnect them first")

ErrInUse means services still build from the built-in server.

View Source
var ErrNoStorage = errors.New("no recovery storage: set up the controller's backups with an S3 connection first")

ErrNoStorage means the controller's backups have no recovery storage.

Functions

This section is empty.

Types

type DumpInfo added in v1.1.0

type DumpInfo struct {
	Name      string    `json:"name"`
	Size      int64     `json:"size"`
	CreatedAt time.Time `json:"createdAt"`
}

DumpInfo is one stored dump.

type Manager

type Manager struct {
	// Hold reports whether a kind of work waits for a recovery (Phase 29c);
	// may be nil.
	Hold func(kind string) bool
	// DumpHeld holds back dumps until a recovery has loaded the server.
	DumpHeld func() bool
	// Frozen reports whether a move is copying the server: it then takes
	// nothing from outside (Phase 29d); may be nil.
	Frozen func() bool
	// Standby holds back every write outside the cluster while this
	// controller does not own it (Phase 29c); may be nil.
	Standby func() (string, bool)

	// Conns, Exec and Sys are set before Run.
	Conns *gitconn.Manager
	Exec  *execrelay.Relay
	Sys   *system.Manager
	// Endpoints returns the dashboard's current addresses.
	Endpoints func() domain.Endpoints
	// OnChange re-renders the system tasks and certificate hosts.
	OnChange func()
	// API is where the controller reaches the server (loopback).
	API string
	// CADir is where the cluster's self-signed certificates are written for
	// the server to trust ("" = none); TrustPEM returns them ("" = none,
	// e.g. once ACME issued real ones).
	CADir    string
	TrustPEM func() string
	// Storage is the recovery storage the dumps go to; S3 reaches an S3
	// connection; OnKey runs when the dump key is made (Phase 29b).
	Storage func() (backup.Storage, bool)
	S3      func(ctx context.Context, endpointID string) (*minio.Client, error)
	OnKey   func()
	// WorkDir is where a dump is prepared while it is loaded ("": the
	// system's temporary folder).
	WorkDir string
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, box *secrets.Box, endpoints func() domain.Endpoints, log *slog.Logger) *Manager

func (*Manager) Answering added in v1.1.0

func (m *Manager) Answering(ctx context.Context) bool

Answering reports whether the server answers now.

func (*Manager) Config

func (m *Manager) Config() *system.GitServerConfig

Config is the system task configuration (nil when off).

func (*Manager) Credentials

func (m *Manager) Credentials() (string, string, bool)

Credentials returns the administrator's sign-in.

func (*Manager) Dump added in v1.1.0

func (m *Manager) Dump(ctx context.Context) (DumpInfo, error)

Dump copies the server into the recovery storage now.

func (*Manager) DumpState added in v1.1.0

func (m *Manager) DumpState() (at, tried time.Time, err error)

DumpState is when the last dump in the current storage succeeded, when one was last tried and why it failed (for the protection page).

func (*Manager) Dumps added in v1.1.0

func (m *Manager) Dumps(ctx context.Context) ([]DumpInfo, error)

Dumps lists the stored dumps, newest first.

func (*Manager) Host

func (m *Manager) Host() string

Host is git.<base-domain> while the server is on and a domain is set.

func (*Manager) Kick

func (m *Manager) Kick()

Kick re-checks the server now (after a domain change, for example).

func (*Manager) Load

func (m *Manager) Load(ctx context.Context) error

Load reads the stored state (call before the system tasks start).

func (*Manager) PublicHost added in v1.1.0

func (m *Manager) PublicHost() string

PublicHost is the name the server is reached at from outside ("" while a move copies it).

func (*Manager) RestoreDump added in v1.1.0

func (m *Manager) RestoreDump(ctx context.Context, name string) error

RestoreDump loads a dump (empty name: the newest) into the running server, which must have no repositories.

func (*Manager) RootURL

func (m *Manager) RootURL() string

RootURL is the server's public address.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run provisions the server whenever it is on and not ready yet, and keeps the connection's address in step with the domain.

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(ctx context.Context, on bool) error

SetEnabled turns the server on or off. Turning it off keeps its data volume, so turning it on again brings the repositories back.

func (*Manager) Status

func (m *Manager) Status() Status

type Status

type Status struct {
	Enabled    bool   `json:"enabled"`
	State      string `json:"state"` // off | starting | provisioning | ready | failed
	URL        string `json:"url"`
	Image      string `json:"image"`
	AdminUser  string `json:"adminUser"`
	Connection string `json:"connection"`
	Problem    string `json:"problem,omitempty"`
}

Status is the server as the API shows it.

Jump to

Keyboard shortcuts

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