config

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingRepo = errors.New("missing repo")

ErrMissingRepo indicates that the requested repository could not be found.

View Source
var (
	// ErrNoConfig is returned when a repo has no config file.
	ErrNoConfig = errors.New("no config file found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Name         string         `yaml:"name" json:"name"`
	Host         string         `yaml:"host" json:"host"`
	Port         int            `yaml:"port" json:"port"`
	AnonAccess   string         `yaml:"anon-access" json:"anon-access"`
	AllowKeyless bool           `yaml:"allow-keyless" json:"allow-keyless"`
	Users        []User         `yaml:"users" json:"users"`
	Repos        []RepoConfig   `yaml:"repos" json:"repos"`
	Source       *RepoSource    `yaml:"-" json:"-"`
	Cfg          *config.Config `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

Config is the Soft Serve configuration.

func NewConfig added in v0.4.0

func NewConfig(cfg *config.Config) (*Config, error)

NewConfig creates a new internal Config struct.

func (*Config) AuthRepo added in v0.4.0

func (cfg *Config) AuthRepo(repo string, pk ssh.PublicKey) gm.AccessLevel

AuthRepo grants repo authorization to the given key.

func (*Config) Fetch added in v0.4.0

func (cfg *Config) Fetch(repo string, pk ssh.PublicKey)

Fetch registers Git fetch functionality for the given repo and key.

func (*Config) KeyboardInteractiveHandler added in v0.4.1

func (cfg *Config) KeyboardInteractiveHandler(ctx ssh.Context, _ gossh.KeyboardInteractiveChallenge) bool

KeyboardInteractiveHandler returns whether or not keyboard interactive is allowed.

func (*Config) PasswordHandler added in v0.4.0

func (cfg *Config) PasswordHandler(ctx ssh.Context, password string) bool

PasswordHandler returns whether or not password access is allowed.

func (*Config) PublicKeyHandler added in v0.4.0

func (cfg *Config) PublicKeyHandler(ctx ssh.Context, pk ssh.PublicKey) bool

PublicKeyHandler returns whether or not the given public key may access the repo.

func (*Config) Push added in v0.4.0

func (cfg *Config) Push(repo string, pk ssh.PublicKey)

Push registers Git push functionality for the given repo and key.

func (*Config) Reload added in v0.4.0

func (cfg *Config) Reload() error

Reload reloads the configuration.

type Repo added in v0.4.0

type Repo struct {
	// contains filtered or unexported fields
}

Repo represents a Git repository.

func (*Repo) Commit added in v0.4.0

func (r *Repo) Commit(hash string) (*git.Commit, error)

Commit returns the commit for a given hash.

func (*Repo) CommitsByPage added in v0.4.0

func (r *Repo) CommitsByPage(ref *git.Reference, page, size int) (git.Commits, error)

CommitsByPage returns the commits for a repository.

func (*Repo) CountCommits added in v0.4.0

func (r *Repo) CountCommits(ref *git.Reference) (int64, error)

CountCommits returns the number of commits for a repository.

func (*Repo) Description added in v0.4.0

func (r *Repo) Description() string

Description returns the description for a repository.

func (*Repo) Diff added in v0.4.0

func (r *Repo) Diff(commit *git.Commit) (*git.Diff, error)

Diff returns the diff for a given commit.

func (*Repo) HEAD added in v0.4.0

func (r *Repo) HEAD() (*git.Reference, error)

HEAD returns the reference for a repository.

func (*Repo) IsPrivate added in v0.4.0

func (r *Repo) IsPrivate() bool

IsPrivate returns true if the repository is private.

func (*Repo) LatestFile added in v0.4.0

func (r *Repo) LatestFile(pattern string) (string, string, error)

LatestFile returns the contents of the latest file at the specified path in the repository and its file path.

func (*Repo) Name added in v0.4.0

func (r *Repo) Name() string

Name returns the name of the repository.

func (*Repo) Path added in v0.4.0

func (r *Repo) Path() string

Path returns the path to the repository.

func (*Repo) Push added in v0.4.0

func (r *Repo) Push(remote, branch string) error

Push pushes the repository to the remote.

func (*Repo) Readme added in v0.4.0

func (r *Repo) Readme() (readme string, path string)

Readme returns the readme and its path for the repository.

func (*Repo) References added in v0.4.0

func (r *Repo) References() ([]*git.Reference, error)

GetReferences returns the references for a repository.

func (*Repo) Repo added in v0.4.0

func (r *Repo) Repo() string

Repo returns the repository directory name.

func (*Repo) SetReadme added in v0.4.0

func (r *Repo) SetReadme(readme, path string)

SetReadme sets the readme for the repository.

func (*Repo) Tree added in v0.4.0

func (r *Repo) Tree(ref *git.Reference, path string) (*git.Tree, error)

Tree returns the git tree for a given path.

func (*Repo) UpdateServerInfo added in v0.4.0

func (r *Repo) UpdateServerInfo() error

UpdateServerInfo updates the server info for the repository.

type RepoConfig added in v0.4.2

type RepoConfig struct {
	Name    string   `yaml:"name" json:"name"`
	Repo    string   `yaml:"repo" json:"repo"`
	Note    string   `yaml:"note" json:"note"`
	Private bool     `yaml:"private" json:"private"`
	Readme  string   `yaml:"readme" json:"readme"`
	Collabs []string `yaml:"collabs" json:"collabs"`
}

RepoConfig is a repository configuration.

type RepoSource added in v0.4.0

type RepoSource struct {
	Path string
	// contains filtered or unexported fields
}

RepoSource is a reference to an on-disk repositories.

func NewRepoSource added in v0.4.0

func NewRepoSource(repoPath string) *RepoSource

NewRepoSource creates a new RepoSource.

func (*RepoSource) AllRepos added in v0.4.0

func (rs *RepoSource) AllRepos() []*Repo

AllRepos returns all repositories for the given RepoSource.

func (*RepoSource) GetRepo added in v0.4.0

func (rs *RepoSource) GetRepo(name string) (*Repo, error)

GetRepo returns a repository by name.

func (*RepoSource) InitRepo added in v0.4.0

func (rs *RepoSource) InitRepo(name string, bare bool) (*Repo, error)

InitRepo initializes a new Git repository.

func (*RepoSource) LoadRepo added in v0.4.0

func (rs *RepoSource) LoadRepo(name string) error

LoadRepo loads a repository from disk.

func (*RepoSource) LoadRepos added in v0.4.0

func (rs *RepoSource) LoadRepos() error

LoadRepos opens Git repositories.

type User added in v0.4.0

type User struct {
	Name        string   `yaml:"name" json:"name"`
	Admin       bool     `yaml:"admin" json:"admin"`
	PublicKeys  []string `yaml:"public-keys" json:"public-keys"`
	CollabRepos []string `yaml:"collab-repos" json:"collab-repos"`
}

User contains user-level configuration for a repository.

Jump to

Keyboard shortcuts

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