cfg

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 10 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"`
	RepositoryLabels RepositoryLabelMap `json:"repositoryLabels" koanf:"repositoryLabels"`
}

Configuration holds a strongly-typed tree of the main configuration

func NewDefaultConfig

func NewDefaultConfig() *Configuration

NewDefaultConfig retrieves the hardcoded configs with sane defaults

type GitConfig

type GitConfig struct {
	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"`
	ShowDiff bool   `json:"showDiff" koanf:"showDiff"`
	// Shows the full log in real-time rather than keeping it hidden until an error occurred.
	ShowLog bool `json:"showLog" koanf:"showLog"`
}

LogConfig configures the logging options

type ProjectConfig

type ProjectConfig struct {
	MainConfigFileName    string `json:"-"`
	ConfigDefaultFileName string `json:"-"`

	// 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"`

	SkipBroken bool `json:"-" koanf:"skipBroken"`
}

ProjectConfig configures the main config settings

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 RepositoryLabel added in v0.2.0

type RepositoryLabel struct {
	// Name is the label name.
	Name string `json:"name" koanf:"name"`
	// Description is a short description of the label.
	Description string `json:"description" koanf:"description"`
	// Color is the hexadecimal color code for the label, without the leading #.
	Color string `json:"color" koanf:"color"`
	// Delete will remove this label.
	Delete bool `json:"delete" koanf:"delete"`
}

RepositoryLabel is a struct describing a Label on a Git hosting service like GitHub.

type RepositoryLabelConverter added in v0.2.0

type RepositoryLabelConverter struct{}

func (RepositoryLabelConverter) ConvertToEntity added in v0.2.0

func (RepositoryLabelConverter) ConvertToEntity(label RepositoryLabel) (domain.Label, error)

ConvertToEntity converts the given object to another.

type RepositoryLabelMap added in v0.2.0

type RepositoryLabelMap map[string]RepositoryLabel

func (RepositoryLabelMap) SelectDeletions added in v0.2.0

func (s RepositoryLabelMap) SelectDeletions() []RepositoryLabel

func (RepositoryLabelMap) SelectModifications added in v0.2.0

func (s RepositoryLabelMap) SelectModifications() []RepositoryLabel

func (RepositoryLabelMap) Values added in v0.2.0

func (s RepositoryLabelMap) Values() []RepositoryLabel

type RepositoryLabelSetConverter added in v0.2.0

type RepositoryLabelSetConverter struct{}

func (RepositoryLabelSetConverter) ConvertToEntity added in v0.2.0

func (RepositoryLabelSetConverter) ConvertToEntity(labels []RepositoryLabel) (domain.LabelSet, error)

ConvertToEntity converts the given object to another. Returns a non-nil empty list if labels is empty or nil.

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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