mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 14:24:20 +02:00
adopt latest golang enhancements (#91)
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"maps"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -158,7 +159,7 @@ func ApiRepl(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
func pageJsonOutput(conf *cfg.Config, raw []byte) {
|
||||
tmpconf := &cfg.Config{HaveJQ: conf.HaveJQ}
|
||||
tmpconf := new(cfg.Config{HaveJQ: conf.HaveJQ})
|
||||
|
||||
if conf.Pager != "" {
|
||||
tmpconf.HaveJQ = false
|
||||
@@ -206,16 +207,16 @@ func CallAPI(conf *cfg.Config, verb, path, data string) ([]byte, error) {
|
||||
verb = strings.ToUpper(verb)
|
||||
|
||||
// we're using port-forwards anyway
|
||||
noVerifyTransport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
noVerifyTransport := new(http.Transport{
|
||||
TLSClientConfig: new(tls.Config{InsecureSkipVerify: true}),
|
||||
})
|
||||
|
||||
client := &http.Client{Transport: noVerifyTransport}
|
||||
client := new(http.Client{Transport: noVerifyTransport})
|
||||
|
||||
if conf.DebugHTTP {
|
||||
client = &http.Client{
|
||||
Transport: &cfg.DebugTransport{
|
||||
Transport: noVerifyTransport}}
|
||||
client = new(http.Client{
|
||||
Transport: new(cfg.DebugTransport{
|
||||
Transport: noVerifyTransport})})
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(verb, conf.DefaultCluster.Uri+path, bytes.NewBuffer([]byte(data)))
|
||||
@@ -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 {
|
||||
@@ -536,7 +528,7 @@ func getApiExample(op *Op) string {
|
||||
// otherwise showpath+verb have to match precisely.
|
||||
func matchOperation(showpath, verb string) (*Op, error) {
|
||||
ops := []*Op{}
|
||||
op := &Op{}
|
||||
op := new(Op{})
|
||||
|
||||
var found bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user