config

package
v0.0.0-...-7954b2e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config provides the functionality to parse a commonrepo configuration file

Package config provides config parsing and other helpers

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRenameInvalid = errors.New("rename entry is not valid")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Include      []string               // File globs to include
	Exclude      []string               // File globs to exclude
	Template     []string               // File globs to treat as templates
	TemplateVars map[string]interface{} // Map of template variables
	Install      []Install              // List of tool versions to install
	InstallFrom  string                 // Path to install from
	InstallWith  []string               // Priority list of install managers to use
	Rename       []Rename               // Rename regex rules to apply to files
	Upstream     []Upstream             // List of upstream CommonRepos
}

Config provides the desired configuration for the commonrepo

func ParseConfig

func ParseConfig(data []byte) (config *Config, err error)

ParseConfig takes yaml data and returns a Config instance

func (*Config) ApplyRename

func (config *Config) ApplyRename(path string) string

ApplyRename modifies the given path according to the rename rules

type Install

type Install struct {
	Name    string
	Version *semver.Constraints
}

type Rename

type Rename struct {
	Match   *regexp.Regexp
	Replace string
}

Rename is a parsed rename structure which transforms paths within the repository

func (*Rename) Apply

func (rename *Rename) Apply(path string) string

Apply transforms the given path using the rename rule

func (*Rename) Check

func (rename *Rename) Check(path string) bool

Check tests whether a rename applies to a given path

func (*Rename) String

func (rename *Rename) String() string

String gives us a string representation of the rename

type Upstream

type Upstream struct {
	URL     string
	Ref     string
	Include []string
	Exclude []string
	Rename  []Rename
}

type YamlConfig

type YamlConfig struct {
	// Source options
	YamlSource  `yaml:",inline"`
	Template    []string            `yaml:"template"`
	Install     []map[string]string `yaml:"install"`
	InstallFrom string              `yaml:"install-from"`
	InstallWith []string            `yaml:"install-with"`
	// Consumer options
	Upstream     []yamlUpstream         `yaml:"upstream"`
	TemplateVars map[string]interface{} `yaml:"template-vars"`
	// contains filtered or unexported fields
}

func YamlParse

func YamlParse(data []byte) (config *YamlConfig, err error)

YamlParse returns a YamlConfig instance from the given data

func (*YamlConfig) Raw

func (config *YamlConfig) Raw() string

Raw returns the raw yaml data

func (*YamlConfig) Unmarshal

func (config *YamlConfig) Unmarshal(data []byte) (err error)

Unmarshal data into this YamlConfig

type YamlSource

type YamlSource struct {
	Include []string
	Exclude []string
	Rename  []map[string]string
}

Jump to

Keyboard shortcuts

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