config

package
v0.0.0-...-b6ab1de Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRepositoryDir = "docs/decisions"
	DefaultConfigExt     = "yaml"
	DefaultConfigName    = ".adr"
)

Variables

This section is empty.

Functions

func Find

func Find(repoDir string, num int) (string, error)

Find will return the repoDir/NNN-file-name.md for the specified ADR number if it exists in the repoDir

func Link(p *LinkPair) error

Link will use the LinkPair to insert links into the 'Status' section

func Sanitize

func Sanitize(title string) string

Sanitize ensures that the given string matches Title expectations (e.g. lowercase, no spaces, etc)

func Supersede

func Supersede(p *LinkPair) error

Supersede will change the Source status to 'Superseded' and link to the Target. It will also append the 'Supersedes' backlink to the Target status

func UpdateStatus

func UpdateStatus(path, to string) error

UpdateStatus will search for the Status section and replace the existing status with the 'to' status

Types

type ADR

type ADR struct {
	FormatName    string
	TitleTemplate string
	BodyTemplate  string
}

func (*ADR) New

func (a *ADR) New(repoDir string, values map[string]string) error

New will create a new ADR using the in-memory configuration. It will determine the next number for the new ADR and write a new file to repoDir

type Config

type Config struct {
	WorkingDirectory string `yaml:"-"`
	CfgFileName      string `yaml:"-"`
	CfgFileExt       string `yaml:"-"`
	*Repository
	*ADR
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) CreateAndWrite

func (c *Config) CreateAndWrite() error

CreateAndWrite creates a file from the current structs values and then calls Write with it

func (*Config) EnsureRepositoryExists

func (c *Config) EnsureRepositoryExists() error

EnsureRepositoryExists creates the repository directory if it doesn't exist. ADRs will be stored in this directory

func (*Config) Managed

func (c *Config) Managed() (bool, error)

Managed checks if the current working directory is already managed by this tool

func (*Config) Write

func (c *Config) Write(w io.Writer) error

Write writes the current struct to the given io.Writer

type LinkPair

type LinkPair struct {
	SourceNum int
	TargetNum int
	SourceMsg string
	BackMsg   string
	RepoDir   string
}

type Repository

type Repository struct {
	Path string `yaml:"path"`
}

Repository contains the metadata for an ADR repository (e.g. configurations, path, etc)

Jump to

Keyboard shortcuts

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