Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac5fb3e

Browse files
committed
lint
1 parent abf18a6 commit ac5fb3e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
"testing"
1212
"time"
1313

14-
"cdr.dev/slog"
1514
"github.com/google/uuid"
1615
"github.com/open-policy-agent/opa/topdown"
1716
"golang.org/x/xerrors"
1817

18+
"cdr.dev/slog"
19+
1920
"github.com/coder/coder/v2/coderd/database"
2021
"github.com/coder/coder/v2/coderd/database/dbtime"
2122
"github.com/coder/coder/v2/coderd/httpapi/httpapiconstraints"

provisioner/terraform/modules.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"archive/tar"
55
"bytes"
66
"encoding/json"
7-
"fmt"
87
"io/fs"
98
"os"
109
"path/filepath"
@@ -79,7 +78,7 @@ func getModulesArchive(workdir string) ([]byte, error) {
7978
modulesDir := getModulesDirectory(workdir)
8079
err := filepath.WalkDir(modulesDir, func(filePath string, info fs.DirEntry, err error) error {
8180
if err != nil {
82-
return xerrors.Errorf("failed to archive modules: %w", err)
81+
return xerrors.Errorf("failed to create modules archive: %w", err)
8382
}
8483
if info.IsDir() {
8584
return nil
@@ -90,9 +89,11 @@ func getModulesArchive(workdir string) ([]byte, error) {
9089
return xerrors.Errorf("walked invalid file path: %q", filePath)
9190
}
9291

93-
fmt.Println("file: ", archivePath)
9492
content, err := os.ReadFile(filePath)
95-
w.WriteHeader(&tar.Header{
93+
if err != nil {
94+
return xerrors.Errorf("failed to read module file while archiving: %w", err)
95+
}
96+
err = w.WriteHeader(&tar.Header{
9697
Name: archivePath,
9798
Size: int64(len(content)),
9899
Mode: 0o644,
@@ -102,15 +103,17 @@ func getModulesArchive(workdir string) ([]byte, error) {
102103
if err != nil {
103104
return xerrors.Errorf("failed to add module file to archive: %w", err)
104105
}
105-
w.Write(content)
106+
if _, err = w.Write(content); err != nil {
107+
return xerrors.Errorf("failed to write module file to archive: %w", err)
108+
}
106109
return nil
107110
})
108111
if err != nil {
109112
return nil, err
110113
}
111114
err = w.Close()
112115
if err != nil {
113-
return nil, err
116+
return nil, xerrors.Errorf("failed to close module files archive: %w", err)
114117
}
115118
// Don't persist empty tar files in the database
116119
if empty {

provisioner/terraform/modules_internal_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
)
1010

1111
func TestGetModulesArchive(t *testing.T) {
12+
t.Parallel()
13+
1214
archive, err := getModulesArchive("testdata/modules-source-caching")
1315
require.NoError(t, err)
1416
hash := sha256.Sum256(archive)

0 commit comments

Comments
 (0)