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 {
indentedRef := []string{}
for _, line := range strings.Split(ref, "\n") {
for line := range strings.SplitSeq(ref, "\n") {
indentedRef = append(indentedRef, " "+line)
}
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/>.
module codeberg.org/scip/esctl
go 1.25.8
go 1.26.4
require (
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
for name, cluster := range conf.Clusters {
wg.Add(1)
go func() {
defer wg.Done()
wg.Go(func() {
online, err := cluster.IsReachable()
mu.Lock()
reachable[name] = clusterReachable{reachable: online, err: err}
mu.Unlock()
}()
})
}
wg.Wait()

View File

@@ -18,6 +18,7 @@ package es
import (
"fmt"
"strings"
"github.com/elastic/go-elasticsearch/v9/typedapi/types"
)
@@ -27,14 +28,14 @@ func esErrorString(err error) string {
switch e := err.(type) {
case *types.ElasticsearchError:
causes := ""
var causes strings.Builder
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 {
msg = *e.ErrorCause.Reason + ": " + causes
msg = *e.ErrorCause.Reason + ": " + causes.String()
} else {
msg = fmt.Sprintf("http status %d: ", e.Status)
}

View File

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

View File

@@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"log/slog"
"maps"
"strconv"
"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) {
metadata := map[string]json.RawMessage{}
for key, value := range meta {
metadata[key] = value
}
maps.Copy(metadata, meta)
for _, meta := range conf.Meta {
parts := strings.Split(meta, ":")

View File

@@ -115,13 +115,6 @@ func (m model) footerView() string {
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) {
p := tea.NewProgram(
model{content: message, title: title},