internal/gofix and fix error wrapping (#76)

This commit is contained in:
T. von Dein
2026-07-07 10:41:34 +02:00
parent f10366dbde
commit b8e0ee074c
28 changed files with 109 additions and 119 deletions

View File

@@ -37,7 +37,7 @@ func IlmRetry(conf *cfg.Config, index string) error {
_, err := conf.DefaultCluster.ES().Ilm.Retry(index).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to retry ilm: %s", esErrorString(err))
return fmt.Errorf("failed to retry ilm: %w", esErrorString(err))
}
return nil
@@ -47,7 +47,7 @@ func IlmStatus(conf *cfg.Config) error {
res, err := conf.DefaultCluster.ES().Ilm.GetStatus().
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get ilm status: %s", esErrorString(err))
return fmt.Errorf("failed to get ilm status: %w", esErrorString(err))
}
fmt.Println(res.OperationMode.Name)
@@ -59,7 +59,7 @@ func IlmNames(conf *cfg.Config) ([]string, error) {
res, err := conf.DefaultCluster.ES().Ilm.GetLifecycle().
Do(context.Background())
if err != nil {
return nil, fmt.Errorf("failed to get ilm policies: %s", esErrorString(err))
return nil, fmt.Errorf("failed to get ilm policies: %w", esErrorString(err))
}
names := make([]string, len(res))
@@ -82,7 +82,7 @@ func IlmList(conf *cfg.Config, pattern string) error {
res, err := ilm.Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get ilm policies: %s", esErrorString(err))
return fmt.Errorf("failed to get ilm policies: %w", esErrorString(err))
}
if conf.Debug {
@@ -110,7 +110,7 @@ func IlmShow(conf *cfg.Config, policy string) error {
Policy(policy).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get ilm status: %s", esErrorString(err))
return fmt.Errorf("failed to get ilm status: %w", esErrorString(err))
}
if conf.Debug {
@@ -270,7 +270,7 @@ func IlmExplain(conf *cfg.Config, index string) error {
res, err := conf.DefaultCluster.ES().Ilm.ExplainLifecycle(index).
Do(context.Background())
if err != nil {
return fmt.Errorf("failed to get ilm state: %s", esErrorString(err))
return fmt.Errorf("failed to get ilm state: %w", esErrorString(err))
}
slog.Debug("ilm status", "ilm", res)
@@ -523,7 +523,7 @@ func IlmCreate(conf *cfg.Config, policyname string) error {
_, err = ilm.Do(context.Background())
if err != nil {
return fmt.Errorf("failed create ilm policy: %s", esErrorString(err))
return fmt.Errorf("failed create ilm policy: %w", esErrorString(err))
}
return nil