Added http support
This commit is contained in:
parent
2bc93bf707
commit
12b106cda5
26
elastop.go
26
elastop.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -515,12 +516,32 @@ func updateGridLayout(grid *tview.Grid, showRoles, showIndices, showMetrics bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
host := flag.String("host", "localhost", "Elasticsearch host")
|
host := flag.String("host", "http://localhost", "Elasticsearch host URL (e.g., http://localhost or https://example.com)")
|
||||||
port := flag.Int("port", 9200, "Elasticsearch port")
|
port := flag.Int("port", 9200, "Elasticsearch port")
|
||||||
user := flag.String("user", "elastic", "Elasticsearch username")
|
user := flag.String("user", "elastic", "Elasticsearch username")
|
||||||
password := flag.String("password", os.Getenv("ES_PASSWORD"), "Elasticsearch password")
|
password := flag.String("password", os.Getenv("ES_PASSWORD"), "Elasticsearch password")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
// Validate and process the host URL
|
||||||
|
if !strings.HasPrefix(*host, "http://") && !strings.HasPrefix(*host, "https://") {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: host must start with http:// or https://\n")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip any trailing slash from the host
|
||||||
|
*host = strings.TrimRight(*host, "/")
|
||||||
|
|
||||||
|
// Create custom HTTP client with SSL configuration
|
||||||
|
tr := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
InsecureSkipVerify: true, // Allow self-signed certificates
|
||||||
|
},
|
||||||
|
}
|
||||||
|
client := &http.Client{
|
||||||
|
Transport: tr,
|
||||||
|
Timeout: time.Second * 10,
|
||||||
|
}
|
||||||
|
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
|
|
||||||
// Update the grid layout to use three columns for the bottom section
|
// Update the grid layout to use three columns for the bottom section
|
||||||
@ -558,8 +579,7 @@ func main() {
|
|||||||
|
|
||||||
// Update function
|
// Update function
|
||||||
update := func() {
|
update := func() {
|
||||||
baseURL := fmt.Sprintf("http://%s:%d", *host, *port)
|
baseURL := fmt.Sprintf("%s:%d", *host, *port)
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
// Helper function for ES requests
|
// Helper function for ES requests
|
||||||
makeRequest := func(path string, target interface{}) error {
|
makeRequest := func(path string, target interface{}) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user