config

package
v0.0.0-...-d280c18 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: GPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{

	Sqlite: Sqlite{
		Path:  cfgpath.DataPath,
		Mkdir: true,
	},
	Client: ClientTypeSqlite,
	GRPC: GRPC{
		Address: "localhost:59122",
	},
	Daemon: Daemon{
		BindAddress: "localhost:59122",
	},
	Log: Log{
		Format: LogFormatPretty,
		Level:  LogLevel(logger.LevelInfo),
		Color:  LogColorAuto,
	},
	// contains filtered or unexported fields
}

Functions

func AddDefaults

func AddDefaults(v *viper.Viper) error

func AddFile

func AddFile(v *viper.Viper, file string) error

AddFile uses the Default configs and then merges the config from a specific file. The function will error if the file does not exist.

func AddStandardFiles

func AddStandardFiles(v *viper.Viper) error

AddStandardFiles uses the Default configs and then merges the config from first file it finds in the following list:

- /etc/dinkur/dinkur.yaml - ~/.config/dinkur.yaml - ~/.dinkur.yaml ~ .dinkur.yaml (current directory)

Where the first one found will be used.

func JSONSchema

func JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema struct for the Config struct.

func Unmarshal

func Unmarshal(v *viper.Viper, cfg *Config) error

Unmarshal will read the config file from github.com/spf13/viper using the appropriate decoding options.

Types

type ClientType

type ClientType string
const (
	ClientTypeSqlite ClientType = "sqlite"
	ClientTypeGRPC   ClientType = "grpc"
)

func (ClientType) JSONSchema

func (ClientType) JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema struct for this struct.

func (*ClientType) Set

func (f *ClientType) Set(value string) error

func (ClientType) String

func (f ClientType) String() string

func (*ClientType) Type

func (f *ClientType) Type() string

func (*ClientType) UnmarshalText

func (f *ClientType) UnmarshalText(text []byte) error

type Config

type Config struct {
	Client ClientType
	Sqlite Sqlite
	GRPC   GRPC
	Daemon Daemon

	Log Log
	// contains filtered or unexported fields
}

func ReadFile

func ReadFile(v *viper.Viper, file string) (*Config, error)

func ReadStandardFiles

func ReadStandardFiles(v *viper.Viper) (*Config, error)

func (*Config) FileUsed

func (c *Config) FileUsed() string

type Daemon

type Daemon struct {
	// BindAddress defines which IP/hostname and port to serve the gRPC API on.
	// Can be set to 0.0.0.0 as IP to allow access from any IP.
	BindAddress string
}

type GRPC

type GRPC struct {
	// Address defines which IP/hostname and port to reach the API on.
	Address string
}

type Log

type Log struct {
	// Format defines how the logs are printed to the console, either "pretty"
	// for human readable, or "json" for machine readable.
	Format LogFormat
	// Level defines the logging severity level. All log messages below this
	// config will not be logged.
	Level LogLevel
	// Color defines if the log output should be colored. Defaults to "auto",
	// where it will only use colors if it detects interactive TTY, but
	// options "always" and "never" can override this.
	Color LogColor
}

type LogColor

type LogColor string
const (
	LogColorAuto   LogColor = "auto"
	LogColorNever  LogColor = "never"
	LogColorAlways LogColor = "always"
)

func (LogColor) JSONSchema

func (LogColor) JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema struct for this struct.

func (*LogColor) Set

func (f *LogColor) Set(value string) error

func (LogColor) String

func (f LogColor) String() string

func (*LogColor) Type

func (f *LogColor) Type() string

func (*LogColor) UnmarshalText

func (f *LogColor) UnmarshalText(text []byte) error

type LogFormat

type LogFormat string
const (
	LogFormatPretty LogFormat = "pretty"
	LogFormatJSON   LogFormat = "json"
)

func (LogFormat) JSONSchema

func (LogFormat) JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema struct for this struct.

func (*LogFormat) Set

func (f *LogFormat) Set(value string) error

func (LogFormat) String

func (f LogFormat) String() string

func (*LogFormat) Type

func (f *LogFormat) Type() string

func (*LogFormat) UnmarshalText

func (f *LogFormat) UnmarshalText(text []byte) error

type LogLevel

type LogLevel logger.Level

func (LogLevel) JSONSchema

func (LogLevel) JSONSchema() *jsonschema.Schema

JSONSchema returns the JSON schema struct for this struct.

func (LogLevel) MarshalText

func (l LogLevel) MarshalText() ([]byte, error)

func (*LogLevel) Set

func (l *LogLevel) Set(value string) error

func (LogLevel) String

func (l LogLevel) String() string

func (*LogLevel) Type

func (l *LogLevel) Type() string

func (*LogLevel) UnmarshalText

func (l *LogLevel) UnmarshalText(text []byte) error

type Sqlite

type Sqlite struct {
	// Path is the file path of where to store the sqlite database file, i.e
	// the file containing all the time-tracked entries.
	Path string
	// Mkdir will enable creating any missing directories for the data
	// directory, if set to true. Will fail if directories don't exist and
	// this is set to false.
	Mkdir bool
}

Jump to

Keyboard shortcuts

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