config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Providers CacheProviders
	Slack     CacheSlack
}

Cache holds the configuration regarding the scheduling of cache updates

type CacheProviders

type CacheProviders struct {
	UpdateRepositories     CacheProvidersUpdateRepositories     `json:"update_repositories" yaml:"update_repositories"`
	UpdateRepositoriesRefs CacheProvidersUpdateRepositoriesRefs `json:"update_repositories_refs" yaml:"update_repositories_refs"`
}

CacheProviders ..

type CacheProvidersUpdateRepositories

type CacheProvidersUpdateRepositories struct {
	OnStart      bool `default:"true" json:"on_start" yaml:"on_start"`
	EverySeconds int  `default:"3600" json:"every_seconds" yaml:"on_schedule"`
}

CacheProvidersUpdateRepositories ..

type CacheProvidersUpdateRepositoriesRefs

type CacheProvidersUpdateRepositoriesRefs struct {
	OnStart      bool `default:"false" json:"on_start" yaml:"on_start"`
	EverySeconds int  `json:"every_seconds" yaml:"on_schedule"`
}

CacheProvidersUpdateRepositoriesRefs ..

type CacheSlack

type CacheSlack struct {
	UpdateUsersEmails CacheSlackUpdateUsersEmails `json:"update_users_emails" yaml:"update_users_emails"`
}

CacheSlack ..

type CacheSlackUpdateUsersEmails

type CacheSlackUpdateUsersEmails struct {
	OnStart      bool `default:"true" json:"on_start" yaml:"on_start"`
	EverySeconds int  `default:"86400" json:"every_seconds" yaml:"on_schedule"`
}

CacheSlackUpdateUsersEmails ..

type Config

type Config struct {
	Cache         Cache
	Providers     Providers `validate:"gt=0,unique=Type"`
	ListenAddress string    `default:":8080" validate:"required"`
	Log           Log
	Slack         Slack
	Users         Users
}

Config represents all the parameters required for the app to be configured properly

func NewConfig

func NewConfig() (cfg Config)

NewConfig returns a new Config with default values

func Parse

func Parse(f Format, bytes []byte) (Config, error)

Parse unmarshal provided bytes with given ConfigType into a Config object

func ParseFile

func ParseFile(filename string) (c Config, err error)

ParseFile reads the content of a file and attempt to unmarshal it into a Config

func (Config) Validate

func (c Config) Validate() error

Validate will throw an error if the Config parameters are whether incomplete or incorrects

type Format

type Format uint8

Format represents the format of the config file

const (
	// FormatJSON represents a Config written in json format
	FormatJSON Format = iota

	// FormatYAML represents a Config written in yaml format
	FormatYAML
)

func GetTypeFromFileExtension

func GetTypeFromFileExtension(filename string) (f Format, err error)

GetTypeFromFileExtension returns the ConfigType based upon the extension of the file

type Log

type Log struct {
	Level  string `default:"info" validate:"required,oneof=trace debug info warning error fatal panic"`
	Format string `default:"text" validate:"oneof=text json"`
}

Log holds runtime logging configuration

type Provider

type Provider struct {
	Type   string `validate:"oneof=github gitlab"`
	URL    string
	Token  string   `validate:"required"`
	Owners []string `validate:"gt=0"`
}

Provider holds the configuration of a git provider

type Providers

type Providers []Provider

Providers is a slice of Provider

type Slack

type Slack struct {
	Token         string `validate:"required"`
	SigningSecret string `validate:"required" json:"signing_secret" yaml:"signing_secret"`
}

Slack holds Slack related configuration

type User

type User struct {
	Email   string   `validate:"required,email"`
	Aliases []string `validate:"gt=0"`
}

User can be used to alias email addresses for a Slack user

type Users

type Users []User

Users is a slice of User

Jump to

Keyboard shortcuts

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