mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 10:04:18 +02:00
use slices.Collect(maps.Keys()) to get map keys
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -366,16 +367,7 @@ func ApiList(conf *cfg.Config, pattern string) error {
|
||||
func ApiPathNames() []string {
|
||||
assets.LoadAssetOpenApi()
|
||||
|
||||
paths := make([]string, len(assets.OpenAPI.Spec().Paths.Paths))
|
||||
|
||||
idx := 0
|
||||
|
||||
for path := range assets.OpenAPI.Spec().Paths.Paths {
|
||||
paths[idx] = path
|
||||
idx++
|
||||
}
|
||||
|
||||
return paths
|
||||
return slices.Collect(maps.Keys(assets.OpenAPI.Spec().Paths.Paths))
|
||||
}
|
||||
|
||||
func ApiShow(conf *cfg.Config, showpath, verb string) error {
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
@@ -62,13 +64,7 @@ func IlmNames(conf *cfg.Config) ([]string, error) {
|
||||
return nil, fmt.Errorf("failed to get ilm policies: %w", esErrorString(err))
|
||||
}
|
||||
|
||||
names := make([]string, len(res))
|
||||
idx := 0
|
||||
|
||||
for name := range res {
|
||||
names[idx] = name
|
||||
idx++
|
||||
}
|
||||
names := slices.Collect(maps.Keys(res))
|
||||
|
||||
return names, nil
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"codeberg.org/scip/esctl/pkg/printer"
|
||||
@@ -33,15 +35,7 @@ func RoleNames(conf *cfg.Config) ([]string, error) {
|
||||
return nil, fmt.Errorf("failed to get roles: %w", esErrorString(err))
|
||||
}
|
||||
|
||||
roles := make([]string, len(res))
|
||||
|
||||
idx := 0
|
||||
for name := range res {
|
||||
roles[idx] = name
|
||||
idx++
|
||||
}
|
||||
|
||||
return roles, nil
|
||||
return slices.Collect(maps.Keys(res)), nil
|
||||
}
|
||||
|
||||
func RoleList(conf *cfg.Config) error {
|
||||
|
||||
Reference in New Issue
Block a user