Skip to content

Commit

Permalink
missed some spots
Browse files Browse the repository at this point in the history
Signed-off-by: Kit Patella <[email protected]>
  • Loading branch information
mkcp committed Oct 2, 2024
1 parent 2afa430 commit 1c69af4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/pkg/packager/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package packager

import (
"fmt"
"log/slog"
"os"
"path/filepath"

Expand All @@ -24,7 +23,7 @@ func (p *Packager) confirmAction(stage string, warnings []string, sbomViewFiles
message.HeaderInfof("📦 PACKAGE DEFINITION")
err := utils.ColorPrintYAML(p.cfg.Pkg, p.getPackageYAMLHints(stage), true)
if err != nil {
slog.Error("unable to print yaml", "error", err)
message.WarnErr(err, "unable to print yaml")
}

// Print any potential breaking changes (if this is a Deploy confirm) between this CLI version and the deployed init package
Expand Down
12 changes: 5 additions & 7 deletions src/pkg/utils/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ func credentialParser(path string) (_ []Credential, err error) {
}

// netrcParser parses a user's .netrc file using the method curl did pre 7.84.0: https://daniel.haxx.se/blog/2022/05/31/netrc-pains/.
func netrcParser(path string) ([]Credential, error) {
func netrcParser(path string) (_ []Credential, _ error) {
file, err := os.Open(path)
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
if err != nil {
return nil, err
}
defer func() {
err2 := file.Close()
err = errors.Join(err, err2)
}()

var credentials []Credential
scanner := bufio.NewScanner(file)
Expand Down Expand Up @@ -157,12 +161,6 @@ func netrcParser(path string) ([]Credential, error) {
}
}

// Close our file and handle any errors now that we're done scanning
err = file.Close()
if err != nil {
return nil, err
}

// Append the last machine (if exists) at the end of the file
if activeMachine != nil {
credentials = appendNetrcMachine(activeMachine, credentials)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/utils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func DownloadToFile(ctx context.Context, src, dst, cosignKeyPath string) (err er
}
}

return err
return nil
}

func httpGetFile(url string, destinationFile *os.File) (err error) {
Expand Down
20 changes: 12 additions & 8 deletions src/pkg/variables/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,20 @@ func TestReplaceTextTemplate(t *testing.T) {

for _, tc := range tests {
if tc.path == "" {
tmpDir := t.TempDir()
tc.path = filepath.Join(tmpDir, "templates.test")
func() {
tmpDir := t.TempDir()
tc.path = filepath.Join(tmpDir, "templates.test")

f, err := os.Create(tc.path)
require.NoError(t, err)
f, err := os.Create(tc.path)
require.NoError(t, err)

_, err = f.WriteString(start)
require.NoError(t, err)
err = f.Close()
require.NoError(t, err)
defer func() {
require.NoError(t, f.Close())
}()

_, err = f.WriteString(start)
require.NoError(t, err)
}()
}

gotErr := tc.vc.ReplaceTextTemplate(tc.path)
Expand Down

0 comments on commit 1c69af4

Please sign in to comment.