config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteDefaultConfig

func WriteDefaultConfig(path string) error

WriteDefaultConfig writes a default configuration file to the specified path

Types

type Config

type Config struct {
	Logging struct {
		Level     string `mapstructure:"level" yaml:"level"`
		Format    string `mapstructure:"format" yaml:"format"`
		Debug     bool   `mapstructure:"debug" yaml:"debug"`
		Directory string `mapstructure:"directory" yaml:"directory"`
		Filename  string `mapstructure:"filename" yaml:"filename"`
	} `mapstructure:"logging" yaml:"logging"`

	Server struct {
		SpecsDir string `mapstructure:"specs_dir" yaml:"specs_dir"`
	} `mapstructure:"server" yaml:"server"`

	GitHub struct {
		Token string `mapstructure:"token" yaml:"token"`
	} `mapstructure:"github" yaml:"github"`

	Specs []string `mapstructure:"specs" yaml:"specs"`
	Path  string   `yaml:"-"` // Not saved to YAML, just for reference
}

Config represents the application configuration

func LoadConfig

func LoadConfig(configFile string, logger LoggerInterface, verbose bool) (*Config, error)

LoadConfig loads configuration from a file

func (*Config) AddSpec

func (c *Config) AddSpec(url string)

AddSpec adds a spec to the config

func (*Config) GetGitHubToken

func (c *Config) GetGitHubToken() string

GetGitHubToken returns the GitHub API token

func (*Config) GetSpecs

func (c *Config) GetSpecs() []string

GetSpecs returns the list of API specs to load

func (*Config) HasSpec

func (c *Config) HasSpec(url string) bool

HasSpec returns true if the given URL is already in the config

func (*Config) RemoveSpec

func (c *Config) RemoveSpec(url string)

RemoveSpec removes a spec from the config

func (*Config) Save

func (c *Config) Save() error

Save writes the config to disk

func (*Config) ShouldUpdateConfig

func (c *Config) ShouldUpdateConfig() bool

ShouldUpdateConfig returns true if the config file should be updated

type LoggerInterface

type LoggerInterface interface {
	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
}

LoggerInterface defines the required logging methods

Jump to

Keyboard shortcuts

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