lint: apply x/tools/modernize fixes

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-03-07 15:00:35 -08:00
parent e19c729d3e
commit d5d3d3d502
50 changed files with 238 additions and 266 deletions

View File

@@ -1016,11 +1016,11 @@ FROM scratch
COPY foo /foo
`)
destDir := t.TempDir()
bakefile := []byte(fmt.Sprintf(`
bakefile := fmt.Appendf(nil, `
target "default" {
output = ["type=local,dest=%s/not/exists"]
}
`, destDir))
`, destDir)
dir := tmpdir(
t,
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
@@ -1050,11 +1050,11 @@ FROM scratch
COPY foo /foo
`)
destDir := t.TempDir()
bakefile := []byte(fmt.Sprintf(`
bakefile := fmt.Appendf(nil, `
target "default" {
output = ["type=local,dest=%s"]
}
`, destDir))
`, destDir)
dir := tmpdir(
t,
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
@@ -1151,11 +1151,11 @@ COPY Dockerfile /foo
keyDir := t.TempDir()
err := writeTempPrivateKey(filepath.Join(keyDir, "id_rsa"))
require.NoError(t, err)
bakefile := []byte(fmt.Sprintf(`
bakefile := fmt.Appendf(nil, `
target "default" {
ssh = ["key=%s"]
}
`, filepath.Join(keyDir, "id_rsa")))
`, filepath.Join(keyDir, "id_rsa"))
dir := tmpdir(
t,
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
@@ -1314,8 +1314,8 @@ target "default" {
type mdT struct {
Default struct {
BuildRef string `json:"buildx.build.ref"`
BuildProvenance map[string]interface{} `json:"buildx.build.provenance"`
BuildRef string `json:"buildx.build.ref"`
BuildProvenance map[string]any `json:"buildx.build.provenance"`
} `json:"default"`
}
var md mdT

View File

@@ -804,8 +804,8 @@ func buildMetadataProvenance(t *testing.T, sb integration.Sandbox, metadataMode
require.NoError(t, err)
type mdT struct {
BuildRef string `json:"buildx.build.ref"`
BuildProvenance map[string]interface{} `json:"buildx.build.provenance"`
BuildRef string `json:"buildx.build.ref"`
BuildProvenance map[string]any `json:"buildx.build.provenance"`
}
var md mdT
err = json.Unmarshal(dt, &md)

View File

@@ -50,7 +50,7 @@ func withDir(dir string) cmdOpt {
func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
cmd := exec.Command("buildx")
cmd.Env = append([]string{}, os.Environ()...)
cmd.Env = os.Environ()
for _, opt := range opts {
opt(cmd)
}
@@ -77,7 +77,7 @@ func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
func dockerCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd {
cmd := exec.Command("docker")
cmd.Env = append([]string{}, os.Environ()...)
cmd.Env = os.Environ()
for _, opt := range opts {
opt(cmd)
}
@@ -214,7 +214,7 @@ func skipNoCompatBuildKit(t *testing.T, sb integration.Sandbox, constraint strin
}
}
func ptrstr(s interface{}) *string {
func ptrstr(s any) *string {
var n *string
if reflect.ValueOf(s).Kind() == reflect.String {
ss := s.(string)

View File

@@ -45,7 +45,7 @@ func testRmMulti(t *testing.T, sb integration.Sandbox) {
}
var builderNames []string
for i := 0; i < 3; i++ {
for range 3 {
out, err := createCmd(sb, withArgs("--driver", "docker-container"))
require.NoError(t, err, out)
builderName := strings.TrimSpace(out)

View File

@@ -2,6 +2,7 @@ package workers
import (
"os"
"slices"
"strings"
"github.com/moby/buildkit/util/testutil/integration"
@@ -49,23 +50,14 @@ func (s *backend) ExtraEnv() []string {
func (s backend) Supports(feature string) bool {
if enabledFeatures := os.Getenv("BUILDKIT_TEST_ENABLE_FEATURES"); enabledFeatures != "" {
for _, enabledFeature := range strings.Split(enabledFeatures, ",") {
if feature == enabledFeature {
return true
}
if slices.Contains(strings.Split(enabledFeatures, ","), feature) {
return true
}
}
if disabledFeatures := os.Getenv("BUILDKIT_TEST_DISABLE_FEATURES"); disabledFeatures != "" {
for _, disabledFeature := range strings.Split(disabledFeatures, ",") {
if feature == disabledFeature {
return false
}
}
}
for _, unsupportedFeature := range s.unsupportedFeatures {
if feature == unsupportedFeature {
if slices.Contains(strings.Split(disabledFeatures, ","), feature) {
return false
}
}
return true
return !slices.Contains(s.unsupportedFeatures, feature)
}