badgeconfig

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 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"`
	Examples    []BadgeExample    `mapstructure:"examples" help:"List of example badges to include"`
	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 BadgeExample added in v0.0.3

type BadgeExample struct {
	Description string `mapstructure:"description" help:"description of the badge example"`
	Parameters  map[string]string
}

BadgeExample defines an example of a predefined badge. It can be used to present common badges on the main UI. Multiple examples can be defined.

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