Skip to content

Commit

Permalink
fix some lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Kit Patella <[email protected]>
  • Loading branch information
mkcp committed Oct 24, 2024
1 parent 863548a commit e7052c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/pkg/layout/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ package layout
import (
"context"
"fmt"
"github.com/zarf-dev/zarf/src/pkg/logger"
"io/fs"
"os"
"path/filepath"

"github.com/zarf-dev/zarf/src/pkg/logger"

"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/mholt/archiver/v3"
"github.com/zarf-dev/zarf/src/api/v1alpha1"
Expand Down
3 changes: 2 additions & 1 deletion src/pkg/layout/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"context"
"errors"
"fmt"
"github.com/zarf-dev/zarf/src/pkg/logger"
"os"
"path/filepath"
"slices"
"strings"

"github.com/zarf-dev/zarf/src/pkg/logger"

"github.com/Masterminds/semver/v3"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/google/go-containerregistry/pkg/crane"
Expand Down
34 changes: 2 additions & 32 deletions src/pkg/utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"context"
"errors"
"fmt"
"github.com/zarf-dev/zarf/src/pkg/logger"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"

"github.com/zarf-dev/zarf/src/pkg/logger"

"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/zarf-dev/zarf/src/config/lang"
"github.com/zarf-dev/zarf/src/pkg/message"
)

func parseChecksum(src string) (string, string, error) {
Expand Down Expand Up @@ -96,36 +96,6 @@ func DownloadToFile(ctx context.Context, src, dst, cosignKeyPath string) (err er
return nil
}

func httpGetFileProgress(url string, destinationFile *os.File) (err error) {
// Get the data
resp, err := http.Get(url)
if err != nil {
return fmt.Errorf("unable to download the file %s", url)
}
defer func() {
err2 := resp.Body.Close()
err = errors.Join(err, err2)
}()

// Check server response
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("bad HTTP status: %s", resp.Status)
}

// Writer the body to file
title := fmt.Sprintf("Downloading %s", filepath.Base(url))
progressBar := message.NewProgressBar(resp.ContentLength, title)

if _, err = io.Copy(destinationFile, io.TeeReader(resp.Body, progressBar)); err != nil {
progressBar.Failf("Unable to save the file %s: %s", destinationFile.Name(), err.Error())
return err
}

title = fmt.Sprintf("Downloaded %s", url)
progressBar.Successf("%s", title)
return nil
}

func httpGetFile(ctx context.Context, url string, destinationFile *os.File) (err error) {
l := logger.From(ctx)
l.Info("download start", "url", url)
Expand Down

0 comments on commit e7052c4

Please sign in to comment.