Skip to content

Commit

Permalink
chore: address some review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Kit Patella <[email protected]>
  • Loading branch information
mkcp committed Sep 30, 2024
1 parent 41265d3 commit d2334bb
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"os"
"regexp"

Expand Down Expand Up @@ -79,7 +78,7 @@ var destroyCmd = &cobra.Command{
// Try to remove the script, but ignore any errors and debug log them
err = os.Remove(script)
if err != nil {
slog.Debug("Unable to remove script", "script", script, "error", err)
message.Debug("Unable to remove script", "script", script, "error", err)
}
}
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -334,11 +333,11 @@ func init() {

err := devFindImagesCmd.Flags().MarkDeprecated("set", "this field is replaced by create-set")
if err != nil {
slog.Debug("Unable to mark dev-find-images flag as set", "error", err)
message.Debug("Unable to mark dev-find-images flag as set", "error", err)
}
err = devFindImagesCmd.Flags().MarkHidden("set")
if err != nil {
slog.Debug("Unable to mark dev-find-images flag as hidden", "error", err)
message.Debug("Unable to mark dev-find-images flag as hidden", "error", err)
}
devFindImagesCmd.Flags().StringVarP(&pkgConfig.CreateOpts.Flavor, "flavor", "f", v.GetString(common.VPkgCreateFlavor), lang.CmdPackageCreateFlagFlavor)
devFindImagesCmd.Flags().StringToStringVar(&pkgConfig.CreateOpts.SetVariables, "create-set", v.GetStringMapString(common.VPkgCreateSet), lang.CmdDevFlagSet)
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -391,7 +390,7 @@ func addHiddenDummyFlag(cmd *cobra.Command, flagDummy string) {
cmd.PersistentFlags().StringVar(&dummyStr, flagDummy, "", "")
err := cmd.PersistentFlags().MarkHidden(flagDummy)
if err != nil {
slog.Debug("Unable to add hidden dummy flag", "error", err)
message.Debug("Unable to add hidden dummy flag", "error", err)
}
}
}
17 changes: 8 additions & 9 deletions src/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"context"
"errors"
"fmt"
"log/slog"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -388,19 +387,19 @@ func choosePackage(args []string) (string, error) {
tarPath := config.ZarfPackagePrefix + toComplete + "*.tar"
files, err := filepath.Glob(tarPath)
if err != nil {
slog.Debug("Unable to glob", "tarPath", tarPath, "error", err)
message.Debug("Unable to glob", "tarPath", tarPath, "error", err)
}

zstPath := config.ZarfPackagePrefix + toComplete + "*.tar.zst"
zstFiles, err := filepath.Glob(zstPath)
if err != nil {
slog.Debug("Unable to glob", "zstPath", zstPath, "error", err)
message.Debug("Unable to glob", "zstPath", zstPath, "error", err)
}

splitPath := config.ZarfPackagePrefix + toComplete + "*.part000"
splitFiles, err := filepath.Glob(splitPath)
if err != nil {
slog.Debug("Unable to glob", "splitPath", splitPath, "error", err)
message.Debug("Unable to glob", "splitPath", splitPath, "error", err)
}

files = append(files, zstFiles...)
Expand Down Expand Up @@ -428,7 +427,7 @@ func getPackageCompletionArgs(cmd *cobra.Command, _ []string, _ string) ([]strin

deployedZarfPackages, err := c.GetDeployedZarfPackages(ctx)
if err != nil {
slog.Error("Unable to get deployed zarf packages for package completion args", "error", err)
message.Debug("Unable to get deployed zarf packages for package completion args", "error", err)
}
// Populate list of package names
for _, pkg := range deployedZarfPackages {
Expand Down Expand Up @@ -500,15 +499,15 @@ func bindCreateFlags(v *viper.Viper) {

errOD := createFlags.MarkHidden("output-directory")
if errOD != nil {
slog.Debug("Unable to mark flag output-directory", "error", errOD)
message.Debug("Unable to mark flag output-directory", "error", errOD)
}
errKey := createFlags.MarkHidden("key")
if errKey != nil {
slog.Debug("Unable to mark flag key", "error", errKey)
message.Debug("Unable to mark flag key", "error", errKey)
}
errKP := createFlags.MarkHidden("key-pass")
if errKP != nil {
slog.Debug("Unable to mark flag key-pass", "error", errKP)
message.Debug("Unable to mark flag key-pass", "error", errKP)
}
}

Expand All @@ -532,7 +531,7 @@ func bindDeployFlags(v *viper.Viper) {

err := deployFlags.MarkHidden("sget")
if err != nil {
slog.Debug("Unable to mark flag sget", "error", err)
message.Debug("Unable to mark flag sget", "error", err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/cmd/tools/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package tools

import (
"log/slog"
"github.com/zarf-dev/zarf/src/pkg/message"
"os"

"github.com/zarf-dev/zarf/src/cmd/tools/helm"
Expand All @@ -27,7 +27,7 @@ func init() {
// The inclusion of Helm in this manner should be changed once https://github.com/helm/helm/pull/12725 is merged
helmCmd, err := helm.NewRootCmd(actionConfig, os.Stdout, helmArgs)
if err != nil {
slog.Error("Failed to initialize helm command", "error", err)
message.Debug("Failed to initialize helm command", "error", err)
}
helmCmd.Short = lang.CmdToolsHelmShort
helmCmd.Long = lang.CmdToolsHelmLong
Expand Down
8 changes: 4 additions & 4 deletions src/internal/gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ func (g *Client) DoRequest(ctx context.Context, method string, path string, body
req.Header.Add("accept", "application/json")
req.Header.Add("content-type", "application/json")
resp, err := g.httpClient.Do(req)
// Ensure we close the body of the http client and capture the error
if err != nil {
return nil, 0, err
}
defer func() {
errClose := resp.Body.Close()
err = errors.Join(err, errClose)
}()
if err != nil {
return nil, 0, err
}

b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, 0, err
Expand Down
3 changes: 1 addition & 2 deletions src/pkg/layout/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package layout
import (
"errors"
"fmt"
"log/slog"
"os"
"path/filepath"
"slices"
Expand Down Expand Up @@ -330,7 +329,7 @@ func (pp *PackagePaths) Files() map[string]string {
stripBase := func(path string) string {
rel, err := filepath.Rel(pp.Base, path)
if err != nil {
slog.Debug("unable to strip base from path", "error", err)
message.Debug("unable to strip base from path", "error", err)
}
// Convert from the OS path separator to the standard '/' for Windows support
return filepath.ToSlash(rel)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/message/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewProgressBar(total int64, text string) *ProgressBar {
WithWriter(os.Stderr).
Start()
if err != nil {
slog.Debug("Unable to create default progressbar", "error", err)
message.Debug("Unable to create default progressbar", "error", err)

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / codeql-scan (go)

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / validate-docs-and-schema

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / validate-external

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / build-e2e

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / build-bigbang

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / build-upgrade

undefined: message

Check failure on line 39 in src/pkg/message/progress.go

View workflow job for this annotation

GitHub Actions / validate-unit

undefined: message
}
}

Expand Down

0 comments on commit d2334bb

Please sign in to comment.