Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
# golangci-lint configuration
# https://golangci-lint.run/usage/configuration/
version: "2"
run:
tests: true
linters:
enable:
- copyloopvar
- errcheck
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- unused
linters-settings:
copyloopvar:
check-alias: true
govet:
enable:
- shadow
misspell:
locale: US
revive:
rules:
- name: package-comments
disabled: true
gci:
sections:
- standard
- default
- prefix(github.com/stolostron/console/backend)
- blank
- dot
settings:
copyloopvar:
check-alias: true
govet:
enable:
- shadow
misspell:
locale: US
revive:
rules:
- name: package-comments
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
settings:
gci:
sections:
- standard
- default
- prefix(github.com/stolostron/console/backend)
- blank
- dot
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion backend/internal/aggregate/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func computeDeployedPodStatuses(related []mapKind, appStatusesMap map[string]Sta
podMap := createResourceMap(related, "Pod")
for appKey, clusterMap := range appStatusesMap {
for clusterKey, appStatuses := range clusterMap {
if !(appStatuses.Health.Counts[scoreHealthy] > 0 && appStatuses.Synced.Counts[scoreHealthy] > 0) && !ignoreHealthCheck {
if (appStatuses.Health.Counts[scoreHealthy] <= 0 || appStatuses.Synced.Counts[scoreHealthy] <= 0) && !ignoreHealthCheck {
continue
}
id := ids[statusIDKey(appKey, clusterKey)]
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func RESTConfig(cfg *config.Config, sa ServiceAccount) (*rest.Config, error) {
},
}
if len(sa.CACert) == 0 {
restCfg.TLSClientConfig.Insecure = true
restCfg.Insecure = true
}
return restCfg, nil
}
Expand Down
12 changes: 6 additions & 6 deletions backend/internal/vmproxy/units.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ func convertBytesToGibibytes(bytes float64) float64 {
func toMillicores(cpuRequest string) (float64, error) {
trimmed := strings.TrimSpace(cpuRequest)
if trimmed == "" {
return 0, fmt.Errorf("Invalid input: cpuRequest must be a non-empty string.")
return 0, fmt.Errorf("invalid input: cpuRequest must be a non-empty string")
}
if strings.HasSuffix(trimmed, "m") {
numericPart := trimmed[:len(trimmed)-1]
millicores, err := strconv.Atoi(numericPart)
if err != nil || strconv.Itoa(millicores) != numericPart {
return 0, fmt.Errorf("Invalid millicore value: %q. The part before \"m\" must be an integer.", cpuRequest)
return 0, fmt.Errorf("invalid millicore value: %q, the part before \"m\" must be an integer", cpuRequest)
}
return float64(millicores), nil
}
coreValue, err := strconv.ParseFloat(trimmed, 64)
if err != nil {
return 0, fmt.Errorf("Invalid core value: %q. Must be a number or end with 'm'.", cpuRequest)
return 0, fmt.Errorf("invalid core value: %q, must be a number or end with 'm'", cpuRequest)
}
return coreValue * 1000, nil
}
Expand All @@ -73,11 +73,11 @@ var memoryRE = regexp.MustCompile(`^(\d+(\.\d+)?)\s*([A-Za-z]+)?$`)
func toMebibytes(memoryRequest string) (float64, error) {
trimmed := strings.TrimSpace(memoryRequest)
if trimmed == "" {
return 0, fmt.Errorf("Invalid input: memoryRequest must be a non-empty string.")
return 0, fmt.Errorf("invalid input: memoryRequest must be a non-empty string")
}
match := memoryRE.FindStringSubmatch(trimmed)
if match == nil {
return 0, fmt.Errorf("Invalid memory format: %q. Expected a number followed by an optional unit.", memoryRequest)
return 0, fmt.Errorf("invalid memory format: %q, expected a number followed by an optional unit", memoryRequest)
}
numericValue, err := strconv.ParseFloat(match[1], 64)
if err != nil {
Expand Down Expand Up @@ -105,7 +105,7 @@ func toMebibytes(memoryRequest string) (float64, error) {
case multipliers[unit] != 0:
bytes = numericValue * multipliers[unit]
default:
return 0, fmt.Errorf("Invalid memory unit: %q.", unit)
return 0, fmt.Errorf("invalid memory unit: %q", unit)
}
return bytes / (1024 * 1024), nil
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/golangci-lint-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

set -euo pipefail

readonly GOLANGCI_LINT_VERSION=v1.64.8
readonly GOLANGCI_LINT_VERSION=v2.13.2
readonly ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

if ! command -v go >/dev/null 2>&1; then
Expand All @@ -12,7 +12,7 @@ if ! command -v go >/dev/null 2>&1; then
fi

if ! command -v golangci-lint >/dev/null 2>&1; then
go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}"
go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}"
fi

export PATH="$(go env GOPATH)/bin:${PATH}"
Expand Down