models

package
v0.0.0-...-8d48e90 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAdminConfigOptions = AdminConfigOptions{
	GitUser:      "git",
	OrgPrefix:    "@",
	UserPrefix:   "~",
	InvitePrefix: "invite:",
}

DefaultAdminConfigOptions is an object with all values set to their default.

Functions

This section is empty.

Types

type AdminConfig

type AdminConfig struct {
	Invites map[string]string           `yaml:"invites"`
	Users   map[string]*AdminConfigUser `yaml:"users"`
	Orgs    map[string]*OrgConfig       `yaml:"orgs"`
	Repos   map[string]*RepoConfig      `yaml:"repos"`
	Groups  map[string][]string         `yaml:"groups"`
	Options AdminConfigOptions          `yaml:"options"`
}

AdminConfig is the config.yml that comes from the admin repo.

func NewAdminConfig

func NewAdminConfig() *AdminConfig

NewAdminConfig returns a blank admin config with any defaults set.

func ParseAdminConfig

func ParseAdminConfig(data []byte) (*AdminConfig, error)

ParseAdminConfig will return an AdminConfig parsed from the given data. No additional validation is done.

type AdminConfigOptions

type AdminConfigOptions struct {
	// GitUser refers to which username to use as the global git user.
	GitUser string `yaml:"git_user"`

	// OrgPrefix refers to the prefix to use when cloning org repos.
	OrgPrefix string `yaml:"org_prefix"`

	// UserPrefix refers to the prefix to use when cloning user repos.
	UserPrefix string `yaml:"user_prefix"`

	// InvitePrefix refers to the prefix to use when sshing in with an invite.
	InvitePrefix string `yaml:"invite_prefix"`

	// ImplicitRepos allows a user with admin access to that area to create
	// repos by simply pushing to them.
	ImplicitRepos bool `yaml:"implicit_repos"`

	// UserConfigKeys allows users to specify ssh keys in their own config,
	// rather than relying on the main admin config.
	UserConfigKeys bool `yaml:"user_config_keys"`

	// UserConfigRepos allows users to specify repos in their own config, rather
	// than relying on the main admin config.
	UserConfigRepos bool `yaml:"user_config_repos"`

	// OrgConfig allows org admins to configure orgs in their own config, rather
	// than relying on the main admin config.
	OrgConfig bool `yaml:"org_config"`

	// OrgConfigRepos allows org admins to specify repos in their own config,
	// rather than relying on the main admin config.
	OrgConfigRepos bool `yaml:"org_config_repos"`
}

AdminConfigOptions contains all the server level settings which can be changed at runtime.

type AdminConfigUser

type AdminConfigUser struct {
	UserConfig `yaml:",inline"`

	IsAdmin  bool `yaml:"is_admin"`
	Disabled bool `yaml:"disabled"`
}

AdminConfigUser defines additional fields which main be loaded from the admin config.

func NewAdminConfigUser

func NewAdminConfigUser() *AdminConfigUser

NewAdminConfigUser returns a blank AdminConfigUser.

type OrgConfig

type OrgConfig struct {
	Admin []string               `yaml:"admin"`
	Write []string               `yaml:"write"`
	Read  []string               `yaml:"read"`
	Repos map[string]*RepoConfig `yaml:"repos"`
}

OrgConfig represents the values under orgs in the main admin config or the contents of the config file in the org config repo.

func NewOrgConfig

func NewOrgConfig() *OrgConfig

NewOrgConfig returns a new, empty OrgConfig.

func ParseOrgConfig

func ParseOrgConfig(data []byte) (*OrgConfig, error)

ParseOrgConfig will return an OrgConfig parsed from the given data. No additional validation is done.

type PrivateKey

type PrivateKey interface {
	crypto.Signer

	MarshalPrivateKey() ([]byte, error)
}

PrivateKey is a wrapper to make dealing with private keys easier to deal with.

func GenerateEd25519PrivateKey

func GenerateEd25519PrivateKey() (PrivateKey, error)

GenerateEd25519PrivateKey generates a new ed25519 private key.

func GenerateRSAPrivateKey

func GenerateRSAPrivateKey() (PrivateKey, error)

GenerateRSAPrivateKey generates a new RSA private key of size 4096.

func ParseEd25519PrivateKey

func ParseEd25519PrivateKey(data []byte) (PrivateKey, error)

ParseEd25519PrivateKey parses an ed25519 private key.

func ParseRSAPrivateKey

func ParseRSAPrivateKey(data []byte) (PrivateKey, error)

ParseRSAPrivateKey parses an RSA private key.

type PublicKey

type PublicKey struct {
	ssh.PublicKey

	Comment string
}

PublicKey is a wrapper around gossh.PublicKey to also store the comment. Note when using that pk.Marshal() handles the wire format, not the authorized keys format.

func ParsePublicKey

func ParsePublicKey(data []byte) (*PublicKey, error)

ParsePublicKey will return a PublicKey from the given data.

func (*PublicKey) MarshalAuthorizedKey

func (pk *PublicKey) MarshalAuthorizedKey() string

MarshalAuthorizedKey converts a key to the authorized keys format, including a comment.

func (*PublicKey) RawMarshalAuthorizedKey

func (pk *PublicKey) RawMarshalAuthorizedKey() string

RawMarshalAuthorizedKey converts a key to the authorized keys format, without the comment.

func (*PublicKey) String

func (pk *PublicKey) String() string

String implements fmt.Stringer.

func (*PublicKey) UnmarshalYAML

func (pk *PublicKey) UnmarshalYAML(unmarshal func(v interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.UnmarshalYAML.

type RepoConfig

type RepoConfig struct {
	// Public allows any user of the service to access this repository for
	// reading
	Public bool

	// Any user or group who explicitly has write access
	Write []string

	// Any user or group who explicitly has read access
	Read []string
}

RepoConfig represents the values under repos in the main admin config, any org configs, or any user configs.

func NewRepoConfig

func NewRepoConfig() *RepoConfig

NewRepoConfig returns a blank RepoConfig.

type UserConfig

type UserConfig struct {
	Repos map[string]*RepoConfig `yaml:"repos"`
	Keys  []PublicKey            `yaml:"keys"`
}

UserConfig represents the values under users in the main admin config or the contents of the config file in the user config repo. This type contains values shared between the different config types.

func NewUserConfig

func NewUserConfig() *UserConfig

NewUserConfig returns a new, empty UserConfig.

func ParseUserConfig

func ParseUserConfig(data []byte) (*UserConfig, error)

ParseUserConfig will return an UserConfig parsed from the given data. No additional validation is done.

Jump to

Keyboard shortcuts

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