config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config provides configuration for kickoff.

Index

Constants

View Source
const (
	// DefaultProjectHost denotes the default git host that is passed to
	// templates so that project related urls can be rendered in files like
	// READMEs.
	DefaultProjectHost = "github.com"

	// DefaultRepositoryName is the name of the default skeleton repository.
	DefaultRepositoryName = "default"

	// DefaultSkeletonName is the name of the default skeleton in a repository.
	DefaultSkeletonName = "default"

	// NoLicense means that no license file will be generated for a new
	// project.
	NoLicense = "none"

	// NoGitignore means that no .gitignore file will be generated for a new
	// project.
	NoGitignore = "none"
)

Variables

View Source
var (
	// LocalConfigDir points to the user's local configuration dir which is
	// platform specific.
	LocalConfigDir = configdir.LocalConfig("kickoff")

	// DefaultConfigPath holds the default kickof config path in the user's
	// local config directory.
	DefaultConfigPath = filepath.Join(LocalConfigDir, "config.yaml")

	// DefaultRepositoryURL is the url of the default skeleton repository if
	// the user did not configure anything else.
	DefaultRepositoryURL = "https://github.com/martinohmann/kickoff-skeletons"
)

Functions

func Save

func Save(config *Config, path string) error

Save saves config to path.

Types

type Config

type Config struct {
	Project      Project           `json:"project"`
	Repositories map[string]string `json:"repositories"`
	Values       template.Values   `json:"values"`
}

Config is the type for user-defined configuration.

func Load

func Load(path string) (Config, error)

Load loads the config from path and returns it.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults applies default values to the config.

func (*Config) MergeFromFile

func (c *Config) MergeFromFile(path string) error

MergeFromFile loads the config from path and merges it into c. Returns any errors that may occur during loading or merging. Non-zero fields in c will not be overridden if present in the file at path.

type Project

type Project struct {
	Host      string `json:"host"`
	Owner     string `json:"owner"`
	Email     string `json:"email"`
	Name      string `json:"-"`
	License   string `json:"license"`
	Gitignore string `json:"gitignore"`
}

Project contains project specific configuration like author, email address and project name.

func (*Project) ApplyDefaults

func (p *Project) ApplyDefaults()

ApplyDefaults applies defaults to unset fields. If the Owner and Email fields are empty ApplyDefaults will attempt to fill them with the git config values of github.user/user.name and user.email if they exist.

func (*Project) Author

func (p *Project) Author() string

Author returns a string that can be used in licenses. If an email address is configured, this will look like `Owner <Email>`. `Owner` otherwise.

func (*Project) GoPackagePath

func (p *Project) GoPackagePath() string

GoPackagePath returns a string that can be used as a Golang package path for the project.

func (*Project) HasGitignore

func (p *Project) HasGitignore() bool

HasGitignore returns true if a gitignore template is specified in the project config. If true, the project creator will write the gitignore template into the .gitignore file in the project's output directory.

func (*Project) HasLicense

func (p *Project) HasLicense() bool

HasLicense returns true if an open source license is specified in the project config. If true, the project creator will write the text of the provided license into the LICENSE file in the project's output directory.

func (*Project) URL

func (p *Project) URL() string

URL returns the repository url.

Jump to

Keyboard shortcuts

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