Move throwaway parsing type into NewSources

pull/10616/head
Jared Scheib 2017-07-06 11:57:02 -07:00
parent 3c3602a724
commit 340ed6f40e
1 changed files with 5 additions and 6 deletions

View File

@ -626,17 +626,16 @@ type LayoutStore interface {
Update(context.Context, Layout) error
}
// SourceAndKapacitor allows a --new-source to be parsed into a source and a kapacitor
type SourceAndKapacitor struct {
Source Source `json:"influxdb"`
Kapacitor Server `json:"kapacitor"`
}
// NewSources adds sources and respective kapacitors to BoltDb idempotently by name
func NewSources(ctx context.Context, sourcesStore SourcesStore, serversStore ServersStore, newSources string, logger Logger) error {
// Once a bolt connection is created, try to add any new sources with respective kapacitor servers
if newSources != "" {
type SourceAndKapacitor struct {
Source Source `json:"influxdb"`
Kapacitor Server `json:"kapacitor"`
}
var srcsKaps []SourceAndKapacitor
// On JSON unmarshal error, continue server process without new source and write error to log
if err := json.Unmarshal([]byte(newSources), &srcsKaps); err != nil {
logger.