mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
all: replace loop with single append
Signed-off-by: Elena Morozova <lelenanam@gmail.com>
This commit is contained in:
parent
535f52c932
commit
64238fef8c
11 changed files with 15 additions and 45 deletions
|
@ -27,9 +27,7 @@ func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWrit
|
|||
list := []types.NetworkResource{}
|
||||
|
||||
if nr, err := n.clusterProvider.GetNetworks(); err == nil {
|
||||
for _, nw := range nr {
|
||||
list = append(list, nw)
|
||||
}
|
||||
list = append(list, nr...)
|
||||
}
|
||||
|
||||
// Combine the network list returned by Docker daemon if it is not already
|
||||
|
|
|
@ -146,9 +146,7 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
|
|||
// InitRouter initializes the list of routers for the server.
|
||||
// This method also enables the Go profiler if enableProfiler is true.
|
||||
func (s *Server) InitRouter(enableProfiler bool, routers ...router.Router) {
|
||||
for _, r := range routers {
|
||||
s.routers = append(s.routers, r)
|
||||
}
|
||||
s.routers = append(s.routers, routers...)
|
||||
|
||||
m := s.createMux()
|
||||
if enableProfiler {
|
||||
|
|
|
@ -56,9 +56,7 @@ func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]s
|
|||
child.Config.ExposedPorts,
|
||||
)
|
||||
|
||||
for _, envVar := range link.ToEnv() {
|
||||
env = append(env, envVar)
|
||||
}
|
||||
env = append(env, link.ToEnv()...)
|
||||
}
|
||||
|
||||
return env, nil
|
||||
|
|
|
@ -583,9 +583,7 @@ func (devices *DeviceSet) createFilesystem(info *devInfo) (err error) {
|
|||
devname := info.DevName()
|
||||
|
||||
args := []string{}
|
||||
for _, arg := range devices.mkfsArgs {
|
||||
args = append(args, arg)
|
||||
}
|
||||
args = append(args, devices.mkfsArgs...)
|
||||
|
||||
args = append(args, devname)
|
||||
|
||||
|
|
|
@ -75,9 +75,7 @@ func (ctx *Context) Hostname() (string, error) {
|
|||
// arguments.
|
||||
func (ctx *Context) Command() string {
|
||||
terms := []string{ctx.ContainerEntrypoint}
|
||||
for _, arg := range ctx.ContainerArgs {
|
||||
terms = append(terms, arg)
|
||||
}
|
||||
terms = append(terms, ctx.ContainerArgs...)
|
||||
command := strings.Join(terms, " ")
|
||||
return command
|
||||
}
|
||||
|
|
|
@ -333,9 +333,7 @@ func (s *DockerSuite) TestImagesFormat(c *check.C) {
|
|||
|
||||
expected := []string{"myimage", "myimage"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
|
|
@ -288,9 +288,7 @@ func (s *DockerSuite) TestNetworkLsFormat(c *check.C) {
|
|||
|
||||
expected := []string{"bridge", "host", "none"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
@ -312,9 +310,7 @@ func (s *DockerSuite) TestNetworkLsFormatDefaultFormat(c *check.C) {
|
|||
|
||||
expected := []string{"bridge default", "host default", "none default"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
|
|
@ -566,9 +566,7 @@ func (s *DockerSuite) TestPsFormatMultiNames(c *check.C) {
|
|||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
expected := []string{"parent", "child,parent/linkedone"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with non-truncated names: %v, got: %v", expected, names))
|
||||
|
||||
//now list without turning off truncation and make sure we only get the non-link names
|
||||
|
@ -576,9 +574,7 @@ func (s *DockerSuite) TestPsFormatMultiNames(c *check.C) {
|
|||
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
expected = []string{"parent", "child"}
|
||||
var truncNames []string
|
||||
for _, l := range lines {
|
||||
truncNames = append(truncNames, l)
|
||||
}
|
||||
truncNames = append(truncNames, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, truncNames, check.Commentf("Expected array with truncated names: %v, got: %v", expected, truncNames))
|
||||
}
|
||||
|
||||
|
@ -592,9 +588,7 @@ func (s *DockerSuite) TestPsNamesMultipleTime(c *check.C) {
|
|||
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
||||
expected := []string{"test2 test2", "test1 test1"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with names displayed twice: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
|
|
@ -106,9 +106,7 @@ func (s *DockerSuite) TestVolumeLsFormat(c *check.C) {
|
|||
|
||||
expected := []string{"aaa", "soo", "test"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
@ -132,9 +130,7 @@ func (s *DockerSuite) TestVolumeLsFormatDefaultFormat(c *check.C) {
|
|||
|
||||
expected := []string{"aaa default", "soo default", "test default"}
|
||||
var names []string
|
||||
for _, l := range lines {
|
||||
names = append(names, l)
|
||||
}
|
||||
names = append(names, lines...)
|
||||
c.Assert(expected, checker.DeepEquals, names, check.Commentf("Expected array with truncated names: %v, got: %v", expected, names))
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,7 @@ func parseFileContent(content []byte) []string {
|
|||
// Trim additional spaces caused by above stripping.
|
||||
line = strings.TrimSpace(line)
|
||||
}
|
||||
for _, ip := range discovery.Generate(line) {
|
||||
result = append(result, ip)
|
||||
}
|
||||
result = append(result, discovery.Generate(line)...)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -100,9 +100,7 @@ func (opt *ThrottledeviceOpt) String() string {
|
|||
// GetList returns a slice of pointers to ThrottleDevices.
|
||||
func (opt *ThrottledeviceOpt) GetList() []*blkiodev.ThrottleDevice {
|
||||
var throttledevice []*blkiodev.ThrottleDevice
|
||||
for _, v := range opt.values {
|
||||
throttledevice = append(throttledevice, v)
|
||||
}
|
||||
throttledevice = append(throttledevice, opt.values...)
|
||||
|
||||
return throttledevice
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue