Skip to content
Merged
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
28 changes: 15 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
run:
concurrency: 6
timeout: 5m

version: "2"
linters:
enable:
- errorlint

linters-settings:
errorlint:
# See https://golangci-lint.run/usage/linters/#errorlint.
# Only allow warnings about not using %w.
errorf-multi: false
asserts: false
comparison: false
settings:
errorlint:
# See https://golangci-lint.run/usage/linters/#errorlint.
# Only allow warnings about not using %w.
errorf-multi: false
asserts: false
comparison: false
staticcheck:
checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1005", "-QF1008"] # golangci-lint's default, we add -ST1005 and -QF1008
exclusions:
presets:
- comments
- common-false-positives
- std-error-handling
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ REGISTRIESDDIR ?= ${CONTAINERSCONFDIR}/registries.d
# N/B: This value is managed by Renovate, manual changes are
# possible, as long as they don't disturb the formatting
# (i.e. DO NOT ADD A 'v' prefix!)
GOLANGCI_LINT_VERSION := 1.64.8
GOLANGCI_LINT_VERSION := 2.0.0

export PATH := $(PATH):${GOBIN}

Expand Down
10 changes: 5 additions & 5 deletions docker/body_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type bodyReader struct {

body io.ReadCloser // The currently open connection we use to read data, or nil if there is nothing to read from / close.
lastRetryOffset int64 // -1 if N/A
lastRetryTime time.Time // time.Time{} if N/A
lastRetryTime time.Time // IsZero() if N/A
offset int64 // Current offset within the blob
lastSuccessTime time.Time // time.Time{} if N/A
lastSuccessTime time.Time // IsZero() if N/A
}

// newBodyReader creates a bodyReader for request path in c.
Expand Down Expand Up @@ -207,9 +207,9 @@ func (br *bodyReader) Read(p []byte) (int, error) {
}

// millisecondsSinceOptional is like currentTime.Sub(tm).Milliseconds, but it returns a floating-point value.
// If tm is time.Time{}, it returns math.NaN()
// If tm.IsZero(), it returns math.NaN()
func millisecondsSinceOptional(currentTime time.Time, tm time.Time) float64 {
if tm == (time.Time{}) {
if tm.IsZero() {
return math.NaN()
}
return float64(currentTime.Sub(tm).Nanoseconds()) / 1_000_000.0
Expand All @@ -229,7 +229,7 @@ func (br *bodyReader) errorIfNotReconnecting(originalErr error, redactedURL stri
logrus.Infof("Reading blob body from %s failed (%v), reconnecting after %d bytes…", redactedURL, originalErr, progress)
return nil
}
if br.lastRetryTime == (time.Time{}) {
if br.lastRetryTime.IsZero() {
logrus.Infof("Reading blob body from %s failed (%v), reconnecting (first reconnection)…", redactedURL, originalErr)
return nil
}
Expand Down
10 changes: 3 additions & 7 deletions internal/manifest/oci_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ type instanceCandidate struct {
digest digest.Digest // Instance digest
}

func (ic instanceCandidate) isPreferredOver(other *instanceCandidate, preferGzip bool) bool {
func (ic instanceCandidate) isPreferredOver(other *instanceCandidate, preferGzip types.OptionalBool) bool {
switch {
case ic.platformIndex != other.platformIndex:
return ic.platformIndex < other.platformIndex
case ic.isZstd != other.isZstd:
if !preferGzip {
if preferGzip != types.OptionalBoolTrue {
return ic.isZstd
} else {
return !ic.isZstd
Expand All @@ -232,10 +232,6 @@ func (ic instanceCandidate) isPreferredOver(other *instanceCandidate, preferGzip
// chooseInstance is a private equivalent to ChooseInstanceByCompression,
// shared by ChooseInstance and ChooseInstanceByCompression.
func (index *OCI1IndexPublic) chooseInstance(ctx *types.SystemContext, preferGzip types.OptionalBool) (digest.Digest, error) {
didPreferGzip := false
if preferGzip == types.OptionalBoolTrue {
didPreferGzip = true
}
wantedPlatforms := platform.WantedPlatforms(ctx)
var bestMatch *instanceCandidate
bestMatch = nil
Expand All @@ -251,7 +247,7 @@ func (index *OCI1IndexPublic) chooseInstance(ctx *types.SystemContext, preferGzi
}
candidate.platformIndex = platformIndex
}
if bestMatch == nil || candidate.isPreferredOver(bestMatch, didPreferGzip) {
if bestMatch == nil || candidate.isPreferredOver(bestMatch, preferGzip) {
bestMatch = &candidate
}
}
Expand Down
2 changes: 1 addition & 1 deletion openshift/openshift-copies.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ func tlsCacheGet(config *restConfig) (http.RoundTripper, error) {
// TLSConfigFor returns a tls.Config that will provide the transport level security defined
// by the provided Config. Will return nil if no transport level security is requested.
func tlsConfigFor(c *restConfig) (*tls.Config, error) {
if !(c.HasCA() || c.HasCertAuth() || c.Insecure) {
if !c.HasCA() && !c.HasCertAuth() && !c.Insecure {
return nil, nil
}
if c.HasCA() && c.Insecure {
Expand Down
8 changes: 2 additions & 6 deletions pkg/docker/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,14 +1048,10 @@ func TestSetGetCredentials(t *testing.T) {
sys := &types.SystemContext{}
if tc.useLegacyFormat {
sys.LegacyFormatAuthFilePath = tmpFile.Name()
_, err = tmpFile.WriteString(fmt.Sprintf(
`{"%s":{"auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}`, tc.set,
))
_, err = fmt.Fprintf(tmpFile, `{"%s":{"auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}`, tc.set)
} else {
sys.AuthFilePath = tmpFile.Name()
_, err = tmpFile.WriteString(fmt.Sprintf(
`{"auths":{"%s":{"auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}}`, tc.set,
))
_, err = fmt.Fprintf(tmpFile, `{"auths":{"%s":{"auth":"dXNlcm5hbWU6cGFzc3dvcmQ="}}}`, tc.set)
}
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sysregistriesv2/shortnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func parseShortNameValue(alias string) (reference.Named, error) {
}

registry := reference.Domain(named)
if !(strings.ContainsAny(registry, ".:") || registry == "localhost") {
if !strings.ContainsAny(registry, ".:") && registry != "localhost" {
return nil, fmt.Errorf("invalid alias %q: must contain registry and repository", alias)
}

Expand Down