Skip to content

Commit

Permalink
deps: update golangci/golangci-lint to v1.62.2 (#3511)
Browse files Browse the repository at this point in the history
* deps: update golangci/golangci-lint to v1.62.2

* deps: tidy all modules

* chore: align with new golangci-lint rules

golangci-lint added some linters in this version upgrade that require fixes on our side. These are done in this commit.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: edgelessci <edgelessci@users.noreply.github.com>
Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent b652baa commit 53ae065
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
# Additional linters
- bodyclose
- errname
- exportloopref
- copyloopvar
- godot
- gofmt
- gofumpt
Expand Down
32 changes: 16 additions & 16 deletions bazel/toolchains/ci_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -223,45 +223,45 @@ def _golangci_lint_deps():
name = "com_github_golangci_golangci_lint_linux_amd64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-amd64.tar.gz",
"https://cdn.confidential.cloud/constellation/cas/sha256/5101292b7925a6a14b49c5c3d845c5021399698ffd2f41bcfab8a111b5669939",
"https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-linux-amd64.tar.gz",
],
strip_prefix = "golangci-lint-1.61.0-linux-amd64",
strip_prefix = "golangci-lint-1.62.2-linux-amd64",
type = "tar.gz",
sha256 = "77cb0af99379d9a21d5dc8c38364d060e864a01bd2f3e30b5e8cc550c3a54111",
sha256 = "5101292b7925a6a14b49c5c3d845c5021399698ffd2f41bcfab8a111b5669939",
)
http_archive(
name = "com_github_golangci_golangci_lint_linux_arm64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/af60ac05566d9351615cb31b4cc070185c25bf8cbd9b09c1873aa5ec6f3cc17e",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-linux-arm64.tar.gz",
"https://cdn.confidential.cloud/constellation/cas/sha256/10b6f5bd8483bd9e85a82f6119ed08f95609f42b86dc344b5dc15703c74d5b85",
"https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-linux-arm64.tar.gz",
],
strip_prefix = "golangci-lint-1.61.0-linux-arm64",
strip_prefix = "golangci-lint-1.62.2-linux-arm64",
type = "tar.gz",
sha256 = "af60ac05566d9351615cb31b4cc070185c25bf8cbd9b09c1873aa5ec6f3cc17e",
sha256 = "10b6f5bd8483bd9e85a82f6119ed08f95609f42b86dc344b5dc15703c74d5b85",
)
http_archive(
name = "com_github_golangci_golangci_lint_darwin_amd64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/5c280ef3284f80c54fd90d73dc39ca276953949da1db03eb9dd0fbf868cc6e55",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-darwin-amd64.tar.gz",
"https://cdn.confidential.cloud/constellation/cas/sha256/6c9ffd05896f0638d5c37152ac4ae337c2d301ba6c9dadf49c04e6d639f10f91",
"https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-darwin-amd64.tar.gz",
],
strip_prefix = "golangci-lint-1.61.0-darwin-amd64",
strip_prefix = "golangci-lint-1.62.2-darwin-amd64",
type = "tar.gz",
sha256 = "5c280ef3284f80c54fd90d73dc39ca276953949da1db03eb9dd0fbf868cc6e55",
sha256 = "6c9ffd05896f0638d5c37152ac4ae337c2d301ba6c9dadf49c04e6d639f10f91",
)
http_archive(
name = "com_github_golangci_golangci_lint_darwin_arm64",
build_file = "//bazel/toolchains:BUILD.golangci.bazel",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/544334890701e4e04a6e574bc010bea8945205c08c44cced73745a6378012d36",
"https://github.com/golangci/golangci-lint/releases/download/v1.61.0/golangci-lint-1.61.0-darwin-arm64.tar.gz",
"https://cdn.confidential.cloud/constellation/cas/sha256/6c76f54467ba471f7bdcd5df0f27c3fa3dbe530b771a10d384c3d8c7178f5e89",
"https://github.com/golangci/golangci-lint/releases/download/v1.62.2/golangci-lint-1.62.2-darwin-arm64.tar.gz",
],
strip_prefix = "golangci-lint-1.61.0-darwin-arm64",
strip_prefix = "golangci-lint-1.62.2-darwin-arm64",
type = "tar.gz",
sha256 = "544334890701e4e04a6e574bc010bea8945205c08c44cced73745a6378012d36",
sha256 = "6c76f54467ba471f7bdcd5df0f27c3fa3dbe530b771a10d384c3d8c7178f5e89",
)

def _buf_deps():
Expand Down
4 changes: 2 additions & 2 deletions disk-mapper/internal/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ func New(log *slog.Logger, csp string, diskPath string, fs afero.Afero,

// PrepareExistingDisk requests and waits for a decryption key to remap the encrypted state disk.
// Once the disk is mapped, the function taints the node as initialized by updating it's PCRs.
func (s *Manager) PrepareExistingDisk(recover RecoveryDoer) error {
func (s *Manager) PrepareExistingDisk(recoverer RecoveryDoer) error {
uuid, err := s.mapper.DiskUUID()
if err != nil {
return err
}
s.log.With(slog.String("uuid", uuid)).Info("Preparing existing state disk")
endpoint := net.JoinHostPort("0.0.0.0", strconv.Itoa(constants.RecoveryPort))

passphrase, measurementSecret, err := recover.Do(uuid, endpoint)
passphrase, measurementSecret, err := recoverer.Do(uuid, endpoint)
if err != nil {
return fmt.Errorf("failed to perform recovery: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions hack/bazel-deps-mirror/internal/bazelfiles/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ type BazelFile struct {
type BazelFileType int

const (
BazelFileTypeBzl = iota // BazelFileTypeBzl is a .bzl file
BazelFileTypeWorkspace // BazelFileTypeWorkspace is a WORKSPACE or WORKSPACE.bzlmod file
// BazelFileTypeBzl is a .bzl file.
BazelFileTypeBzl = iota
// BazelFileTypeWorkspace is a WORKSPACE or WORKSPACE.bzlmod file.
BazelFileTypeWorkspace
)

// LookupEnv can be the real os.LookupEnv or a mock for testing.
Expand Down
26 changes: 13 additions & 13 deletions hack/gocoverage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,25 @@ func parseTestLine(line string) (string, packageCoverage, error) {
return pkg, coverage, nil
}

func diff(old, new, touched string) error {
oldf, err := os.Open(old)
func diff(a, b, touched string) error {
af, err := os.Open(a)
if err != nil {
return err
}
defer oldf.Close()
var oldRep, newReport report
if err := json.NewDecoder(oldf).Decode(&oldRep); err != nil {
defer af.Close()
var aReport, bReport report
if err := json.NewDecoder(af).Decode(&aReport); err != nil {
return err
}
newf, err := os.Open(new)
bf, err := os.Open(b)
if err != nil {
return err
}
defer newf.Close()
if err := json.NewDecoder(newf).Decode(&newReport); err != nil {
defer bf.Close()
if err := json.NewDecoder(bf).Decode(&bReport); err != nil {
return err
}
diffs, err := diffCoverage(oldRep, newReport)
diffs, err := diffCoverage(aReport, bReport)
if err != nil {
return err
}
Expand All @@ -170,17 +170,17 @@ type coverageDiff struct {
new *packageCoverage
}

func diffCoverage(old, new report) (map[string]coverageDiff, error) {
func diffCoverage(a, b report) (map[string]coverageDiff, error) {
allPkgs := make(map[string]struct{})
for pkg := range old.Coverage {
for pkg := range a.Coverage {
allPkgs[pkg] = struct{}{}
}
for pkg := range new.Coverage {
for pkg := range b.Coverage {
allPkgs[pkg] = struct{}{}
}
diffs := make(map[string]coverageDiff)
for pkg := range allPkgs {
diffs[pkg] = coverageDiff{old: old.Coverage[pkg], new: new.Coverage[pkg]}
diffs[pkg] = coverageDiff{old: a.Coverage[pkg], new: b.Coverage[pkg]}
if diffs[pkg].old == nil && diffs[pkg].new == nil {
return nil, fmt.Errorf("both old and new coverage are nil for pkg %s", pkg)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/api/attestationconfigapi/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (i *List) SortReverse() {
}

// AddVersion adds new to i's list and sorts the element in descending order.
func (i *List) AddVersion(new string) {
i.List = append(i.List, new)
func (i *List) AddVersion(ver string) {
i.List = append(i.List, ver)
i.List = variant.RemoveDuplicate(i.List)

i.SortReverse()
Expand Down
8 changes: 4 additions & 4 deletions internal/attestation/measurements/measurements.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,17 @@ func (m *Measurement) unmarshal(eM encodedMeasurement) error {
// WithAllBytes returns a measurement value where all bytes are set to b. Takes a dynamic length as input.
// Expected are either 32 bytes (PCRMeasurementLength) or 48 bytes (TDXMeasurementLength).
// Over inputs are possible in this function, but potentially rejected elsewhere.
func WithAllBytes(b byte, validationOpt MeasurementValidationOption, len int) Measurement {
func WithAllBytes(b byte, validationOpt MeasurementValidationOption, length int) Measurement {
return Measurement{
Expected: bytes.Repeat([]byte{b}, len),
Expected: bytes.Repeat([]byte{b}, length),
ValidationOpt: validationOpt,
}
}

// PlaceHolderMeasurement returns a measurement with placeholder values for Expected.
func PlaceHolderMeasurement(len int) Measurement {
func PlaceHolderMeasurement(length int) Measurement {
return Measurement{
Expected: bytes.Repeat([]byte{0x12, 0x34}, len/2),
Expected: bytes.Repeat([]byte{0x12, 0x34}, length/2),
ValidationOpt: Enforce,
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ func (h *Handler) CopyFile(src, dst string, opts ...Option) error {
}

// RenameFile renames a file, overwriting any existing file at the destination.
func (h *Handler) RenameFile(old, new string) error {
return h.fs.Rename(old, new)
func (h *Handler) RenameFile(a, b string) error {
return h.fs.Rename(a, b)
}

// IsEmpty returns true if the given directory is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (s *stubRateLimiter) When(_ any) time.Duration {

func (s *stubRateLimiter) Forget(_ any) {}

func assertBetween(assert *assert.Assertions, min, max, actual int) {
assert.GreaterOrEqual(actual, min)
assert.LessOrEqual(actual, max)
func assertBetween(assert *assert.Assertions, minimum, maximum, actual int) {
assert.GreaterOrEqual(actual, minimum)
assert.LessOrEqual(actual, maximum)
}

0 comments on commit 53ae065

Please sign in to comment.