Skip to content

Commit 91b7157

Browse files
author
Wen Cheng Ma
committed
Deprecated of docker ps since and before options for v1.12
Deprecated note https://github.com/docker/docker/blob/master/docs/deprecated.md#docker-ps-before-and-since-options Signed-off-by: Wen Cheng Ma <[email protected]>
1 parent 7fd53f7 commit 91b7157

File tree

4 files changed

+2
-120
lines changed

4 files changed

+2
-120
lines changed

api/client/ps.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
2626
all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)")
2727
noTrunc = cmd.Bool([]string{"-no-trunc"}, false, "Don't truncate output")
2828
nLatest = cmd.Bool([]string{"l", "-latest"}, false, "Show the latest created container (includes all states)")
29-
since = cmd.String([]string{"#-since"}, "", "Show containers created since Id or Name (includes all states)")
30-
before = cmd.String([]string{"#-before"}, "", "Only show containers created before Id or Name")
3129
last = cmd.Int([]string{"n"}, -1, "Show n last created containers (includes all states)")
3230
format = cmd.String([]string{"-format"}, "", "Pretty-print containers using a Go template")
3331
flFilter = opts.NewListOpts(nil)
@@ -52,8 +50,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
5250
options := types.ContainerListOptions{
5351
All: *all,
5452
Limit: *last,
55-
Since: *since,
56-
Before: *before,
5753
Size: *size,
5854
Filter: psFilterArgs,
5955
}

daemon/list.go

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte
174174
}
175175

176176
var beforeContFilter, sinceContFilter *container.Container
177-
// FIXME remove this for 1.12 as --since and --before are deprecated
178-
var beforeContainer, sinceContainer *container.Container
179177

180178
err = psFilters.WalkValues("before", func(value string) error {
181179
beforeContFilter, err = daemon.GetContainer(value)
@@ -213,29 +211,11 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte
213211
})
214212
}
215213

216-
// FIXME remove this for 1.12 as --since and --before are deprecated
217-
if config.Before != "" {
218-
beforeContainer, err = daemon.GetContainer(config.Before)
219-
if err != nil {
220-
return nil, err
221-
}
222-
}
223-
224-
// FIXME remove this for 1.12 as --since and --before are deprecated
225-
if config.Since != "" {
226-
sinceContainer, err = daemon.GetContainer(config.Since)
227-
if err != nil {
228-
return nil, err
229-
}
230-
}
231-
232214
return &listContext{
233215
filters: psFilters,
234216
ancestorFilter: ancestorFilter,
235217
images: imagesFilter,
236218
exitAllowed: filtExited,
237-
beforeContainer: beforeContainer,
238-
sinceContainer: sinceContainer,
239219
beforeFilter: beforeContFilter,
240220
sinceFilter: sinceContFilter,
241221
ContainerListOptions: config,
@@ -263,8 +243,7 @@ func includeContainerInList(container *container.Container, ctx *listContext) it
263243
}
264244

265245
// Do not include container if it's stopped and we're not filters
266-
// FIXME remove the ctx.beforContainer and ctx.sinceContainer part of the condition for 1.12 as --since and --before are deprecated
267-
if !container.Running && !ctx.All && ctx.Limit <= 0 && ctx.beforeContainer == nil && ctx.sinceContainer == nil {
246+
if !container.Running && !ctx.All && ctx.Limit <= 0 {
268247
return excludeContainer
269248
}
270249

@@ -288,21 +267,6 @@ func includeContainerInList(container *container.Container, ctx *listContext) it
288267
return excludeContainer
289268
}
290269

291-
// FIXME remove this for 1.12 as --since and --before are deprecated
292-
if ctx.beforeContainer != nil {
293-
if container.ID == ctx.beforeContainer.ID {
294-
ctx.beforeContainer = nil
295-
}
296-
return excludeContainer
297-
}
298-
299-
// FIXME remove this for 1.12 as --since and --before are deprecated
300-
if ctx.sinceContainer != nil {
301-
if container.ID == ctx.sinceContainer.ID {
302-
return stopIteration
303-
}
304-
}
305-
306270
// Stop iteration when the index is over the limit
307271
if ctx.Limit > 0 && ctx.idx == ctx.Limit {
308272
return stopIteration

docs/deprecated.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ defining it at container creation (`POST /containers/create`).
4848

4949
**Deprecated In Release: [v1.10.0](https://github.com/docker/docker/releases/tag/v1.10.0)**
5050

51-
**Target For Removal In Release: v1.12**
51+
**Removed In Release: v1.12**
5252

5353
The `docker ps --before` and `docker ps --since` options are deprecated.
5454
Use `docker ps --filter=before=...` and `docker ps --filter=since=...` instead.

integration-cli/docker_cli_ps_test.go

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -117,86 +117,8 @@ func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
117117

118118
}
119119

120-
// FIXME remove this for 1.12 as --since and --before are deprecated
121-
func (s *DockerSuite) TestPsListContainersDeprecatedSinceAndBefore(c *check.C) {
122-
out, _ := runSleepingContainer(c, "-d")
123-
firstID := strings.TrimSpace(out)
124-
125-
out, _ = runSleepingContainer(c, "-d")
126-
secondID := strings.TrimSpace(out)
127-
128-
// not long running
129-
out, _ = dockerCmd(c, "run", "-d", "busybox", "true")
130-
thirdID := strings.TrimSpace(out)
131-
132-
out, _ = runSleepingContainer(c, "-d")
133-
fourthID := strings.TrimSpace(out)
134-
135-
// make sure the second is running
136-
c.Assert(waitRun(secondID), checker.IsNil)
137-
138-
// make sure third one is not running
139-
dockerCmd(c, "wait", thirdID)
140-
141-
// make sure the forth is running
142-
c.Assert(waitRun(fourthID), checker.IsNil)
143-
144-
// since
145-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "-a")
146-
expected := []string{fourthID, thirdID, secondID}
147-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE & ALL: Container list is not in the correct order: %v \n%s", expected, out))
148-
149-
out, _ = dockerCmd(c, "ps", "--since="+firstID)
150-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE: Container list is not in the correct order: %v \n%s", expected, out))
151-
152-
// before
153-
out, _ = dockerCmd(c, "ps", "--before="+thirdID, "-a")
154-
expected = []string{secondID, firstID}
155-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE & ALL: Container list is not in the correct order: %v \n%s", expected, out))
156-
157-
out, _ = dockerCmd(c, "ps", "--before="+thirdID)
158-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE: Container list is not in the correct order: %v \n%s", expected, out))
159-
160-
// since & before
161-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "--before="+fourthID, "-a")
162-
expected = []string{thirdID, secondID}
163-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE, BEFORE & ALL: Container list is not in the correct order: %v \n%s", expected, out))
164-
165-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "--before="+fourthID)
166-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE, BEFORE: Container list is not in the correct order: %v \n%s", expected, out))
167-
168-
// since & limit
169-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "-n=2", "-a")
170-
expected = []string{fourthID, thirdID}
171-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE, LIMIT & ALL: Container list is not in the correct order: %v \n%s", expected, out))
172-
173-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "-n=2")
174-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE, LIMIT: Container list is not in the correct order: %v \n%s", expected, out))
175-
176-
// before & limit
177-
out, _ = dockerCmd(c, "ps", "--before="+fourthID, "-n=1", "-a")
178-
expected = []string{thirdID}
179-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE, LIMIT & ALL: Container list is not in the correct order: %v \n%s", expected, out))
180-
181-
out, _ = dockerCmd(c, "ps", "--before="+fourthID, "-n=1")
182-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("BEFORE, LIMIT: Container list is not in the correct order: %v \n%s", expected, out))
183-
184-
// since & before & limit
185-
out, _ = dockerCmd(c, "ps", "--since="+firstID, "--before="+fourthID, "-n=1", "-a")
186-
expected = []string{thirdID}
187-
c.Assert(assertContainerList(out, expected), checker.Equals, true, check.Commentf("SINCE, BEFORE, LIMIT & ALL: Container list is not in the correct order: %v \n%s", expected, out))
188-
189-
}
190-
191120
func assertContainerList(out string, expected []string) bool {
192121
lines := strings.Split(strings.Trim(out, "\n "), "\n")
193-
// FIXME remove this for 1.12 as --since and --before are deprecated
194-
// This is here to remove potential Warning: lines (printed out with deprecated flags)
195-
for i := 0; i < 2; i++ {
196-
if strings.Contains(lines[0], "Warning:") {
197-
lines = lines[1:]
198-
}
199-
}
200122

201123
if len(lines)-1 != len(expected) {
202124
return false

0 commit comments

Comments
 (0)