paulopacitti / bacon

🥓 cli to update the public IP of your domain registered in Porkbun
MIT License
14 stars 2 forks source link

Create a dedicated package for config management #2

Open pedromotita opened 4 months ago

pedromotita commented 4 months ago

Description

Instead of calling config from the CLI layer, create a dedicated package. Viper would be wrapped in this package, and would not appear anywhere in the code, all config management would be done by the config package.

It's API could look something like:

type PorkbunAPIConfig struct {
    Key       string `json:"key"`
    SecretKey string `json:"secretKey"`
    Domain    string `json:"domain"`
    Subdomain string `json:"subdomain"`
    Type      string `json:"type"`
}

type Config struct{}

func (c *Config) Get() (PorkbunAPIConfig, error)
func (c *Config) GetKey(key string) (PorkbunAPIConfig, error)
func (c *Config) Set(key, value string) error
func (c *Config) Delete(key) error
paulopacitti commented 4 months ago

I think it's a great refactor from what we have now, great suggestion!