This commit is contained in:
2026-07-07 09:22:18 +02:00
parent f10366dbde
commit 24038e36f7
7 changed files with 12 additions and 25 deletions

View File

@@ -26,7 +26,7 @@ import (
func addReference(ref string) string { func addReference(ref string) string {
indentedRef := []string{} indentedRef := []string{}
for _, line := range strings.Split(ref, "\n") { for line := range strings.SplitSeq(ref, "\n") {
indentedRef = append(indentedRef, " "+line) indentedRef = append(indentedRef, " "+line)
} }
return fmt.Sprintf("%s\nREFERENCE:\n%s\n", return fmt.Sprintf("%s\nREFERENCE:\n%s\n",

2
go.mod
View File

@@ -14,7 +14,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
module codeberg.org/scip/esctl module codeberg.org/scip/esctl
go 1.25.8 go 1.26.4
require ( require (
github.com/MichaelMure/go-term-markdown v0.1.4 github.com/MichaelMure/go-term-markdown v0.1.4

View File

@@ -44,16 +44,14 @@ func ClusterList(conf *cfg.Config) error {
// check endpoints in parallel to speed things up // check endpoints in parallel to speed things up
for name, cluster := range conf.Clusters { for name, cluster := range conf.Clusters {
wg.Add(1)
go func() { wg.Go(func() {
defer wg.Done()
online, err := cluster.IsReachable() online, err := cluster.IsReachable()
mu.Lock() mu.Lock()
reachable[name] = clusterReachable{reachable: online, err: err} reachable[name] = clusterReachable{reachable: online, err: err}
mu.Unlock() mu.Unlock()
}() })
} }
wg.Wait() wg.Wait()

View File

@@ -18,6 +18,7 @@ package es
import ( import (
"fmt" "fmt"
"strings"
"github.com/elastic/go-elasticsearch/v9/typedapi/types" "github.com/elastic/go-elasticsearch/v9/typedapi/types"
) )
@@ -27,14 +28,14 @@ func esErrorString(err error) string {
switch e := err.(type) { switch e := err.(type) {
case *types.ElasticsearchError: case *types.ElasticsearchError:
causes := "" var causes strings.Builder
for _, cause := range e.ErrorCause.RootCause { for _, cause := range e.ErrorCause.RootCause {
causes += fmt.Sprintf("%s\n", *cause.Reason) causes.WriteString(fmt.Sprintf("%s\n", *cause.Reason))
} }
if e.ErrorCause.Reason != nil { if e.ErrorCause.Reason != nil {
msg = *e.ErrorCause.Reason + ": " + causes msg = *e.ErrorCause.Reason + ": " + causes.String()
} else { } else {
msg = fmt.Sprintf("http status %d: ", e.Status) msg = fmt.Sprintf("http status %d: ", e.Status)
} }

View File

@@ -157,11 +157,7 @@ func IlmForecastShow(conf *cfg.Config) error {
var toBeFreed int64 = 0 var toBeFreed int64 = 0
for _, phase := range phaseData { for _, phase := range phaseData {
age := virtualAge(&phase) age := max(virtualAge(&phase), phase.age)
if age < phase.age {
age = phase.age
}
if age+within >= phase.minage { if age+within >= phase.minage {
toBeFreed += phase.size toBeFreed += phase.size
@@ -200,7 +196,7 @@ func getIlmPhaseData(conf *cfg.Config) ([]PhaseData, error) {
var indicesres *indices.Response var indicesres *indices.Response
var ilmpolicies getlifecycle.Response var ilmpolicies getlifecycle.Response
for i := 0; i < 3; i++ { for range 3 {
r := <-responses r := <-responses
if r.error != nil { if r.error != nil {

View File

@@ -22,6 +22,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"log/slog" "log/slog"
"maps"
"strconv" "strconv"
"strings" "strings"
@@ -448,9 +449,7 @@ func modMappings(mappings []string) (types.TypeMappingVariant, error) {
func modMeta(conf *cfg.Config, meta types.Metadata) (map[string]json.RawMessage, error) { func modMeta(conf *cfg.Config, meta types.Metadata) (map[string]json.RawMessage, error) {
metadata := map[string]json.RawMessage{} metadata := map[string]json.RawMessage{}
for key, value := range meta { maps.Copy(metadata, meta)
metadata[key] = value
}
for _, meta := range conf.Meta { for _, meta := range conf.Meta {
parts := strings.Split(meta, ":") parts := strings.Split(meta, ":")

View File

@@ -115,13 +115,6 @@ func (m model) footerView() string {
return lipgloss.JoinHorizontal(lipgloss.Center, line, info) return lipgloss.JoinHorizontal(lipgloss.Center, line, info)
} }
func max(a, b int) int {
if a > b {
return a
}
return b
}
func Pager(title, message string) { func Pager(title, message string) {
p := tea.NewProgram( p := tea.NewProgram(
model{content: message, title: title}, model{content: message, title: title},