config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config manages jugctl's on-disk TOML configuration store of saved git servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() (string, error)

Path returns the location of jugctl's config file, honoring XDG_CONFIG_HOME and defaulting to ~/.config/jugctl/config.toml.

Types

type Config

type Config struct {
	Servers []Server `toml:"servers"`
}

Config is the top-level TOML document: a list of saved servers.

func Load

func Load() (*Config, error)

Load reads the config file from its default XDG-resolved path, returning an empty Config if the file does not exist yet.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads and decodes the config file at path, returning an empty Config if the file does not exist.

func (*Config) Get

func (c *Config) Get(name string) (Server, error)

Get looks up a server by its friendly name, returning an error if no such server is saved.

func (*Config) List

func (c *Config) List() []Server

List returns all saved servers sorted by name.

func (*Config) Save

func (c *Config) Save() error

Save writes cfg to the default XDG-resolved config path, creating the containing directory if needed.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes cfg to path atomically: it writes to a temp file in the same directory and renames it into place, so a crash or concurrent read never observes a partially written file.

func (*Config) Upsert

func (c *Config) Upsert(srv Server)

Upsert inserts srv, or replaces the existing server with the same Name if one is already present.

type Server

type Server struct {
	// Name is the friendly key used to refer to this server on the
	// command line.
	Name string `toml:"name"`

	// GitHost is the hostname clients use in git@<host>:repo.git clone
	// URLs, and the git vhost's own hostname for HTTP clone and
	// go-import discovery.
	GitHost string `toml:"git_host"`

	// WebHost is the hostname Caddy serves the cgit browsing UI on.
	WebHost string `toml:"web_host"`

	// ServiceUser is the unprivileged account that owns the rootless
	// podman pod on the remote host. jugctl connects as this user to
	// deploy: writing quadlet units and (re)starting the pod.
	ServiceUser string `toml:"service_user"`

	// ServicePort is the SSH port the service user's sshd listens on
	// (the host's admin sshd, not the container's).
	ServicePort int `toml:"service_port"`

	// ServiceIdentityFile is the path to the SSH private key used to
	// authenticate as ServiceUser.
	ServiceIdentityFile string `toml:"service_identity_file"`

	// GitUser is the account the container's sshd exposes for
	// git-shell operations (typically "git").
	GitUser string `toml:"git_user"`

	// GitPort is the SSH port the container's sshd listens on
	// (published by the pod, typically 22).
	GitPort int `toml:"git_port"`

	// GitIdentityFile is the path to the SSH private key used to
	// authenticate as GitUser.
	GitIdentityFile string `toml:"git_identity_file"`

	// ACMEEmail is the contact email Caddy registers with Let's
	// Encrypt for automatic HTTPS.
	ACMEEmail string `toml:"acme_email"`

	// CgitTitle is cgit's root-title.
	CgitTitle string `toml:"cgit_title"`

	// CgitDescription is cgit's root-desc.
	CgitDescription string `toml:"cgit_description"`

	// DefaultBranch sets the git user's global init.defaultBranch,
	// applied to repos created by "jugctl repo create".
	DefaultBranch string `toml:"default_branch"`

	// AuthorizedKeys lists the public keys (in authorized_keys line
	// format) allowed to authenticate as GitUser.
	AuthorizedKeys []string `toml:"authorized_keys"`

	// Image is the just-use-git container image reference to deploy.
	// There's no registry default: it's set by "jugctl build" (which
	// auto-persists the tag it just built) or an explicit --image
	// override.
	Image string `toml:"image,omitempty"`
}

Server holds everything jugctl needs to deploy and manage a containerized just-use-git server.

func (Server) Validate

func (srv Server) Validate() error

Validate reports every required field that is missing from srv, named so the failure points at "jugctl deploy" rather than surfacing later as a confusing SSH error.

Source Files

  • accessors.go
  • config.go
  • path.go
  • types.go

Jump to

Keyboard shortcuts

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