cfg

package
v0.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseConfig

func ParseConfig(configPath string, config *Configuration, ctx *cli.Context) error

ParseConfig overrides given config defaults from file and with environment variables.

Types

type Configuration

type Configuration struct {
	Project     *ProjectConfig     `json:"project" koanf:"project"`
	Log         *LogConfig         `json:"log" koanf:"log"`
	PullRequest *PullRequestConfig `json:"pr" koanf:"pr"`
	Template    *TemplateConfig    `json:"template" koanf:"template"`
	Git         *GitConfig         `json:"git" koanf:"git"`
}

Configuration holds a strongly-typed tree of the main configuration

func NewDefaultConfig

func NewDefaultConfig() *Configuration

NewDefaultConfig retrieves the hardcoded configs with sane defaults

func (*Configuration) Sanitize

func (config *Configuration) Sanitize()

Sanitize does corrective actions on the configuration hierarchy.

type GitConfig

type GitConfig struct {
	// Url is the full Git URL to the remote repository.
	// This option is not configurable in `greposync.yml`.
	// In templates, the URL is looking like “
	Url *url.URL `json:"-"`
	// Dir is the relative path to current working directory where the repository is cloned locally.
	// This option is not configurable in `greposync.yml`.
	Dir        string `json:"-"`
	SkipReset  bool   `json:"skipReset"`
	SkipCommit bool   `json:"skipCommit"`
	SkipPush   bool   `json:"skipPush"`
	ForcePush  bool   `json:"forcePush"`
	// Amend will amend the last commit.
	// This option is not configurable in `greposync.yml`.
	// Configurable only via environment variables or CLI flag.
	Amend bool `json:"-" koanf:"amend"`
	// CommitMessage is the string that is passed to `git commit`.
	// It can contain newlines, for example to pass a long description.
	CommitMessage string `json:"commitMessage" koanf:"commitMessage"`
	CommitBranch  string `json:"commitBranch" koanf:"commitBranch"`
	// DefaultBranch is the name of the default branch in origin.
	DefaultBranch string `json:"defaultBranch"`
	// Name is the git repository name without .git extension.
	Name string `json:"name"`
	// Namespace is the repository owner without the repository name.
	// This is often a user or organization name in GitHub.com or GitLab.com.
	Namespace string `json:"namespace"`
}

GitConfig configures a git repository. This structure is used to configuring the sync behaviour It is also passed to templates with filled-in information

type LogConfig

type LogConfig struct {
	Level string `json:"level" koanf:"level"`
}

LogConfig configures the logging options

type ProjectConfig

type ProjectConfig struct {
	// RootDir is the local directory where the Git repositories are cloned into.
	RootDir string `json:"rootDir" koanf:"rootDir"`
	// Jobs is the number of parallel jobs to run.
	// Requires a minimum of 1, supports a maximum of 8.
	// 1 basically means that jobs are run in sequence.
	// If this number is 2 or greater, then the logs are buffered and only displayed in case of errors.
	Jobs int `json:"jobs" koanf:"jobs"`
	// Include is a regex filter that includes repositories only when they match.
	// The filter is applied to the whole URL.
	// This option is not configurable in `greposync.yml`.
	Include string `json:"-" koanf:"include"`
	// Exclude is similar to Include, only that matching repository URLs are skipped.
	// This option is not configurable in `greposync.yml`.
	Exclude string `json:"-" koanf:"exclude"`
}

ProjectConfig configures the project

type PullRequestConfig

type PullRequestConfig struct {
	Create bool `json:"create" koanf:"create"`
	// TargetBranch is the target remote branch of the pull request.
	// If left empty, it will target the default branch.
	TargetBranch string `json:"targetBranch" koanf:"targetBranch"`
	// Labels is an array of issue labels to apply when creating a pull request.
	// Labels on existing pull requests are not updated.
	// It is not validated whether the labels exist, the API may or may not create non-existing labels dynamically.
	Labels []string `json:"labels" koanf:"labels"`
	// BodyTemplate is the description used in pull requests.
	// Supports Go template with the `.Metadata` key.
	// If this string is a relative path to an existing file in the greposync directory, the file is parsed as a Go template.
	// If empty, the CommitMessage is used.
	BodyTemplate string `json:"bodyTemplate" koanf:"bodyTemplate"`
	// Subject is the Pull Request title.
	Subject string `json:"subject" koanf:"subject"`
}

PullRequestConfig configures the pull request feature

type SyncConfig

type SyncConfig struct {
	PullRequest *PullRequestConfig `json:"pullRequest"`
	Git         *GitConfig         `json:"git"`
	Template    *TemplateConfig    `json:"template"`
}

SyncConfig configures a single repository sync

type TemplateConfig

type TemplateConfig struct {
	// RootDir is the path relative to the current workdir where the template files are located.
	RootDir string `json:"rootDir" koanf:"rootDir"`
}

TemplateConfig configures template settings

Jump to

Keyboard shortcuts

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