8000 Adding capability to filter by name, id or status to list containers api by brahmaroutu · Pull Request #8543 · moby/moby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding capability to filter by name, id or status to list containers api #8543

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

Merged
merged 1 commit into from
Oct 20, 2014

Conversation

brahmaroutu
Copy link
Contributor

Addresses #7599

Signed-off-by: Srini Brahmaroutu srbrahma@us.ibm.com

@@ -61,3 +62,22 @@ func FromParam(p string) (Args, error) {
}
return args, nil
}

func MatchFilter(source string, filter Args, field string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like idea, but I would like if we can call this like:

psFilters[field].Match(source)

or

psFilters.Match(field, source)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the second option.

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch 2 times, most recently from 77cf7cc to a80ad0e Compare October 14, 2014 19:51
@brahmaroutu
Copy link
Contributor Author
8000

Please review, I hope I addressed above mentioned issues.

@@ -61,3 +62,22 @@ func FromParam(p string) (Args, error) {
}
return args, nil
}

func (filters Args) Match(source string, field string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer field be first argument.

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from a80ad0e to 2ad0151 Compare October 15, 2014 20:33
@brahmaroutu
Copy link
Contributor Author

@LK4D4 Thanks for reviewing, I made changes based on your comments. Technically I agree one test should do only one thing, second half was just trying to demonstrate that regular expression works instead of recoding the whole test again, I did remove that part now.

// start exited container
runCmd := exec.Command(dockerBinary, "run", "-d", "--name=a_name_to_match", "busybox")
out, _, err := runCommandWithOutput(runCmd)
errorOut(err, t, out)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey sorry so we got rid of this errorOut function in a cleanup PR, can you rebase and change these to t.Fatalf()

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from 2ad0151 to 75afe2b Compare October 17, 2014 18:40
@brahmaroutu
Copy link
Contributor Author

Changed the code to replace errorOut with t.Fatal.

@jessfraz
Copy link
Contributor

one nit, other than that LGTM

8000

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from 75afe2b to 9e7dd9b Compare October 17, 2014 20:17
@brahmaroutu
Copy link
Contributor Author

Yep fixed it, my eyes did not pay attention to copy paste code especially comments. Some of the other comments are also weird, why do we say exited container? I am tempted to get that out too.

@LK4D4
Copy link
Contributor
LK4D4 commented Oct 17, 2014

@brahmaroutu Yup, recheck logic of comments and your tests pls.

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from 9e7dd9b to 531a25b Compare October 17, 2014 20:40
@brahmaroutu
Copy link
Contributor Author

I did change the comments. I believe logic can stay as is, it still does filter with both stopped and running containers in the list.

}
firstID := stripTrailingCharacters(out)

// make sure the exited container is not running
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can take this part out, just so it takes out a bit of the time it takes to run the tests

@brahmaroutu
Copy link
Contributor Author

I want to have two id's so that I can see if I got the one I wanted.

@jessfraz
Copy link
Contributor

ya ya for sure we just don't need to run wait, because technically we don't need that container to have exited

@brahmaroutu
Copy link
Contributor Author

that is true, wait is redundant. Thanks. I have remove that code.

@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from 531a25b to 2345242 Compare October 17, 2014 21:40
@jessfraz
Copy link
Contributor

LGTM

Closes moby#7599

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
@brahmaroutu brahmaroutu force-pushed the filter_containers_7599 branch from 2345242 to 1634625 Compare October 20, 2014 18:33
@LK4D4
Copy link
Contributor
LK4D4 commented Oct 20, 2014

LGTM

LK4D4 added a commit that referenced this pull request Oct 20, 2014
Adding capability to filter by name, id or status to list containers api
@LK4D4 LK4D4 merged commit 52784c0 into moby:master Oct 20, 2014
@brahmaroutu brahmaroutu deleted the filter_containers_7599 branch October 24, 2014 04:20
aanm added a commit to noironetworks/docker that referenced this pull request Feb 19, 2015
Added more examples and functionalities for docker ps documentation

Signed-off-by: André Martins <martins@noironetworks.com>
jessfraz pushed a commit that referenced this pull request Feb 20, 2015
…s-filter

Added missing documentation for PR #8543
SvenDowideit pushed a commit to SvenDowideit/docker that referenced this pull request Feb 26, 2015
…er-ps-filter

Added missing documentation for PR moby#8543
(cherry picked from commit 573e248)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0