Documentation ¶
Overview ¶
Package appconfig loads repository configuration for GitHub apps. It supports loading directly from a file in a repository, loading from remote references, and loading an organization-level default. The config itself can be in any format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Content []byte // Source contains the repository and ref in "owner/name@ref" format. The // ref component ("@ref") is optional and may not be present. Source string Path string IsRemote bool }
Config contains unparsed configuration data and metadata about where it was found.
func (Config) IsUndefined ¶
IsUndefined returns true if the Config's content is empty and there is no metadata giving a source.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads configuration for repositories.
func (*Loader) LoadConfig ¶
func (ld *Loader) LoadConfig(ctx context.Context, client *github.Client, owner, repo, ref string) (Config, error)
LoadConfig loads configuration for the repository owner/repo. It first tries the Loader's paths in order, following remote references if they exist. If no configuration exists at any path in the repository, it tries to load default configuration defined by owner for all repositories. If no default configuration exists, it returns an undefined Config and a nil error.
If error is non-nil, the Source and Path fields of the returned Config tell which file LoadConfig was processing when it encountered the error.
type Option ¶
type Option func(*Loader)
func WithOwnerDefault ¶
WithOwnerDefault sets the owner repository and paths to check when a repository does not define its own configuration. By default, the repository name is ".github" and the paths are those passed to the loader with the ".github/" prefix removed. Set an empty repository name to disable owner defaults.
func WithRemoteRefParser ¶
func WithRemoteRefParser(parser RemoteRefParser) Option
WithRemoteRefParser sets the parser for encoded RemoteRefs. The default parser uses YAML. Set a nil parser to disable remote references.
type RemoteRef ¶
type RemoteRef struct { // The repository in "owner/name" format. Required. Remote string `yaml:"remote" json:"remote"` // The path to the config file in the repository. If empty, use the first // path configured in the loader. Path string `yaml:"path" json:"path"` // The reference (branch, tag, or SHA) to read in the repository. If empty, // use the default branch of the repository. Ref string `yaml:"ref" json:"ref"` }
RemoteRef identifies a configuration file in a different repository.
func YAMLRemoteRefParser ¶
YAMLRemoteRefParser parses b as a YAML-encoded RemoteRef. It assumes all parsing errors mean the content is not a RemoteRef.