lint: support Go 1.27 validation

Build golangci-lint with Staticcheck v0.8.0-rc.1 to handle the Go 1.27
AST. Disable SA4023 because unsupported platform stubs cause false
positives during multiplatform linting.

Apply Go 1.27 formatting and replace the deprecated plain HTTP resolver
option.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi authored and Sebastiaan van Stijn committed 2026-10-12 17:07:16 +02:00
1 parent c3292e1abe
commit d4f5924b25
6 files changed
+29 -20

No files matched your search

+2
View File
@@ -100,6 +100,8 @@ linters:
staticcheck:
checks:
- all
# Produces false positives for shared callers of platform-specific unsupported stubs.
- -SA4023
testifylint:
disable:
- empty
+6 -2
View File
@@ -308,7 +308,9 @@ func testBuildExportWithForeignLayer(t *testing.T, sb integration.Sandbox) {
ctx := namespaces.WithNamespace(sb.Context(), "buildkit")
resolver := docker.NewResolver(docker.ResolverOptions{PlainHTTP: true})
resolver := docker.NewResolver(docker.ResolverOptions{
Hosts: docker.ConfigureDefaultRegistries(docker.WithPlainHTTP(docker.MatchAllHosts)),
})
name, desc, err := resolver.Resolve(ctx, target)
require.NoError(t, err)
@@ -355,7 +357,9 @@ func testBuildExportWithForeignLayer(t *testing.T, sb integration.Sandbox) {
ctx := namespaces.WithNamespace(sb.Context(), "buildkit")
resolver := docker.NewResolver(docker.ResolverOptions{PlainHTTP: true})
resolver := docker.NewResolver(docker.ResolverOptions{
Hosts: docker.ConfigureDefaultRegistries(docker.WithPlainHTTP(docker.MatchAllHosts)),
})
name, desc, err := resolver.Resolve(ctx, target)
require.NoError(t, err)
+6 -6
View File
@@ -843,12 +843,12 @@ func testSourceMetaPolicySession(t *testing.T, sb integration.Sandbox) {
source: func() (*opspb.SourceOp, sourceresolver.Opt) {
p := platforms.DefaultSpec()
return &opspb.SourceOp{
Identifier: "docker-image://docker.io/library/alpine:latest",
}, sourceresolver.Opt{
ImageOpt: &sourceresolver.ResolveImageOpt{
Platform: &p,
},
}
Identifier: "docker-image://docker.io/library/alpine:latest",
}, sourceresolver.Opt{
ImageOpt: &sourceresolver.ResolveImageOpt{
Platform: &p,
},
}
},
callbacks: []policysession.PolicyCallback{
func(ctx context.Context, req *policysession.CheckPolicyRequest) (*policysession.DecisionResponse, *pb.ResolveSourceMetaRequest, error) {
+6 -6
View File
@@ -327,12 +327,12 @@ func metadataMount(def *opspb.Definition) (*executor.Mount, func(), error) {
}
return &executor.Mount{
Src: &bind{dir},
Dest: "/run/config/buildkit/metadata",
Readonly: true,
}, func() {
os.RemoveAll(dir)
}, nil
Src: &bind{dir},
Dest: "/run/config/buildkit/metadata",
Readonly: true,
}, func() {
os.RemoveAll(dir)
}, nil
}
type bind struct {
+3
View File
@@ -5,6 +5,7 @@ ARG ALPINE_VERSION=3.23
ARG XX_VERSION=1.10.0
ARG PROTOLINT_VERSION=0.56.4
ARG GOLANGCI_LINT_VERSION=v2.12.2
ARG STATICCHECK_VERSION=v0.8.0-rc.1
ARG GOLANGCI_FROM_SOURCE=false
ARG GOPLS_VERSION=v0.38.0
# GOPLS_ANALYZERS defines gopls analyzers to be run. disabled by default: deprecated simplifyrange unusedfunc unusedvariable
@@ -18,7 +19,9 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM golang-base AS golangci-build
WORKDIR /src
ARG GOLANGCI_LINT_VERSION
ARG STATICCHECK_VERSION
ADD https://github.com/golangci/golangci-lint.git#${GOLANGCI_LINT_VERSION} .
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/ go get honnef.co/go/tools@${STATICCHECK_VERSION}
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/ go mod download
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/ mkdir -p out && go build -o /out/golangci-lint ./cmd/golangci-lint
+6 -6
View File
@@ -71,12 +71,12 @@ func (m *staticEmulatorMount) Mount() ([]mount.Mount, func() error, error) {
ret = true
return []mount.Mount{{
Type: "bind",
Source: filepath.Join(tmpdir, qemuMountName),
Options: []string{"ro", "bind"},
}}, func() error {
return os.RemoveAll(tmpdir)
}, nil
Type: "bind",
Source: filepath.Join(tmpdir, qemuMountName),
Options: []string{"ro", "bind"},
}}, func() error {
return os.RemoveAll(tmpdir)
}, nil
}
func (m *staticEmulatorMount) IdentityMapping() *user.IdentityMapping {