Skip to content

make secret ls support filters in CLI#30810

Merged
thaJeztah merged 1 commit into
moby:masterfrom
allencloud:make-secret-ls-support-filter
Mar 28, 2017
Merged

make secret ls support filters in CLI#30810
thaJeztah merged 1 commit into
moby:masterfrom
allencloud:make-secret-ls-support-filter

Conversation

@allencloud

@allencloud allencloud commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

Signed-off-by: allencloud allen.sun@daocloud.io

This pr makes command docker secret ls support filter.

I found that in daemon API, we have already supported secret list filter query. While I found that in docker CLI, there is no support of this filter yet.

- What I did

  1. rename ./secret/ls.go to ./secret/list.go;
  2. support filter in secret ls command;
  3. add a test case for docker secret ls --filter;
  4. add more filter options in swagger.yml;
  5. update command line reference of docker secret ls.

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch 2 times, most recently from bec81ff to 604dcca Compare February 8, 2017 05:38
@allencloud

Copy link
Copy Markdown
Contributor Author

While here I still have some confusion that the names in secret filter:https://github.com/docker/docker/blame/master/daemon/cluster/filters.go#L102
Could you give me some help, since I guess I have some issues here in dealing names filter in this PR. @ehazlett

@vdemeester vdemeester left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ehazlett

ehazlett commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

Good catch. Looks like it should be names and name_prefixes (https://github.com/docker/swarmkit/blob/4cf6f729d7387f3d6e0a5eb3664969ebf08b66fd/api/control.proto#L352). @diogomonica could tell more about how it actually filters in swarm.

@diogomonica

Copy link
Copy Markdown
Contributor

LGTM

@diogomonica

Copy link
Copy Markdown
Contributor

ping @aaronlehmann

@aaronlehmann

Copy link
Copy Markdown

Good catch. Looks like it should be names and name_prefixes

Filters for other types of objects don't seem to support name_prefixes, so maybe just name is sufficient.

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch 2 times, most recently from e281e7b to ce4d948 Compare February 9, 2017 01:11
@allencloud

Copy link
Copy Markdown
Contributor Author

Thanks a lot for all your feedback.
Now I remove the names filter part from swagger, filter validation, and test cases.
PTAL

@aaronlehmann

Copy link
Copy Markdown

LGTM

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@AkihiroSuda

Copy link
Copy Markdown
Member

Since it was names in 1.13, I think we need to update docs to clarify that.
https://github.com/docker/docker/blob/v1.13.1/api/swagger.yaml#L7646

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch from f2a6c7a to d398b26 Compare February 10, 2017 06:35
@allencloud

Copy link
Copy Markdown
Contributor Author

I added * GET /secretsnow does not support filternames. in version-history.md. PTAL @AkihiroSuda

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch from d398b26 to 51aed85 Compare February 10, 2017 16:18
Comment thread docs/api/version-history.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As it is supported in 1.13 release (the names filter), we can't remove it just like that. We need to do what our deprecation policy requires us to do (i.e. mark it as deprecated for next release, and will be remove in 3 more releases)
/cc @thaJeztah

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:( figured this was added after 1.13

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah API 1.25 and above support this 😓

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be a unit test I think 👼

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test could be merged with the other one (that would let use create and start one daemon, create once the secret and then list them with or without filters).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed already 😄 same as the below one.

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch 4 times, most recently from 6d96855 to 9c23fd3 Compare February 13, 2017 03:50

@vdemeester vdemeester left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the unit tests 👼 I feel some cases are redundant (for each, think of what your are testing and anything that you test multiple time can reduced to once) but that's a nit. The integration test could be a little bit more readable (by extracting some common stuff, like the creation of secrets, the common part of each filter command), but that's a nit too.

But we need to version this change and make sure filtering using names work on API 1.25 and 1.26 🙏

Comment thread daemon/cluster/filters.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have to accept this still (for few version and for API versions 1.25 and 1.26). We need to "version" the accepted list of filter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, we have to say to removal seems not so reasonable, added it back already.

Comment thread daemon/cluster/filters_test.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test is testing the same as above right ? (an invalid value in the middle of valid ones) — if yes, could be remove 👼

Comment thread daemon/cluster/filters_test.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same for this one right ?

@vdemeester

Copy link
Copy Markdown
Member

going to docs-review 👼 /cc @thaJeztah

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch from 9a1fe51 to 6cf6994 Compare March 17, 2017 05:25

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @allencloud, I left some comments

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a blank line before this? I think the Jekyll markdown parser doesn't like it if there's isn't a blank line 😓

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you change the first sentence to;

The filtering flag (`-f` or `--filter`) format is a `key=value` pair. .....

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think in other locations we add a short description here, something like;

* [id](secret_ls.md#id) (secret's ID)
* [label](secret_ls.md#label) (`label=<key>` or `label=<key>=<value>`)
* [name](secret_ls.md#name) (secret's name)

Do we need names (plural) here? I know we have "names" for docker ps because of historical reasons (linked containers), but I don't think it's needed for secrets?

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For a follow up discussion; I'm not very fond of just id here as heading; I think having filter by id or filter secrets by id would be more descriptive, and possibly better for discoverability (searching on Google or the docs search)

@mstanleyjones WDYT?

Comment thread api/swagger.yaml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have names (plural) as filter currently? Or only name ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for my delay. I am afraid that currently we support names. And this is something we hope to deprecate to use name instead. Actually it is indeed supported in docker/master.

@thaJeztah thaJeztah Mar 28, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@allencloud but docker 17.03 does not have docker secret ls --filter. In that case we can remove support for "names", because it has not yet been in a release

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or is it used somewhere else already?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread daemon/cluster/filters_test.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you move the tests for other objects to a separate PR?

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd opt for removing names (plural). The examples in this section are also incorrect, because they use name (singular)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Any input for names in secret filtering? @ehazlett @vdemeester @aaronlehmann

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's remove it from the doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @aaronlehmann, I removed names in the command docker secret ls doc, while remained that in swagger.yml. Is that OK? PTAL

Comment thread docs/reference/commandline/secret_ls.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, I think we do this in other places as well, but wondering; do we actually match a part or only a prefix (which is, erm, a part, but only if the ID starts with the given value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think id filtering is only supported by whole id, or prefix of ID. like:

root@ip-172-31-23-42:~/gocode/src/github.com/allencloud/docker/bundles/17.05.0-dev/binary-client# ./docker secret ls
ID                          NAME                        CREATED             UPDATED
6697bflskwj1998km1gnnjr38   q5s5570vtvnimefos1fyeo2u2   7 weeks ago         7 weeks ago
9u9hk4br2ej0wgngkga6rp4hq   my_secret                   6 weeks ago         6 weeks ago
lofl440t1pmh7vz3qt81v704g   allen                       6 days ago          6 days ago
mem02h8n73mybpgqjf0kfi1n0   test_secret                 6 days ago          6 days ago
sj04gk80yqk2xtdrs64nsyoln   test                        6 weeks ago         6 weeks ago
ueo2vbjbl8kk97mrmlq509e7r   my_secsret                  5 weeks ago         5 weeks ago
root@ip-172-31-23-42:~/gocode/src/github.com/allencloud/docker/bundles/17.05.0-dev/binary-client# ./docker secret ls --filter id=66
ID                          NAME                        CREATED             UPDATED
6697bflskwj1998km1gnnjr38   q5s5570vtvnimefos1fyeo2u2   7 weeks ago         7 weeks ago

@cpuguy83

Copy link
Copy Markdown
Member

Any updates?

@allencloud allencloud force-pushed the make-secret-ls-support-filter branch 9 times, most recently from f5f2dfa to 9bc7bd9 Compare March 26, 2017 02:30
Signed-off-by: allencloud <allen.sun@daocloud.io>
@allencloud allencloud force-pushed the make-secret-ls-support-filter branch from 9bc7bd9 to 3935074 Compare March 27, 2017 02:16
@allencloud

Copy link
Copy Markdown
Contributor Author

Updated. PTAL @thaJeztah

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@thaJeztah

Copy link
Copy Markdown
Member

/cc @albers @sdurrheimer for completion scripts 👍

@thaJeztah

Copy link
Copy Markdown
Member

failures are not related

@thaJeztah thaJeztah merged commit 4df350b into moby:master Mar 28, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.05.0 milestone Mar 28, 2017
@albers

albers commented Mar 29, 2017

Copy link
Copy Markdown
Member

@thaJeztah bash completion is blocked by pending #32013.

@allencloud allencloud deleted the make-secret-ls-support-filter branch March 31, 2017 02:41
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
…filter

make secret ls support filters in CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants