Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[22.06 backport] fix (whitespace) formatting in preparation of enabling more linters #44229

Merged
merged 18 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion api/server/middleware/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.
ctx = context.WithValue(ctx, httputils.APIVersionKey{}, apiVersion)
return handler(ctx, w, r, vars)
}

}
1 change: 0 additions & 1 deletion api/server/router/build/build_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
defer func() { _ = output.Close() }()

errf := func(err error) error {

if httputils.BoolValue(r, "q") && notVerboseBuffer.Len() > 0 {
_, _ = output.Write(notVerboseBuffer.Bytes())
}
Expand Down
1 change: 0 additions & 1 deletion api/server/router/swarm/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,4 @@ func TestAdjustForAPIVersion(t *testing.T) {
if len(spec.TaskTemplate.ContainerSpec.Ulimits) != 0 {
t.Error("Ulimits were not stripped from spec")
}

}
9 changes: 4 additions & 5 deletions api/types/strslice/strslice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ func TestStrSliceUnmarshalJSON(t *testing.T) {
"[]": {},
`["/bin/sh","-c","echo"]`: {"/bin/sh", "-c", "echo"},
}
for json, expectedParts := range parts {
for input, expected := range parts {
strs := StrSlice{"default", "values"}
if err := strs.UnmarshalJSON([]byte(json)); err != nil {
if err := strs.UnmarshalJSON([]byte(input)); err != nil {
t.Fatal(err)
}

actualParts := []string(strs)
if !reflect.DeepEqual(actualParts, expectedParts) {
t.Fatalf("%#v: expected %v, got %v", json, expectedParts, actualParts)
if !reflect.DeepEqual(actualParts, expected) {
t.Fatalf("%#v: expected %v, got %v", input, expected, actualParts)
}

}
}

Expand Down
3 changes: 1 addition & 2 deletions builder/builder-next/adapters/containerimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session
p := &puller{
src: imageIdentifier,
is: is,
//resolver: is.getResolver(is.RegistryHosts, imageIdentifier.Reference.String(), sm, g),
// resolver: is.getResolver(is.RegistryHosts, imageIdentifier.Reference.String(), sm, g),
platform: platform,
sm: sm,
}
Expand Down Expand Up @@ -439,7 +439,6 @@ func (p *puller) Snapshot(ctx context.Context, g session.Group) (cache.Immutable
// TODO: Optimize to do dispatch and integrate pulling with download manager,
// leverage existing blob mapping and layer storage
} else {

// TODO: need a wrapper snapshot interface that combines content
// and snapshots as 1) buildkit shouldn't have a dependency on contentstore
// or 2) cachemanager should manage the contentstore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

// ResolveCacheImporterFunc returns a resolver function for local inline cache
func ResolveCacheImporterFunc(sm *session.Manager, resolverFunc docker.RegistryHosts, cs content.Store, rs reference.Store, is imagestore.Store) remotecache.ResolveCacheImporterFunc {

upstream := registryremotecache.ResolveCacheImporterFunc(sm, cs, resolverFunc)

return func(ctx context.Context, group session.Group, attrs map[string]string) (remotecache.Importer, specs.Descriptor, error) {
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ func (b *Builder) dispatchDockerfileWithCancellation(parseResult []instructions.
}
dispatchRequest.state.updateRunConfig()
fmt.Fprintf(b.Stdout, " ---> %s\n", stringid.TruncateID(dispatchRequest.state.imageID))

}
if err := emitImageID(b.Aux, dispatchRequest.state); err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func copierFromDispatchRequest(req dispatchRequest, download sourceDownloader, i
imageSource: imageSource,
platform: platform,
}

}

func (o *copier) createCopyInstruction(sourcesAndDest instructions.SourcesAndDest, cmdName string) (copyInstruction, error) {
Expand Down
2 changes: 0 additions & 2 deletions builder/dockerfile/dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func dispatchEnv(d dispatchRequest, c *instructions.EnvCommand) error {
//
// Sets the maintainer metadata.
func dispatchMaintainer(d dispatchRequest, c *instructions.MaintainerCommand) error {

d.state.maintainer = c.Maintainer
return d.builder.commit(d.state, "MAINTAINER "+c.Maintainer)
}
Expand Down Expand Up @@ -557,7 +556,6 @@ func dispatchVolume(d dispatchRequest, c *instructions.VolumeCommand) error {
//
// Set the signal that will be used to kill the container.
func dispatchStopSignal(d dispatchRequest, c *instructions.StopSignalCommand) error {

_, err := signal.ParseSignal(c.Signal)
if err != nil {
return errdefs.InvalidParameter(err)
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/dispatchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func TestHealthcheckNone(t *testing.T) {
}

func TestHealthcheckCmd(t *testing.T) {

b := newBuilderWithMockBackend()
sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
expectedTest := []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/internals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func TestCopyRunConfig(t *testing.T) {
// Assert the original was not modified
assert.Check(t, runConfig != runConfigCopy, testcase.doc)
}

}

func fullMutableRunConfig() *container.Config {
Expand Down
3 changes: 0 additions & 3 deletions builder/remotecontext/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestProcessShouldRemoveDockerfileDockerignore(t *testing.T) {
executeProcess(t, contextDir)

checkDirectory(t, contextDir, []string{shouldStayFilename})

}

func TestProcessNoDockerignore(t *testing.T) {
Expand All @@ -85,7 +84,6 @@ func TestProcessNoDockerignore(t *testing.T) {
executeProcess(t, contextDir)

checkDirectory(t, contextDir, []string{shouldStayFilename, builder.DefaultDockerfileName})

}

func TestProcessShouldLeaveAllFiles(t *testing.T) {
Expand All @@ -99,7 +97,6 @@ func TestProcessShouldLeaveAllFiles(t *testing.T) {
executeProcess(t, contextDir)

checkDirectory(t, contextDir, []string{shouldStayFilename, builder.DefaultDockerfileName, dockerignoreFilename})

}

// TODO: remove after moving to a separate pkg
Expand Down
1 change: 0 additions & 1 deletion client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
// be sent over the error channel. If an error is sent all processing will be stopped. It's up
// to the caller to reopen the stream in the event of an error by reinvoking this method.
func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {

messages := make(chan events.Message)
errs := make(chan error, 1)

Expand Down
1 change: 0 additions & 1 deletion client/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestEventsErrorFromServer(t *testing.T) {
}

func TestEvents(t *testing.T) {

expectedURL := "/events"

filters := filters.NewArgs()
Expand Down
1 change: 0 additions & 1 deletion cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ func newRouterOptions(config *config.Config, d *daemon.Daemon) (routerOptions, e

func (cli *DaemonCli) reloadConfig() {
reload := func(c *config.Config) {

// Revalidate and reload the authorization plugins
if err := validateAuthzPlugins(c.AuthorizationPlugins, cli.d.PluginStore); err != nil {
logrus.Fatalf("Error validating authorization plugin: %v", err)
Expand Down
1 change: 0 additions & 1 deletion cmd/dockerd/trap/trap_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ func TestTrap(t *testing.T) {
}
})
}

}
1 change: 0 additions & 1 deletion daemon/cluster/convert/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func configReferencesToGRPC(sr []*types.ConfigReference) ([]*swarmapi.ConfigRefe
func configReferencesFromGRPC(sr []*swarmapi.ConfigReference) []*types.ConfigReference {
refs := make([]*types.ConfigReference, 0, len(sr))
for _, s := range sr {

r := &types.ConfigReference{
ConfigID: s.ConfigID,
ConfigName: s.ConfigName,
Expand Down
1 change: 0 additions & 1 deletion daemon/cluster/convert/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func endpointFromGRPC(e *swarmapi.Endpoint) types.Endpoint {
NetworkID: v.NetworkID,
Addr: v.Addr})
}

}

return endpoint
Expand Down
4 changes: 0 additions & 4 deletions daemon/cluster/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func serviceSpecFromGRPC(spec *swarmapi.ServiceSpec) (*types.ServiceSpec, error)
for _, n := range spec.Networks {
netConfig := types.NetworkAttachmentConfig{Target: n.Target, Aliases: n.Aliases, DriverOpts: n.DriverAttachmentOpts}
serviceNetworks = append(serviceNetworks, netConfig)

}

taskTemplate, err := taskSpecFromGRPC(spec.Task)
Expand Down Expand Up @@ -169,7 +168,6 @@ func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) {
for _, n := range s.TaskTemplate.Networks {
netConfig := &swarmapi.NetworkAttachmentConfig{Target: n.Target, Aliases: n.Aliases, DriverAttachmentOpts: n.DriverOpts}
taskNetworks = append(taskNetworks, netConfig)

}

spec := swarmapi.ServiceSpec{
Expand Down Expand Up @@ -473,7 +471,6 @@ func resourcesToGRPC(res *types.ResourceRequirements) *swarmapi.ResourceRequirem
MemoryBytes: res.Reservations.MemoryBytes,
Generic: GenericResourcesToGRPC(res.Reservations.GenericResources),
}

}
}
return reqs
Expand Down Expand Up @@ -536,7 +533,6 @@ func restartPolicyToGRPC(p *types.RestartPolicy) (*swarmapi.RestartPolicy, error
}
if p.MaxAttempts != nil {
rp.MaxAttempts = *p.MaxAttempts

}
}
return rp, nil
Expand Down
1 change: 0 additions & 1 deletion daemon/cluster/executor/container/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ func (c *containerAdapter) createVolumes(ctx context.Context) error {
// It returns an error if the driver name is different - that is a valid error
return err
}

}

return nil
Expand Down
1 change: 0 additions & 1 deletion daemon/cluster/executor/container/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
)

func TestHealthStates(t *testing.T) {

// set up environment: events, task, container ....
e := events.New()
_, l, _ := e.Subscribe()
Expand Down
4 changes: 0 additions & 4 deletions daemon/cluster/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,11 @@ func (c *Cluster) CreateService(s types.ServiceSpec, encodedAuth string, queryRe
logrus.Warnf("unable to pin image %s to digest: %s", ctnr.Image, err.Error())
// warning in the client response should be concise
resp.Warnings = append(resp.Warnings, digestWarning(ctnr.Image))

} else if ctnr.Image != digestImage {
logrus.Debugf("pinning image %s by digest: %s", ctnr.Image, digestImage)
ctnr.Image = digestImage

} else {
logrus.Debugf("creating service using supplied digest reference %s", ctnr.Image)

}

// Replace the context with a fresh one.
Expand Down Expand Up @@ -286,7 +283,6 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec typ
var resp *apitypes.ServiceUpdateResponse

err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {

err := c.populateNetworkID(ctx, state.controlClient, &spec)
if err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions daemon/container_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) (retErr er
if err := daemon.connectToNetwork(container, defaultNetName, nConf.EndpointSettings, updateSettings); err != nil {
return err
}

}

// the intermediate map is necessary because "connectToNetwork" modifies "container.NetworkSettings.Networks"
Expand Down Expand Up @@ -601,7 +600,6 @@ func (daemon *Daemon) allocateNetwork(container *container.Container) (retErr er
}
}()
}

}

if _, err := container.WriteHostConfig(); err != nil {
Expand Down
1 change: 0 additions & 1 deletion daemon/daemon_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,4 @@ func TestRootMountCleanup(t *testing.T) {
checkMounted(t, cfg.Root, false)
assert.Assert(t, d.cleanupMounts())
})

}
2 changes: 0 additions & 2 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
if len(resources.BlkioDeviceWriteBps) > 0 && !sysInfo.BlkioWriteBpsDevice {
warnings = append(warnings, "Your kernel does not support BPS Block I/O write limit or the cgroup is not mounted. Block I/O BPS write limit discarded.")
resources.BlkioDeviceWriteBps = []*pblkiodev.ThrottleDevice{}

}
if len(resources.BlkioDeviceReadIOps) > 0 && !sysInfo.BlkioReadIOpsDevice {
warnings = append(warnings, "Your kernel does not support IOPS Block read limit or the cgroup is not mounted. Block I/O IOPS read limit discarded.")
Expand Down Expand Up @@ -1090,7 +1089,6 @@ func setupInitLayer(idMapping idtools.IdentityMapping) func(containerfs.Containe
//
// If names are used, they are verified to exist in passwd/group
func parseRemappedRoot(usergrp string) (string, string, error) {

var (
userID, groupID int
username, groupname string
Expand Down
1 change: 0 additions & 1 deletion daemon/graphdriver/aufs/aufs.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ func (a *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts
// Create three folders for each id
// mnt, layers, and diff
func (a *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {

if opts != nil && len(opts.StorageOpt) != 0 {
return fmt.Errorf("--storage-opt is not supported for aufs")
}
Expand Down
1 change: 0 additions & 1 deletion daemon/graphdriver/btrfs/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type btrfsOptions struct {
// Init returns a new BTRFS driver.
// An error is returned if BTRFS is not supported.
func Init(home string, options []string, idMap idtools.IdentityMapping) (graphdriver.Driver, error) {

// Perform feature detection on /var/lib/docker/btrfs if it's an existing directory.
// This covers situations where /var/lib/docker/btrfs is a mount, and on a different
// filesystem than /var/lib/docker.
Expand Down
5 changes: 0 additions & 5 deletions daemon/graphdriver/devmapper/deviceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ func (devices *DeviceSet) migrateOldMetaData() error {
if err := os.Rename(devices.oldMetadataFile(), devices.oldMetadataFile()+".migrated"); err != nil {
return err
}

}

return nil
Expand Down Expand Up @@ -1148,7 +1147,6 @@ func (devices *DeviceSet) setupVerifyBaseImageUUIDFS(baseInfo *devInfo) error {
}

func (devices *DeviceSet) checkGrowBaseDeviceFS(info *devInfo) error {

if !userBaseSize {
return nil
}
Expand Down Expand Up @@ -1622,7 +1620,6 @@ func (devices *DeviceSet) loadThinPoolLoopBackInfo() error {
devices.dataDevice = dataLoopDevice
devices.dataLoopFile = datafilename
}

}

// metadata device has not been passed in. So there should be a
Expand All @@ -1643,7 +1640,6 @@ func (devices *DeviceSet) loadThinPoolLoopBackInfo() error {
}

func (devices *DeviceSet) enableDeferredRemovalDeletion() error {

// If user asked for deferred removal then check both libdm library
// and kernel driver support deferred removal otherwise error out.
if enableDeferredRemoval {
Expand Down Expand Up @@ -1946,7 +1942,6 @@ func (devices *DeviceSet) AddDevice(hash, baseHash string, storageOpt map[string
}

func (devices *DeviceSet) parseStorageOpt(storageOpt map[string]string) (uint64, error) {

// Read size to change the block device size per container.
for key, val := range storageOpt {
key := strings.ToLower(key)
Expand Down
5 changes: 2 additions & 3 deletions daemon/graphdriver/graphtest/graphbench_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ func DriverBenchDiffApplyN(b *testing.B, fileCount int, drivername string, drive
// suppressing "SA9003: empty branch (staticcheck)" instead of commenting-out/removing
// these lines because removing/commenting these lines causes a ripple effect
// of changes, and there's still a to-do below
//nolint:staticcheck
//nolint:staticcheck,revive
if applyDiffSize != diffSize {
// TODO: enforce this
//b.Fatalf("Apply diff size different, got %d, expected %s", applyDiffSize, diffSize)
// b.Fatalf("Apply diff size different, got %d, expected %s", applyDiffSize, diffSize)
}
if err := checkManyFiles(driver, diff, fileCount, 6); err != nil {
b.Fatal(err)
Expand Down Expand Up @@ -247,7 +247,6 @@ func DriverBenchDeepLayerRead(b *testing.B, layerCount int, drivername string, d

b.ResetTimer()
for i := 0; i < b.N; i++ {

// Read content
c, err := contdriver.ReadFile(root, root.Join(root.Path(), "testfile.txt"))
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion daemon/graphdriver/graphtest/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string,
}

lastLayer = nextLayer

}
return lastLayer, nil
}
Expand Down
1 change: 0 additions & 1 deletion daemon/graphdriver/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts
// Create is used to create the upper, lower, and merge directories required for overlay fs for a given id.
// The parent filesystem is used to configure these directories for the overlay.
func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr error) {

if opts != nil && len(opts.StorageOpt) != 0 {
return fmt.Errorf("--storage-opt is not supported for overlay")
}
Expand Down
1 change: 0 additions & 1 deletion daemon/graphdriver/zfs/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e
if rmErr := unix.Rmdir(mountpoint); rmErr != nil && !os.IsNotExist(rmErr) {
logrus.WithField("storage-driver", "zfs").Debugf("Failed to remove %s: %v", id, rmErr)
}

}
}
}()
Expand Down