Documentation ¶
Index ¶
- func KeysEqual(a, b gossh.PublicKey) bool
- func LatestFile(r Repository, pattern string) (string, string, error)
- func MarshalAuthorizedKey(pk gossh.PublicKey) string
- func ParseAuthorizedKey(ak string) (gossh.PublicKey, string, error)
- func Readme(r Repository) (readme string, path string, err error)
- type AccessLevel
- type Backend
- type HookArg
- type Hooks
- type Repository
- type RepositoryAccess
- type RepositoryMetadata
- type RepositoryOptions
- type RepositoryStore
- type SettingsBackend
- type User
- type UserAccess
- type UserOptions
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LatestFile ¶
func LatestFile(r Repository, 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 MarshalAuthorizedKey ¶
MarshalAuthorizedKey marshals a public key into an authorized key string.
This is the inverse of ParseAuthorizedKey. This function is a copy of ssh.MarshalAuthorizedKey, but without the trailing newline. It returns an empty string if pk is nil.
func ParseAuthorizedKey ¶
ParseAuthorizedKey parses an authorized key string into a public key.
Types ¶
type AccessLevel ¶
type AccessLevel int
AccessLevel is the level of access allowed to a repo.
const ( // NoAccess does not allow access to the repo. NoAccess AccessLevel = iota // ReadOnlyAccess allows read-only access to the repo. ReadOnlyAccess // ReadWriteAccess allows read and write access to the repo. ReadWriteAccess // AdminAccess allows read, write, and admin access to the repo. AdminAccess )
func ParseAccessLevel ¶
func ParseAccessLevel(s string) AccessLevel
ParseAccessLevel parses an access level string.
func (AccessLevel) String ¶
func (a AccessLevel) String() string
String returns the string representation of the access level.
type Backend ¶
type Backend interface { SettingsBackend RepositoryStore RepositoryMetadata RepositoryAccess UserStore UserAccess Hooks }
Backend is an interface that handles repositories management and any non-Git related operations.
type Hooks ¶
type Hooks interface { PreReceive(stdout io.Writer, stderr io.Writer, repo string, args []HookArg) Update(stdout io.Writer, stderr io.Writer, repo string, arg HookArg) PostReceive(stdout io.Writer, stderr io.Writer, repo string, args []HookArg) PostUpdate(stdout io.Writer, stderr io.Writer, repo string, args ...string) }
Hooks provides an interface for git server-side hooks.
type Repository ¶
type Repository interface { // Name returns the repository's name. Name() string // ProjectName returns the repository's project name. ProjectName() string // Description returns the repository's description. Description() string // IsPrivate returns whether the repository is private. IsPrivate() bool // IsMirror returns whether the repository is a mirror. IsMirror() bool // IsHidden returns whether the repository is hidden. IsHidden() bool // UpdatedAt returns the time the repository was last updated. // If the repository has never been updated, it returns the time it was created. UpdatedAt() time.Time // Open returns the underlying git.Repository. Open() (*git.Repository, error) }
Repository is a Git repository interface.
type RepositoryAccess ¶
type RepositoryAccess interface { IsCollaborator(repo string, username string) (bool, error) // AddCollaborator adds the authorized key as a collaborator on the repository. AddCollaborator(repo string, username string) error // RemoveCollaborator removes the authorized key as a collaborator on the repository. RemoveCollaborator(repo string, username string) error // Collaborators returns a list of all collaborators on the repository. Collaborators(repo string) ([]string, error) }
RepositoryAccess is an interface for managing repository access.
type RepositoryMetadata ¶
type RepositoryMetadata interface { // ProjectName returns the repository's project name. ProjectName(repo string) (string, error) // SetProjectName sets the repository's project name. SetProjectName(repo, name string) error // Description returns the repository's description. Description(repo string) (string, error) // SetDescription sets the repository's description. SetDescription(repo, desc string) error // IsPrivate returns whether the repository is private. IsPrivate(repo string) (bool, error) // SetPrivate sets whether the repository is private. SetPrivate(repo string, private bool) error // IsMirror returns whether the repository is a mirror. IsMirror(repo string) (bool, error) // IsHidden returns whether the repository is hidden. IsHidden(repo string) (bool, error) // SetHidden sets whether the repository is hidden. SetHidden(repo string, hidden bool) error }
RepositoryMetadata is an interface for managing repository metadata.
type RepositoryOptions ¶
type RepositoryOptions struct { Private bool Description string ProjectName string Mirror bool Hidden bool }
RepositoryOptions are options for creating a new repository.
type RepositoryStore ¶
type RepositoryStore interface { // Repository finds the given repository. Repository(repo string) (Repository, error) // Repositories returns a list of all repositories. Repositories() ([]Repository, error) // CreateRepository creates a new repository. CreateRepository(name string, opts RepositoryOptions) (Repository, error) // ImportRepository creates a new repository from a Git repository. ImportRepository(name string, remote string, opts RepositoryOptions) (Repository, error) // DeleteRepository deletes a repository. DeleteRepository(name string) error // RenameRepository renames a repository. RenameRepository(oldName, newName string) error }
RepositoryStore is an interface for managing repositories.
type SettingsBackend ¶
type SettingsBackend interface { // AnonAccess returns the access level for anonymous users. AnonAccess() AccessLevel // SetAnonAccess sets the access level for anonymous users. SetAnonAccess(level AccessLevel) error // AllowKeyless returns true if keyless access is allowed. AllowKeyless() bool // SetAllowKeyless sets whether or not keyless access is allowed. SetAllowKeyless(allow bool) error }
SettingsBackend is an interface that handles server configuration.
type User ¶
type User interface { // Username returns the user's username. Username() string // IsAdmin returns whether the user is an admin. IsAdmin() bool // PublicKeys returns the user's public keys. PublicKeys() []ssh.PublicKey }
User is an interface representing a user.
type UserAccess ¶
type UserAccess interface { // AccessLevel returns the access level of the username to the repository. AccessLevel(repo string, username string) AccessLevel // AccessLevelByPublicKey returns the access level of the public key to the repository. AccessLevelByPublicKey(repo string, pk ssh.PublicKey) AccessLevel }
UserAccess is an interface that handles user access to repositories.
type UserOptions ¶
type UserOptions struct { // Admin is whether the user is an admin. Admin bool // PublicKeys are the user's public keys. PublicKeys []ssh.PublicKey }
UserOptions are options for creating a user.
type UserStore ¶
type UserStore interface { // User finds the given user. User(username string) (User, error) // UserByPublicKey finds the user with the given public key. UserByPublicKey(pk ssh.PublicKey) (User, error) // Users returns a list of all users. Users() ([]string, error) // CreateUser creates a new user. CreateUser(username string, opts UserOptions) (User, error) // DeleteUser deletes a user. DeleteUser(username string) error // SetUsername sets the username of the user. SetUsername(oldUsername string, newUsername string) error // SetAdmin sets whether the user is an admin. SetAdmin(username string, admin bool) error // AddPublicKey adds a public key to the user. AddPublicKey(username string, pk ssh.PublicKey) error // RemovePublicKey removes a public key from the user. RemovePublicKey(username string, pk ssh.PublicKey) error // ListPublicKeys lists the public keys of the user. ListPublicKeys(username string) ([]ssh.PublicKey, error) }
UserStore is an interface for managing users.