1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-03 11:53:41 +02:00

app/config: Adding description to methods.

This commit is contained in:
Henrik Hautakoski 2024-02-12 15:13:09 +01:00
parent 49faaf5325
commit 4a5cff20cd
4 changed files with 4 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
// Read cli flag values into the config
func (cfg *Config) ReadCliFlags(ctx *cli.Context) error { func (cfg *Config) ReadCliFlags(ctx *cli.Context) error {
logFile := ctx.Path("log") logFile := ctx.Path("log")
if len(logFile) > 0 { if len(logFile) > 0 {

View file

@ -43,6 +43,7 @@ type Config struct {
Telegram TelegramConfig `yaml:"telegram"` Telegram TelegramConfig `yaml:"telegram"`
} }
// Create a new Config object with default values
func New() Config { func New() Config {
return Config{ return Config{
MessageCodec: "json", MessageCodec: "json",

View file

@ -4,6 +4,7 @@ import (
"os" "os"
) )
// Read values from file
func (cfg *Config) ReadFile(filename string) error { func (cfg *Config) ReadFile(filename string) error {
bytes, err := os.ReadFile(filename) bytes, err := os.ReadFile(filename)
if err != nil { if err != nil {

View file

@ -20,6 +20,7 @@ func (ship *ShipConfig) UnmarshalYAML(value *yaml.Node) error {
return err return err
} }
// Read YAML config data
func (cfg *Config) ReadYAML(data []byte) error { func (cfg *Config) ReadYAML(data []byte) error {
return yaml.Unmarshal(data, cfg) return yaml.Unmarshal(data, cfg)
} }