From 1cec995edf1222292acb43eaea966a9e2f17c864 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 6 Dec 2024 20:57:02 +0100 Subject: [PATCH] updates --- ignite/pkg/archive/tar_gz.go | 11 ++++++----- ignite/pkg/cosmosfaucet/http.go | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ignite/pkg/archive/tar_gz.go b/ignite/pkg/archive/tar_gz.go index 38ec3fbd90..c4500d86f5 100644 --- a/ignite/pkg/archive/tar_gz.go +++ b/ignite/pkg/archive/tar_gz.go @@ -3,10 +3,11 @@ package archive import ( "archive/tar" "compress/gzip" - "fmt" "io" "os" "path/filepath" + + "github.com/ignite/cli/v29/ignite/pkg/errors" ) // CreateArchive creates a tar.gz archive from a list of files. @@ -20,7 +21,7 @@ func CreateArchive(dir string, buf io.Writer) error { tw := tar.NewWriter(gw) defer tw.Close() - return filepath.WalkDir(dir, func(path string, info os.DirEntry, err error) error { + return filepath.WalkDir(dir, func(path string, _ os.DirEntry, _ error) error { return addToArchive(tw, path) }) } @@ -82,7 +83,7 @@ func ExtractArchive(outDir string, gzipStream io.Reader) error { return err } - targetPath := filepath.Join(outDir, header.Name) + targetPath := filepath.Join(outDir, header.Name) //nolint:gosec // We trust the tar file switch header.Typeflag { case tar.TypeDir: @@ -94,13 +95,13 @@ func ExtractArchive(outDir string, gzipStream io.Reader) error { if err != nil { return err } - if _, err := io.Copy(outFile, tarReader); err != nil { + if _, err := io.Copy(outFile, tarReader); err != nil { //nolint:gosec // We trust the tar file return err } outFile.Close() default: - return fmt.Errorf("unknown type: %s in %s", string(header.Typeflag), header.Name) + return errors.Errorf("unknown type: %s in %s", string(header.Typeflag), header.Name) } } diff --git a/ignite/pkg/cosmosfaucet/http.go b/ignite/pkg/cosmosfaucet/http.go index 262161c576..a14a313b34 100644 --- a/ignite/pkg/cosmosfaucet/http.go +++ b/ignite/pkg/cosmosfaucet/http.go @@ -14,11 +14,12 @@ func (f Faucet) ServeHTTP(w http.ResponseWriter, r *http.Request) { mux := http.NewServeMux() mux.Handle("/", cors.Default().Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Method == http.MethodPost || r.Method == http.MethodOptions { + switch { + case r.Method == http.MethodPost || r.Method == http.MethodOptions: f.faucetHandler(w, r) - } else if r.Method == http.MethodGet { + case r.Method == http.MethodGet: openapiconsole.Handler("Faucet", "openapi.yml")(w, r) - } else { + default: http.NotFound(w, r) } })))