badgeconfig

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigLoading = errors.New("error while loading configuration")
)

Functions

func Decoder

func Decoder(target interface{}, allowUnused bool) (*mapstructure.Decoder, error)

Decoder returns the decoder for config maps.

Types

type BadgeDefinition

type BadgeDefinition struct {
	BadgeDesc   `mapstructure:",squash"`
	Target      string            `mapstructure:"target" help:"target URL to resolve badge data from"`
	Parameters  map[string]string `mapstructure:"parameters" help:"Accepted parameters for the interface"`
	Example     map[string]string `mapstructure:"example" help:"Prefilled parameters to display an example badge"`
	Description string            `mapstructure:"description"`
}

type BadgeDesc

type BadgeDesc struct {
	Label   string `mapstructure:"label" help:"Label template"`
	Message string `mapstructure:"message" help:"Message template"`
	Color   string `mapstructure:"color" help:"Color template"`
}

type Config

type Config struct {
	PredefinedBadges map[string]BadgeDefinition `mapstructure:"predefined_badges"`
}

func Load

func Load(configData []byte) (*Config, error)

Load loads a configuration file from the supplied bytes.

func LoadDir

func LoadDir(dirPath string) (*Config, error)

LoadDir loads a directory of predefined badge configuration files.

type URL

type URL struct {
	*url.URL
}

URL is a custom URL type that allows validation at configuration load time.

func NewURL

func NewURL(url string) (URL, error)

func (*URL) MarshalText

func (u *URL) MarshalText() ([]byte, error)

MarshalYAML implements the yaml.Marshaler interface for URLs.

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) error

UnmarshalYAML implements the yaml.Unmarshaler interface for URLs.

Jump to

Keyboard shortcuts

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