-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (45 loc) · 1020 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"io"
"log"
"os"
)
const (
TailSleep = 5
ResponseTimeout = 10
AuthTypeAWS = "aws"
AuthTypeBasic = "basic"
SearchRequestSize = 10000
)
var (
version = ""
commit = ""
date = ""
)
var DebugLogger = log.New(io.Discard, "DEBUG: ", log.Ldate|log.Ltime|log.Lshortfile)
func FatalError(err error) {
fmt.Fprintf(os.Stderr, "clibana: %v\n", err)
os.Exit(1)
}
func main() {
clibanaConfig := NewClibanaConfig()
if clibanaConfig.Debug {
DebugLogger.SetOutput(os.Stderr)
}
client, err := createClient(clibanaConfig)
if err != nil {
FatalError(fmt.Errorf("Failed to create OpenSearch client: %w", err))
}
DebugLogger.Printf("Configuration: %+v\n", clibanaConfig)
switch {
case clibanaConfig.Search != nil:
search(client, clibanaConfig)
case clibanaConfig.Mappings != nil:
mappings(client, clibanaConfig)
case clibanaConfig.Indices != nil:
indices(client, clibanaConfig)
default:
FatalError(fmt.Errorf("no subcommand specified"))
}
}