more knecht
This commit is contained in:
@@ -8,15 +8,12 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
type Portainer struct {
|
||||
URL string `toml:"url"`
|
||||
Token string `toml:"token"`
|
||||
Endpoint string `toml:"endpoint"` // optional name override, defaults to auto-discover
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Portainer Portainer `toml:"portainer"`
|
||||
ServicesPath string `toml:"services_path"` // optional, defaults to git root / services
|
||||
URL string `toml:"url"`
|
||||
Token string `toml:"token"`
|
||||
Endpoint string `toml:"endpoint"` // optional, auto-discovered if empty
|
||||
ServicesPath string `toml:"services_path"` // optional, defaults to git root / services
|
||||
Ignore []string `toml:"ignore"`
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
@@ -28,16 +25,16 @@ func Load() (*Config, error) {
|
||||
var cfg Config
|
||||
if _, err := toml.DecodeFile(path, &cfg); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("config file not found at %s — run `knecht init` to create one", path)
|
||||
return nil, fmt.Errorf("config file not found at %s", path)
|
||||
}
|
||||
return nil, fmt.Errorf("parsing config: %w", err)
|
||||
}
|
||||
|
||||
if cfg.Portainer.URL == "" {
|
||||
return nil, fmt.Errorf("portainer.url is required in %s", path)
|
||||
if cfg.URL == "" {
|
||||
return nil, fmt.Errorf("url is required in %s", path)
|
||||
}
|
||||
if cfg.Portainer.Token == "" {
|
||||
return nil, fmt.Errorf("portainer.token is required in %s", path)
|
||||
if cfg.Token == "" {
|
||||
return nil, fmt.Errorf("token is required in %s", path)
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user