The new configuration files were initially generated by
`golangci-lint migrate`, when tweaked to minimize and simplify.
golangci-lint v2 switches to a new version of staticcheck which shows
much more warnings. Some of them were fixed by a few previous commits,
and the rest of them are disabled.
Also, golangci-extra was modified to include ALL staticcheck linters.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following linter warning:
> pkg/retry/retry.go:50:4: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck)
> break
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following linter warnings:
> pkg/auth/auth.go:176:11: ST1005: error strings should not be capitalized (staticcheck)
> return errors.New("Can't specify both --password-stdin and --password")
> ^
> pkg/auth/auth.go:179:11: ST1005: error strings should not be capitalized (staticcheck)
> return errors.New("Must provide --username with --password-stdin")
> ^
> pkg/subscriptions/subscriptions.go:325:17: ST1005: error strings should not be capitalized (staticcheck)
> return false, fmt.Errorf("Container /etc resolution error: %w", err)
> ^
> pkg/subscriptions/subscriptions.go:325:17: ST1005: error strings should not be capitalized (staticcheck)
> return false, fmt.Errorf("Container /etc resolution error: %w", err)
> ^
> pkg/subscriptions/subscriptions.go:334:17: ST1005: error strings should not be capitalized (staticcheck)
> return false, fmt.Errorf("Container /etc/system-fips resolution error: %w", err)
> ^
> pkg/subscriptions/subscriptions.go:451:10: ST1005: error strings should not be capitalized (staticcheck)
> return fmt.Errorf("Could not expand %q in container: %w", srcPolicyConfig, err)
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following staticcheck warning:
> pkg/cgroups/utils_linux.go:224:25: QF1001: could apply De Morgan's law (staticcheck)
> if parts[2] == "/" && !(unifiedMode && parts[1] == "") {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following staticcheck warnings:
> libimage/image.go:463:5: QF1001: could apply De Morgan's law (staticcheck)
> if !(referencedBy == "" || numNames == 1) {
> ^
> libimage/normalize.go:33:5: QF1001: could apply De Morgan's law (staticcheck)
> if !(strings.ContainsAny(registry, ".:") || registry == "localhost") {
> ^
> libimage/search.go:220:6: QF1001: could apply De Morgan's law (staticcheck)
> if !(filterMatchesAutomatedFilter(&options.Filter, results[i]) && filterMatchesOfficialFilter(&options.Filter, results[i]) && filterMatchesStarFilter(&options.Filter, results[i])) {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following staticcheck warnings:
> pkg/configmaps/configmaps.go:135:5: QF1001: could apply De Morgan's law (staticcheck)
> if !(len(data) > 0 && len(data) < maxConfigMapSize) {
> ^
> pkg/secrets/secrets.go:169:5: QF1001: could apply De Morgan's law (staticcheck)
> if !(len(data) > 0 && len(data) < maxSecretSize) {
> ^
as well as the subsequent gocritic warnings:
> pkg/configmaps/configmaps.go:135:5: sloppyLen: len(data) <= 0 can be len(data) == 0 (gocritic)
> if len(data) <= 0 || len(data) >= maxConfigMapSize {
> ^
> pkg/secrets/secrets.go:169:5: sloppyLen: len(data) <= 0 can be len(data) == 0 (gocritic)
> if len(data) <= 0 || len(data) >= maxSecretSize {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Fix the following staticcheck warning:
> pkg/timetype/timestamp.go:35:21: QF1001: could apply De Morgan's law (staticcheck)
> parseInLocation := !(strings.ContainsAny(value, "zZ+") || strings.Count(value, "-") == 3)
> ^
While at it, improve the comment.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following staticcheck warning:
> libnetwork/netavark/config.go:297:2: QF1007: could merge conditional assignment into variable declaration (staticcheck)
> isMacVlan := true
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
... and add a deprecated alias so backward compatibility is still
preserved (and users can gradually switch to the new name).
Done because this is now also reported by staticcheck
(in addition to revive) linter.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This fixes the following staticcheck warning:
> pkg/timezone/timezone.go:23:2: QF1002: could use tagged switch on timezone (staticcheck)
> switch {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Fix the following warning, as reported by staticcheck from golangci-lint
v2.0.1:
> pkg/secrets/secrets_test.go:67:5: QF1009: probably want to use time.Time.Equal instead (staticcheck)
> if s.CreatedAt == s.UpdatedAt {
> ^
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Let's take a look at each enabled linter, and find out if it's needed;
remove those that make no sense.
* gci: formats imports, probably superseded by gofumpt;
* gofmt: is a subset of gofumpt;
* goheader: does nothing with empty configuration;
* goimports: functionality should be covered by gofumpt;
* gomodguard: does nothing with empty configuration;
* grouper: formats imports, probably superseded by gofumpt;
* importas: does nothing with empty configuration;
* loggercheck: this repo does not use any loggers it checks (kitlog,klog,logr,zap);
* promlinter: this repo does not use Prometheus;
* protogetter: this repo does not use protobuf;
* rowserrcheck: this repo does not use sql;
* sloginit: this repo does not use slog;
* spancheck: this repo does not use opentelemetry/opencensus;
* sqlclosecheck: this repo does not use sql;
* tagalign: this repo does not use multiple struct tags;
* testableexamples: this repo does not have any examples;
* zerologlint: this repo does not use zerolog.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Instead of enabling all linters, and when disabling some of them because
we don't like them, switch to list of explicitly enabled linters. The
upside of this is we can easily upgrade golangci-lint (i.e. any new
linters won't break our CI). The downside is, we need to explicitly
enable extra linters.
To me, this is better from the maintainability perspective.
NOTE this commit does not change the configuration in any way, in other
words, the list of linters being run is the same as before. The next
commit will address this.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Commit f8614a5b ("CI: enable extra linters for new code") introduced the
feature of running some extra linters for any newly added code (see the
commit description for motivation).
Commit 7f76a6b5 ("use runc cgroup creation logic") broke the feature,
because it contains:
mv .golangci-extra.yml golangci.yml
(Note the missing dot in the destination file name.)
As a result, golangci-lint was running twice with the same config,
with golangci-extra.yml being unused.
Let's fix it by using args: action parameter.
Also, some time later, a new golangci-lint removed support for deadline
option, and commit 5d5e6a44 ("update golangci.yml") fixed it for the
main config. Let's do the same for the extra config.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Currently when we run podman image prune or podman images --filter
dangling
It is pruning images that are in a local manifest. These images are
not dangling because they are currently in use by a named manifest list.
You can create this situation simply by doing
echo "from scratch" > /tmp/Containerfile
id=$(podman build /tmp)
podman manifest create test $id
podman image prune --force
podman image exists $id
Will return an error since the image was pruned. Now the local manifest
test is broken.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Following commit fixes a `race` condition in `libimage` because in `Pull(`
after performing `copy` from remote sources it agains attempts to resolve
image via `LookupImage`, any operation between `copy` and `LookupImage` can remove
`name` from the recently pulled image. Causing race in builds.
This issue was discoverd while working on PR https://github.com/containers/buildah/pull/5971
```
buildah build -t test --jobs=2 --skip-unused-stages=false .
```
Containerfile
```
FROM quay.io/jitesoft/alpine
RUN arch
FROM --platform=linux/arm64 quay.io/jitesoft/alpine AS foreign
```
Following commit also addresses the commit 88f60eeeb3
by performing the neccessary refactor.
No functional change in public exposed API, exisiting tests should pass as-is.
[NO NEW TESTS NEEDED]
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Implements interface name length validation during network creation to prevent
netlink errors when names exceed the kernel's 15-character limit.
This prevents creation of networks with interface names that would cause failures
when running containers.
Signed-off-by: Lucas Pablo Calisi <lucas.calisi@mercadolibre.com>