Deprecated note https://github.com/docker/docker/blob/master/docs/deprecated.md#docker-ps-before-and-since-options
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
| ... | ... |
@@ -26,8 +26,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
| 26 | 26 |
all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)")
|
| 27 | 27 |
noTrunc = cmd.Bool([]string{"-no-trunc"}, false, "Don't truncate output")
|
| 28 | 28 |
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")
|
|
| 31 | 29 |
last = cmd.Int([]string{"n"}, -1, "Show n last created containers (includes all states)")
|
| 32 | 30 |
format = cmd.String([]string{"-format"}, "", "Pretty-print containers using a Go template")
|
| 33 | 31 |
flFilter = opts.NewListOpts(nil) |
| ... | ... |
@@ -52,8 +50,6 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
| 52 | 52 |
options := types.ContainerListOptions{
|
| 53 | 53 |
All: *all, |
| 54 | 54 |
Limit: *last, |
| 55 |
- Since: *since, |
|
| 56 |
- Before: *before, |
|
| 57 | 55 |
Size: *size, |
| 58 | 56 |
Filter: psFilterArgs, |
| 59 | 57 |
} |
| ... | ... |
@@ -174,8 +174,6 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte |
| 174 | 174 |
} |
| 175 | 175 |
|
| 176 | 176 |
var beforeContFilter, sinceContFilter *container.Container |
| 177 |
- // FIXME remove this for 1.12 as --since and --before are deprecated |
|
| 178 |
- var beforeContainer, sinceContainer *container.Container |
|
| 179 | 177 |
|
| 180 | 178 |
err = psFilters.WalkValues("before", func(value string) error {
|
| 181 | 179 |
beforeContFilter, err = daemon.GetContainer(value) |
| ... | ... |
@@ -213,29 +211,11 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte |
| 213 | 213 |
}) |
| 214 | 214 |
} |
| 215 | 215 |
|
| 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 |
- |
|
| 232 | 216 |
return &listContext{
|
| 233 | 217 |
filters: psFilters, |
| 234 | 218 |
ancestorFilter: ancestorFilter, |
| 235 | 219 |
images: imagesFilter, |
| 236 | 220 |
exitAllowed: filtExited, |
| 237 |
- beforeContainer: beforeContainer, |
|
| 238 |
- sinceContainer: sinceContainer, |
|
| 239 | 221 |
beforeFilter: beforeContFilter, |
| 240 | 222 |
sinceFilter: sinceContFilter, |
| 241 | 223 |
ContainerListOptions: config, |
| ... | ... |
@@ -263,8 +243,7 @@ func includeContainerInList(container *container.Container, ctx *listContext) it |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 | 265 |
// 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 {
|
|
| 266 |
+ if !container.Running && !ctx.All && ctx.Limit <= 0 {
|
|
| 268 | 267 |
return excludeContainer |
| 269 | 268 |
} |
| 270 | 269 |
|
| ... | ... |
@@ -288,21 +267,6 @@ func includeContainerInList(container *container.Container, ctx *listContext) it |
| 288 | 288 |
return excludeContainer |
| 289 | 289 |
} |
| 290 | 290 |
|
| 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 |
- |
|
| 306 | 291 |
// Stop iteration when the index is over the limit |
| 307 | 292 |
if ctx.Limit > 0 && ctx.idx == ctx.Limit {
|
| 308 | 293 |
return stopIteration |
| ... | ... |
@@ -48,7 +48,7 @@ defining it at container creation (`POST /containers/create`). |
| 48 | 48 |
|
| 49 | 49 |
**Deprecated In Release: [v1.10.0](https://github.com/docker/docker/releases/tag/v1.10.0)** |
| 50 | 50 |
|
| 51 |
-**Target For Removal In Release: v1.12** |
|
| 51 |
+**Removed In Release: v1.12** |
|
| 52 | 52 |
|
| 53 | 53 |
The `docker ps --before` and `docker ps --since` options are deprecated. |
| 54 | 54 |
Use `docker ps --filter=before=...` and `docker ps --filter=since=...` instead. |
| ... | ... |
@@ -117,86 +117,8 @@ func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
|
| 117 | 117 |
|
| 118 | 118 |
} |
| 119 | 119 |
|
| 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 |
- |
|
| 191 | 120 |
func assertContainerList(out string, expected []string) bool {
|
| 192 | 121 |
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 |
- } |
|
| 200 | 122 |
|
| 201 | 123 |
if len(lines)-1 != len(expected) {
|
| 202 | 124 |
return false |