Skip to content

Commit

Permalink
Merge pull request #48333 from vvoland/48081-27.x
Browse files Browse the repository at this point in the history
[27.x backport] do another run of gofumpt
  • Loading branch information
thaJeztah authored Aug 15, 2024
2 parents 5955778 + 354bf75 commit 290663e
Show file tree
Hide file tree
Showing 42 changed files with 47 additions and 70 deletions.
1 change: 0 additions & 1 deletion api/server/router/image/image_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter
}
platform = p
}

}

if err := ir.backend.PushImage(ctx, ref, platform, metaHeaders, authConfig, output); err != nil {
Expand Down
1 change: 0 additions & 1 deletion api/server/router/swarm/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,4 @@ func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
service.TaskTemplate.ContainerSpec.OomScoreAdj = 0
}
}

}
1 change: 0 additions & 1 deletion api/types/network/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) {
}
})
}

}

func TestEndpointIPAMConfigWithInvalidConfig(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {

return path, func() {
err = os.RemoveAll(path)

if err != nil {
t.Fatalf("Error when removing directory %s: %s", path, err)
}
Expand Down
1 change: 0 additions & 1 deletion builder/remotecontext/tarsum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestCloseRootDirectory(t *testing.T) {

src := makeTestArchiveContext(t, contextDir)
err = src.Close()

if err != nil {
t.Fatalf("Error while executing Close: %s", err)
}
Expand Down
1 change: 0 additions & 1 deletion builder/remotecontext/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func createTestTempDir(t *testing.T, dir, prefix string) (string, func()) {

return path, func() {
err = os.RemoveAll(path)

if err != nil {
t.Fatalf("Error when removing directory %s: %s", path, err)
}
Expand Down
1 change: 0 additions & 1 deletion daemon/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ func TestValidateMinAPIVersion(t *testing.T) {
}
})
}

}

func TestConfigInvalidDNS(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion daemon/containerd/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (c cacheAdaptor) Get(id image.ID) (*image.Image, error) {
return nil, fmt.Errorf("resolveImage: %w", err)
}

var errFound = errors.New("success")
errFound := errors.New("success")
err = c.is.walkImageManifests(ctx, c8dImg, func(img *ImageManifest) error {
desc, err := img.Config(ctx)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion daemon/containerd/image_children.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
// getImagesWithLabel returns all images that have the matching label key and value.
func (i *ImageService) getImagesWithLabel(ctx context.Context, labelKey string, labelValue string) ([]image.ID, error) {
imgs, err := i.images.List(ctx, "labels."+labelKey+"=="+labelValue)

if err != nil {
return []image.ID{}, errdefs.System(errors.Wrap(err, "failed to list all images"))
}
Expand Down
1 change: 0 additions & 1 deletion daemon/containerd/image_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func TestImageDelete(t *testing.T) {
}
})
}

}

type testContainerStore struct{}
Expand Down
2 changes: 0 additions & 2 deletions daemon/containerd/image_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func (i *ImageService) ExportImage(ctx context.Context, names []string, outStrea

for _, img := range imgs {
ref, err := reference.ParseNamed(img.Name)

if err != nil {
log.G(ctx).WithFields(log.Fields{
"image": img.Name,
Expand Down Expand Up @@ -299,7 +298,6 @@ func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outSt

if !unpacked {
err = platformImg.Unpack(ctx, i.snapshotter)

if err != nil {
return errdefs.System(err)
}
Expand Down
1 change: 0 additions & 1 deletion daemon/containerd/image_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func (i *ImageService) Images(ctx context.Context, opts imagetypes.ListOptions)
func (i *ImageService) imageSummary(ctx context.Context, img images.Image, platformMatcher platforms.MatchComparer,
opts imagetypes.ListOptions, tagsByDigest map[digest.Digest][]string,
) (_ *imagetypes.Summary, allChainIDs []digest.Digest, _ error) {

// Total size of the image including all its platform
var totalSize int64

Expand Down
1 change: 0 additions & 1 deletion daemon/containerd/image_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func TestImageList(t *testing.T) {
tc.check(t, all)
})
}

}

func fakeImageService(t testing.TB, ctx context.Context, cs content.Store) *ImageService {
Expand Down
3 changes: 1 addition & 2 deletions daemon/containerd/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ func desc(size int64) ocispec.Descriptor {
Size: size,
MediaType: ocispec.MediaTypeImageIndex,
}

}

func digestFor(i int64) digest.Digest {
Expand All @@ -284,7 +283,7 @@ func newTestDB(ctx context.Context, t testing.TB) *metadata.DB {
t.Helper()

p := filepath.Join(t.TempDir(), "metadata")
bdb, err := bbolt.Open(p, 0600, &bbolt.Options{})
bdb, err := bbolt.Open(p, 0o600, &bbolt.Options{})
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 0 additions & 1 deletion daemon/containerd/soft_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (i *ImageService) softImageDelete(ctx context.Context, img containerdimages
// Create dangling image if this is the last image pointing to this target.
if len(imgs) == 1 {
err := i.ensureDanglingImage(context.WithoutCancel(ctx), img)

// Error out in case we couldn't persist the old image.
if err != nil {
return errdefs.System(errors.Wrapf(err, "failed to create a dangling image for the replaced image %s with digest %s",
Expand Down
1 change: 0 additions & 1 deletion daemon/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ func (daemon *Daemon) fillDebugInfo(ctx context.Context, v *system.Info) {
v.NFd = fileutils.GetTotalUsedFds(ctx)
v.NGoroutines = runtime.NumGoroutine()
v.NEventsListener = daemon.EventsService.SubscribersCount()

}

// fillContainerdInfo provides information about the containerd configuration
Expand Down
2 changes: 1 addition & 1 deletion daemon/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ func (daemon *Daemon) clearAttachableNetworks() {
// buildCreateEndpointOptions builds endpoint options from a given network.
func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
var createOptions []libnetwork.EndpointOption
var genericOptions = make(options.Generic)
genericOptions := make(options.Generic)

nwName := n.Name()

Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) {
c.Fatal(err)
}

err = os.WriteFile(fooPath, []byte("test"), 0666)
err = os.WriteFile(fooPath, []byte("test"), 0o666)
if err != nil {
c.Fatal(err)
}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinksVolume(c *testing.T) {
defer ctx.Close()
fooPath := filepath.Join(ctx.Dir, targetFile)

err = os.WriteFile(fooPath, []byte("test"), 0666)
err = os.WriteFile(fooPath, []byte("test"), 0o666)
if err != nil {
c.Fatal(err)
}
Expand Down
14 changes: 7 additions & 7 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T)

// daemon config file
const configFilePath = "test-daemon.json"
err := os.WriteFile(configFilePath, []byte(`{ "max-concurrent-downloads" : 8 }`), 0666)
err := os.WriteFile(configFilePath, []byte(`{ "max-concurrent-downloads" : 8 }`), 0o666)
assert.NilError(c, err)
defer os.Remove(configFilePath)
s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
Expand All @@ -2061,7 +2061,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T)
assert.NilError(c, err)
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
err = os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : 7, "max-concurrent-downloads" : 9 }`), 0666)
err = os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : 7, "max-concurrent-downloads" : 9 }`), 0o666)
assert.NilError(c, err)
assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
// unix.Kill(s.d.cmd.Process.Pid, unix.SIGHUP)
Expand All @@ -2084,7 +2084,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test

// daemon config file
const configFilePath = "test-daemon.json"
err := os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : null }`), 0666)
err := os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : null }`), 0o666)
assert.NilError(c, err)
defer os.Remove(configFilePath)

Expand All @@ -2096,7 +2096,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
assert.NilError(c, err)
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
err = os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : 1, "max-concurrent-downloads" : null }`), 0666)
err = os.WriteFile(configFilePath, []byte(`{ "max-concurrent-uploads" : 1, "max-concurrent-downloads" : null }`), 0o666)
assert.NilError(c, err)

assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
Expand All @@ -2110,7 +2110,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
assert.NilError(c, err)
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
err = os.WriteFile(configFilePath, []byte(`{ "labels":["foo=bar"] }`), 0666)
err = os.WriteFile(configFilePath, []byte(`{ "labels":["foo=bar"] }`), 0o666)
assert.NilError(c, err)

assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
Expand Down Expand Up @@ -2451,13 +2451,13 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *testing.T

// daemon config file
const configFilePath = "test-daemon.json"
err := os.WriteFile(configFilePath, []byte(`{ "shutdown-timeout" : 8 }`), 0666)
err := os.WriteFile(configFilePath, []byte(`{ "shutdown-timeout" : 8 }`), 0o666)
assert.NilError(c, err)
defer os.Remove(configFilePath)

s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))

err = os.WriteFile(configFilePath, []byte(`{ "shutdown-timeout" : 5 }`), 0666)
err = os.WriteFile(configFilePath, []byte(`{ "shutdown-timeout" : 5 }`), 0o666)
assert.NilError(c, err)

assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
Expand Down
1 change: 0 additions & 1 deletion integration-cli/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, err error)
if i > 0 {
prevCmd := cmds[i-1]
cmd.Stdin, err = prevCmd.StdoutPipe()

if err != nil {
return "", fmt.Errorf("cannot set stdout pipe for %s: %v", cmd.Path, err)
}
Expand Down
1 change: 0 additions & 1 deletion integration/build/build_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,4 @@ func TestBuildkitHistoryTracePropagation(t *testing.T) {
}
return poll.Continue("trace not available yet")
}, poll.WithDelay(time.Second), poll.WithTimeout(30*time.Second))

}
1 change: 0 additions & 1 deletion integration/image/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ func TestSaveOCI(t *testing.T) {
t.Run("OCI reference tag", func(t *testing.T) {
assert.Check(t, is.Equal(index.Manifests[0].Annotations["org.opencontainers.image.ref.name"], tc.expectedOCIRef))
})

})
}
}
Expand Down
2 changes: 1 addition & 1 deletion integration/internal/network/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func WriteTempResolvConf(t *testing.T, addr string) string {
f, err := os.CreateTemp("", "resolv.conf")
assert.NilError(t, err)
t.Cleanup(func() { os.Remove(f.Name()) })
err = f.Chmod(0644)
err = f.Chmod(0o644)
assert.NilError(t, err)
f.Write([]byte("nameserver " + addr + "\n"))
return f.Name()
Expand Down
1 change: 0 additions & 1 deletion integration/network/ipvlan/ipvlan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func TestDockerNetworkIpvlan(t *testing.T) {
test: testIpvlanNoIPv6,
},
} {

t.Run(tc.name, func(t *testing.T) {
testutil.StartSpan(ctx, t)
d := daemon.New(t)
Expand Down
2 changes: 1 addition & 1 deletion integration/networking/resolvconf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestInternalNetworkLocalDNS(t *testing.T) {
// Write a config file for busybox's dnsd.
td := t.TempDir()
fname := path.Join(td, "dnsd.conf")
err := os.WriteFile(fname, []byte("foo.example 192.0.2.42\n"), 0644)
err := os.WriteFile(fname, []byte("foo.example 192.0.2.42\n"), 0o644)
assert.NilError(t, err)

// Start a DNS server on the internal network.
Expand Down
12 changes: 6 additions & 6 deletions internal/cleanups/composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (

func TestCall(t *testing.T) {
c := Composite{}
var err1 = errors.New("error1")
var err2 = errors.New("error2")
var errX = errors.New("errorX")
var errY = errors.New("errorY")
var errZ = errors.New("errorZ")
var errYZ = errors.Join(errY, errZ)
err1 := errors.New("error1")
err2 := errors.New("error2")
errX := errors.New("errorX")
errY := errors.New("errorY")
errZ := errors.New("errorZ")
errYZ := errors.Join(errY, errZ)

c.Add(func(ctx context.Context) error {
return err1
Expand Down
1 change: 0 additions & 1 deletion internal/safepath/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func TestJoinWithSymlinkReplace(t *testing.T) {
assert.NilError(t, err, "failed to read file")

assert.Check(t, is.Equal(string(data), "bar"))

}

func TestJoinCloseInvalidates(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions internal/testutils/specialimage/dangling.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

const danglingImageManifestDigest = "sha256:16d365089e5c10e1673ee82ab5bba38ade9b763296ad918bd24b42a1156c5456" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)
const danglingImageConfigDigest = "sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)
const (
danglingImageManifestDigest = "sha256:16d365089e5c10e1673ee82ab5bba38ade9b763296ad918bd24b42a1156c5456" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)
danglingImageConfigDigest = "sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43" // #nosec G101 -- ignoring: Potential hardcoded credentials (gosec)
)

// Dangling creates an image with no layers and no tag.
// It also has an extra org.mobyproject.test.specialimage=1 label set.
Expand Down
1 change: 0 additions & 1 deletion internal/testutils/specialimage/twoplatform.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func oneLayerPlatformManifest(dir string, platform ocispec.Platform, f FileInLay
manifestDesc.Platform = &platform

return manifestDesc, nil

}

func multiPlatformImage(dir string, ref reference.Named, target ocispec.Index) (*ocispec.Index, error) {
Expand Down
1 change: 0 additions & 1 deletion layer/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestEmptyLayer(t *testing.T) {

digester := digest.Canonical.Digester()
_, err = io.Copy(digester.Hash(), tarStream)

if err != nil {
t.Fatalf("error hashing empty tar layer: %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion libcontainerd/remote/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ func (t *task) Start(ctx context.Context) error {
ctx, span := otel.Tracer("").Start(ctx, "libcontainerd.remote.task.Start")
defer span.End()
return wrapError(t.Task.Start(ctx))

}

// Exec creates exec process.
Expand Down
2 changes: 0 additions & 2 deletions libnetwork/cnmallocator/networkallocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ func (na *cnmNetworkAllocator) IsAttachmentAllocated(node *api.Node, networkAtta
// AllocateAttachment allocates the IP addresses for a LB in a network
// on a given node
func (na *cnmNetworkAllocator) AllocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error {

if err := na.allocateNetworkIPs(networkAttachment); err != nil {
return err
}
Expand All @@ -501,7 +500,6 @@ func (na *cnmNetworkAllocator) AllocateAttachment(node *api.Node, networkAttachm
// DeallocateAttachment deallocates the IP addresses for a LB in a network to
// which the node is attached.
func (na *cnmNetworkAllocator) DeallocateAttachment(node *api.Node, networkAttachment *api.NetworkAttachment) error {

delete(na.nodes[node.ID], networkAttachment.Network.ID)
if len(na.nodes[node.ID]) == 0 {
delete(na.nodes, node.ID)
Expand Down
1 change: 0 additions & 1 deletion libnetwork/cnmallocator/networkallocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,6 @@ func TestServiceNetworkUpdate(t *testing.T) {

assert.Check(t, na.IsServiceAllocated(s))
assert.Check(t, is.Len(s.Endpoint.VirtualIPs, 1))

}

type mockIpam struct {
Expand Down
3 changes: 2 additions & 1 deletion libnetwork/drivers/bridge/interface_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func (i *bridgeInterface) programIPv6Addresses(config *networkConfiguration) err
if err != nil {
log.G(context.TODO()).WithFields(log.Fields{
"error": err,
"address": existingAddr.IPNet},
"address": existingAddr.IPNet,
},
).Warnf("Failed to remove residual IPv6 address from bridge")
}
}
Expand Down
2 changes: 2 additions & 0 deletions libnetwork/drivers/bridge/port_mapping_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,11 @@ func setPerPortForwarding(b portBinding, ipv iptables.IPVersion, bridgeName stri
func (n *bridgeNetwork) reapplyPerPortIptables4() {
n.reapplyPerPortIptables(func(b portBinding) bool { return b.IP.To4() != nil })
}

func (n *bridgeNetwork) reapplyPerPortIptables6() {
n.reapplyPerPortIptables(func(b portBinding) bool { return b.IP.To4() == nil })
}

func (n *bridgeNetwork) reapplyPerPortIptables(needsReconfig func(portBinding) bool) {
n.Lock()
var allPBs []portBinding
Expand Down
1 change: 0 additions & 1 deletion libnetwork/drivers/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ func (d *driver) CreateEndpoint(ctx context.Context, nid, eid string, ifInfo dri
endpoint.epConnectivity = epConnectivity
endpoint.epOption = epOption
endpoint.portMapping, err = ParsePortBindingPolicies(hnsresponse.Policies)

if err != nil {
hcsshim.HNSEndpointRequest("DELETE", hnsresponse.Id, "")
return err
Expand Down
Loading

0 comments on commit 290663e

Please sign in to comment.