From fc433a9b2787ae23a676fa82346943654782433b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Thu, 11 Jun 2026 10:01:29 +0200 Subject: [PATCH 1/5] Replace deprecated `strings.Title` with manual capitalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- cmd/podman/containers/ps.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go index d60e0c33a2..129c091039 100644 --- a/cmd/podman/containers/ps.go +++ b/cmd/podman/containers/ps.go @@ -382,12 +382,9 @@ func (l psReporter) Status() string { state = fmt.Sprintf("Exited (%d) %s ago", l.ExitCode, t) default: // Need to capitalize the first letter to match Docker. - - // strings.Title is deprecated since go 1.18 - // However for our use case it is still fine. The recommended replacement - // is adding about 400kb binary size so let's keep using this for now. - //nolint:staticcheck - state = strings.Title(l.ListContainer.State) + if s := l.ListContainer.State; len(s) > 0 { + state = strings.ToUpper(s[:1]) + s[1:] + } } hc := l.ListContainer.Status if hc != "" { From d222b0ae0704bc82dc87cd0bb678c017699964b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Thu, 11 Jun 2026 10:39:54 +0200 Subject: [PATCH 2/5] Fix staticcheck SA4023 warnings in call.go and sign.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- cmd/podman-testing/call.go | 3 --- cmd/podman/common/sign.go | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/podman-testing/call.go b/cmd/podman-testing/call.go index 5ed33b4dd8..a9f63d1557 100644 --- a/cmd/podman-testing/call.go +++ b/cmd/podman-testing/call.go @@ -103,9 +103,6 @@ func noop(_ *cobra.Command, args []string) error { return fmt.Errorf("setting up grpc client for podman service: %w", err) } noopClient := grpcpb.NewNoopClient(grpcClient) - if noopClient == nil { - return fmt.Errorf("setting up client for noop grpc service: %w", err) - } var request grpcpb.NoopRequest if encoded := strings.Join(args, ""); len(encoded) > 0 { if err := json.Unmarshal([]byte(encoded), &request); err != nil { diff --git a/cmd/podman/common/sign.go b/cmd/podman/common/sign.go index 1c73a1e18e..5ab02a7b13 100644 --- a/cmd/podman/common/sign.go +++ b/cmd/podman/common/sign.go @@ -120,7 +120,7 @@ func PrepareSigning(pushOpts *entities.ImagePushOptions, cliOpts *SigningCLIOnly if passphrase != "" { opts = append(opts, simplesequoia.WithPassphrase(passphrase)) } - signer, err := simplesequoia.NewSigner(opts...) + signer, err := simplesequoia.NewSigner(opts...) //nolint:staticcheck,nolintlint // SA4023 false positive: stub always errors, real build does not if err != nil { return nil, fmt.Errorf("error using --sign-by-sq-fingerprint: %w", err) } From b294a92a250827473abe60646ec7d22319031786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Thu, 11 Jun 2026 10:46:22 +0200 Subject: [PATCH 3/5] Add reasons to all staticcheck suppressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- libpod/boltdb_state_internal.go | 4 ++-- libpod/container_config.go | 2 +- pkg/api/handlers/compat/containers.go | 8 ++++---- pkg/api/handlers/compat/events.go | 14 +++++--------- pkg/api/handlers/compat/images_push.go | 5 ++--- pkg/api/handlers/compat/system.go | 2 +- pkg/api/handlers/utils/images.go | 8 +++----- pkg/bindings/images/build.go | 2 +- pkg/machine/os/ostree.go | 2 +- pkg/specgen/generate/kube/seccomp.go | 8 ++++---- test/e2e/search_mock_registry.go | 4 ++-- 11 files changed, 26 insertions(+), 33 deletions(-) diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index f1824d1f7d..d656cc316e 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -328,7 +328,7 @@ func (s *BoltState) getVolumeFromDB(name []byte, volume *Volume, volBkt *bolt.Bu // ocicniPortsToNetTypesPorts convert the old port format to the new one // while deduplicating ports into ranges // -//nolint:staticcheck +//nolint:staticcheck // OCICNIPortMapping is deprecated; kept for backwards-compatible DB migration func ocicniPortsToNetTypesPorts(ports []types.OCICNIPortMapping) []types.PortMapping { if len(ports) == 0 { return nil @@ -377,7 +377,7 @@ func ocicniPortsToNetTypesPorts(ports []types.OCICNIPortMapping) []types.PortMap // 3) hostPort // 4) container port // -//nolint:staticcheck +//nolint:staticcheck // OCICNIPortMapping is deprecated; kept for backwards-compatible DB migration func compareOCICNIPorts(i, j types.OCICNIPortMapping) bool { if i.HostIP != j.HostIP { return i.HostIP < j.HostIP diff --git a/libpod/container_config.go b/libpod/container_config.go index be78734cbe..28f33ba292 100644 --- a/libpod/container_config.go +++ b/libpod/container_config.go @@ -258,7 +258,7 @@ type ContainerNetworkConfig struct { // namespace. As of podman 4.0 this field is deprecated, use PortMappings // instead. The db will convert the old ports to the new structure for you. // These are not used unless CreateNetNS is true - OldPortMappings []types.OCICNIPortMapping `json:"portMappings,omitempty"` //nolint:staticcheck + OldPortMappings []types.OCICNIPortMapping `json:"portMappings,omitempty"` //nolint:staticcheck // OCICNIPortMapping is deprecated but kept for backwards-compatible DB migration // ExposedPorts are the ports which are exposed but not forwarded // into the container. // The map key is the port and the string slice contains the protocols, diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index ecebdda375..8568a93e57 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -289,7 +289,7 @@ func WaitContainer(w http.ResponseWriter, r *http.Request) { utils.WaitContainerDocker(w, r) } -//nolint:staticcheck +//nolint:staticcheck // LegacyNetworkSettings is deprecated but kept for Docker API compat < v1.52 func convertSecondaryIPPrefixLen(input *define.InspectNetworkSettings, output *handlers.LegacyNetworkSettings) { for index, ip := range input.SecondaryIPAddresses { output.SecondaryIPAddresses[index].PrefixLen = ip.PrefixLength @@ -485,7 +485,7 @@ func LibpodToContainer(l *libpod.Container, sz bool, includeHealth bool) (*handl }, nil } -//nolint:staticcheck +//nolint:staticcheck // LegacyImageInspect is deprecated but kept for Docker API compat < v1.52 func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageInspect, error) { imageID, imageName := l.Image() inspect, err := l.Inspect(sz) @@ -588,7 +588,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI Data: inspect.GraphDriver.Data, } - cb := handlers.LegacyImageInspect{ //nolint:staticcheck + cb := handlers.LegacyImageInspect{ //nolint:staticcheck // LegacyImageInspect is deprecated but kept for Docker API compat < v1.52 InspectResponse: container.InspectResponse{ ID: l.ID(), Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC @@ -702,7 +702,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*handlers.LegacyImageI return nil, err } - networkSettings := handlers.LegacyNetworkSettings{} //nolint:staticcheck + networkSettings := handlers.LegacyNetworkSettings{} //nolint:staticcheck // LegacyNetworkSettings is deprecated but kept for Docker API compat < v1.52 if err := json.Unmarshal(n, &networkSettings); err != nil { return nil, err } diff --git a/pkg/api/handlers/compat/events.go b/pkg/api/handlers/compat/events.go index 6bb506bd2b..d13b67d1cd 100644 --- a/pkg/api/handlers/compat/events.go +++ b/pkg/api/handlers/compat/events.go @@ -98,24 +98,20 @@ func GetEvents(w http.ResponseWriter, r *http.Request) { // Handle these differences for Docker-compat. if !utils.IsLibpodRequest(r) && e.Type == "image" && e.Action == "remove" { // Status is deprecated, but we still like to set it for consumers that might use it. - //nolint:staticcheck,nolintlint // we run the linter several times and sometimes it - // complains about this and sometimes it doesn't thus the nolintlint - e.Status = "delete" + e.Status = "delete" //nolint:staticcheck // deprecated field e.Action = "delete" } if !utils.IsLibpodRequest(r) && e.Action == "died" { - //nolint:staticcheck,nolintlint // we run the linter several times and sometimes it - // complains about this and sometimes it doesn't thus the nolintlint - e.Status = "die" + e.Status = "die" //nolint:staticcheck // deprecated field e.Action = "die" e.Actor.Attributes["exitCode"] = e.Actor.Attributes["containerExitCode"] } // Remove fields which are not set in 1.52 and newer. if _, err := apiutil.SupportedVersion(r, ">=1.52.0"); err == nil && !apiutil.IsLibpodRequest(r) { - e.Status = "" //nolint:staticcheck - e.ID = "" //nolint:staticcheck - e.From = "" //nolint:staticcheck + e.Status = "" //nolint:staticcheck // deprecated field, cleared for API >= 1.52 + e.ID = "" //nolint:staticcheck // deprecated field, cleared for API >= 1.52 + e.From = "" //nolint:staticcheck // deprecated field, cleared for API >= 1.52 } if err := coder.Encode(e); err != nil { diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go index 278f4d5581..17beeec068 100644 --- a/pkg/api/handlers/compat/images_push.go +++ b/pkg/api/handlers/compat/images_push.go @@ -152,7 +152,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { loop: // break out of for/select infinite loop for { - var report handlers.LegacyJSONMessage //nolint:staticcheck + var report handlers.LegacyJSONMessage //nolint:staticcheck // LegacyJSONMessage is deprecated but kept for Docker API compat < v1.52 select { case e := <-options.Progress: @@ -204,9 +204,8 @@ loop: // break out of for/select infinite loop report.Error = &jsonstream.Error{ Message: msg, } - //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. if _, err := apiutil.SupportedVersion(r, "<1.52.0"); err == nil { - report.ErrorMessage = msg + report.ErrorMessage = msg //nolint:staticcheck // deprecated field } if err := enc.Encode(report); err != nil { logrus.Warnf("Failed to json encode error %q", err.Error()) diff --git a/pkg/api/handlers/compat/system.go b/pkg/api/handlers/compat/system.go index 35b8a7e1ac..27fd9fd2ab 100644 --- a/pkg/api/handlers/compat/system.go +++ b/pkg/api/handlers/compat/system.go @@ -105,7 +105,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) { } } - utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{ //nolint:staticcheck + utils.WriteResponse(w, http.StatusOK, handlers.LegacyDiskUsage{ //nolint:staticcheck // LegacyDiskUsage is deprecated but kept for Docker API compat < v1.52 LayersSize: df.ImagesSize, Images: legacy, Containers: ctnrs, diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go index 60fb863a80..0c774234c8 100644 --- a/pkg/api/handlers/utils/images.go +++ b/pkg/api/handlers/utils/images.go @@ -216,7 +216,7 @@ func CompatPull(r *http.Request, w http.ResponseWriter, runtime *libpod.Runtime, loop: // break out of for/select infinite loop for { - report := handlers.LegacyJSONMessage{} //nolint:staticcheck + report := handlers.LegacyJSONMessage{} //nolint:staticcheck // LegacyJSONMessage is deprecated but kept for Docker API compat < v1.52 report.Progress = &jsonstream.Progress{} select { case e := <-progress: @@ -251,9 +251,8 @@ loop: // break out of for/select infinite loop report.Error = &jsonstream.Error{ Message: msg, } - //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. if _, err := apiutil.SupportedVersion(r, "<1.52.0"); err == nil { - report.ErrorMessage = msg + report.ErrorMessage = msg //nolint:staticcheck // deprecated field } } else { pulledImages := pullRes.images @@ -266,9 +265,8 @@ loop: // break out of for/select infinite loop report.Error = &jsonstream.Error{ Message: msg, } - //nolint:staticcheck // Deprecated field, but because consumers might still read it keep it. if _, err := apiutil.SupportedVersion(r, "<1.52.0"); err == nil { - report.ErrorMessage = msg + report.ErrorMessage = msg //nolint:staticcheck // deprecated field } writeStatusCode(http.StatusInternalServerError) } diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index a0bda74530..4ee494336b 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -1185,7 +1185,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { // If name is absolute path, then it has to be containerfile outside of build context. // If not, we should check it for being excluded via pattern matcher. if !filepath.IsAbs(name) { - excluded, err := pm.Matches(name) //nolint:staticcheck + excluded, err := pm.Matches(name) if err != nil { return fmt.Errorf("checking if %q is excluded: %w", name, err) } diff --git a/pkg/machine/os/ostree.go b/pkg/machine/os/ostree.go index 37cfd9f850..e1108057db 100644 --- a/pkg/machine/os/ostree.go +++ b/pkg/machine/os/ostree.go @@ -236,7 +236,7 @@ func parseApplyInput(arg string) (string, string, error) { } imagePath := imgRef.StringWithinTransport() - if transportName == ociTransport { //nolint:staticcheck + if transportName == ociTransport { // oci:/tmp/oci-image imagePath, _, _ = strings.Cut(imagePath, ":") } else if transportName == ociArchiveTransport { diff --git a/pkg/specgen/generate/kube/seccomp.go b/pkg/specgen/generate/kube/seccomp.go index a2d3b5e336..ac06592a95 100644 --- a/pkg/specgen/generate/kube/seccomp.go +++ b/pkg/specgen/generate/kube/seccomp.go @@ -38,7 +38,7 @@ func InitializeSeccompPaths(annotations map[string]string, profileRoot string) ( // check if it is prefaced with container.seccomp.security.alpha.kubernetes.io/ prefixAndCtr := strings.Split(annKeyValue, "/") // FIXME: Rework for deprecation removal https://github.com/containers/podman/issues/27501 - //nolint:staticcheck + //nolint:staticcheck // deprecated k8s annotation constant if prefixAndCtr[0]+"/" != v1.SeccompContainerAnnotationKeyPrefix { continue } else if len(prefixAndCtr) != 2 { @@ -55,7 +55,7 @@ func InitializeSeccompPaths(annotations map[string]string, profileRoot string) ( seccompPaths.containerPaths[prefixAndCtr[1]] = path } // FIXME: Rework for deprecation removal https://github.com/containers/podman/issues/27501 - //nolint:staticcheck + //nolint:staticcheck // deprecated k8s annotation constant podSeccomp, ok := annotations[v1.SeccompPodAnnotationKey] if ok { seccompPaths.podPath, err = verifySeccompPath(podSeccomp, profileRoot) @@ -74,11 +74,11 @@ func InitializeSeccompPaths(annotations map[string]string, profileRoot string) ( func verifySeccompPath(path string, profileRoot string) (string, error) { switch path { // FIXME: Rework for deprecation removal https://github.com/containers/podman/issues/27501 - //nolint:staticcheck + //nolint:staticcheck // deprecated k8s seccomp constant case v1.DeprecatedSeccompProfileDockerDefault: fallthrough // FIXME: Rework for deprecation removal https://github.com/containers/podman/issues/27501 - //nolint:staticcheck + //nolint:staticcheck // deprecated k8s seccomp constant case v1.SeccompProfileRuntimeDefault: return libpod.DefaultSeccompPath() case "unconfined": diff --git a/test/e2e/search_mock_registry.go b/test/e2e/search_mock_registry.go index 2450417bd7..d52fc8fc7f 100644 --- a/test/e2e/search_mock_registry.go +++ b/test/e2e/search_mock_registry.go @@ -14,8 +14,8 @@ import ( "strconv" "strings" - . "github.com/onsi/ginkgo/v2" //nolint:staticcheck - . "github.com/onsi/gomega" //nolint:staticcheck + . "github.com/onsi/ginkgo/v2" //nolint:staticcheck // ST1001: should not use dot imports + . "github.com/onsi/gomega" //nolint:staticcheck // ST1001: should not use dot imports ) const ( From 454a1dea459ead376525a860916d43992a36434b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Fri, 12 Jun 2026 09:39:58 +0200 Subject: [PATCH 4/5] Replace deprecated PatternMatcher.Matches with MatchesResult MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- pkg/bindings/images/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 4ee494336b..e13e6679d2 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -1185,11 +1185,11 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { // If name is absolute path, then it has to be containerfile outside of build context. // If not, we should check it for being excluded via pattern matcher. if !filepath.IsAbs(name) { - excluded, err := pm.Matches(name) + res, err := pm.MatchesResult(name) if err != nil { return fmt.Errorf("checking if %q is excluded: %w", name, err) } - if excluded { + if res.IsMatched() { // Note: filepath.SkipDir is not possible to use given .dockerignore semantics. // An exception to exclusions may include an excluded directory, therefore we // are required to visit all files. :( From f1d0ded43cd7a296ee6044781cb94262863af1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Fri, 12 Jun 2026 09:51:58 +0200 Subject: [PATCH 5/5] Convert if/else to switch for transport name comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- pkg/machine/os/ostree.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/machine/os/ostree.go b/pkg/machine/os/ostree.go index e1108057db..3bf1d7a177 100644 --- a/pkg/machine/os/ostree.go +++ b/pkg/machine/os/ostree.go @@ -236,10 +236,11 @@ func parseApplyInput(arg string) (string, string, error) { } imagePath := imgRef.StringWithinTransport() - if transportName == ociTransport { + switch transportName { + case ociTransport: // oci:/tmp/oci-image imagePath, _, _ = strings.Cut(imagePath, ":") - } else if transportName == ociArchiveTransport { + case ociArchiveTransport: // oci-archive:/tmp/myimage.tar imagePath = strings.TrimSuffix(imagePath, ":") }