forked from aristanetworks/openconfigbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (34 loc) · 1017 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2016 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the LICENSE file.
package main
import (
"fmt"
"os"
"github.com/aristanetworks/openconfigbeat/cmd"
"github.com/aristanetworks/openconfigbeat/gen/fields"
"github.com/aristanetworks/openconfigbeat/gen/openconfigbeat"
)
const (
fieldsFile = "fields.yml"
openconfigFile = "openconfigbeat.yml"
)
func main() {
if _, err := os.Stat(openconfigFile); os.IsNotExist(err) {
fmt.Printf("%s not found, generating the default one\n", openconfigFile)
if err = openconfigbeat.RestoreAssets(".", openconfigFile); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}
if _, err := os.Stat(fieldsFile); os.IsNotExist(err) {
fmt.Printf("%s not found, generating the default one\n", fieldsFile)
if err = fields.RestoreAssets(".", fieldsFile); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}
if err := cmd.RootCmd.Execute(); err != nil {
os.Exit(1)
}
}