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:
parent
49faaf5325
commit
4a5cff20cd
4 changed files with 4 additions and 0 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue