Better validation of all config file fields (#6090)

Add Validate() to serverConfig to call it at server
startup and in Admin SetConfig handler to minimize
errors scenario after server restart.
This commit is contained in:
Anis Elleuch
2018-07-18 20:22:29 +02:00
committed by kannappanr
parent 758a80e39b
commit e8a008f5b5
14 changed files with 375 additions and 54 deletions

View File

@@ -18,6 +18,7 @@ package target
import (
"encoding/json"
"errors"
"net/url"
"github.com/minio/minio/pkg/event"
@@ -45,6 +46,32 @@ type NATSArgs struct {
} `json:"streaming"`
}
// Validate NATSArgs fields
func (n NATSArgs) Validate() error {
if !n.Enable {
return nil
}
if n.Address.IsEmpty() {
return errors.New("empty address")
}
if n.Subject == "" {
return errors.New("empty subject")
}
if n.Streaming.Enable {
if n.Streaming.ClusterID == "" {
return errors.New("empty cluster id")
}
if n.Streaming.ClientID == "" {
return errors.New("empty client id")
}
}
return nil
}
// NATSTarget - NATS target.
type NATSTarget struct {
id event.TargetID