Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Dec 6, 2024
1 parent 9d1101d commit 1cec995
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions ignite/pkg/archive/tar_gz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
})
}
Expand Down Expand Up @@ -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:
Expand All @@ -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)
}
}

Expand Down
7 changes: 4 additions & 3 deletions ignite/pkg/cosmosfaucet/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})))
Expand Down

0 comments on commit 1cec995

Please sign in to comment.