Skip to content
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

Support wildcards when selecting resources #71

Closed
rhuss opened this issue Apr 12, 2019 · 13 comments
Closed

Support wildcards when selecting resources #71

rhuss opened this issue Apr 12, 2019 · 13 comments
Labels
kind/feature New feature or request lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@rhuss
Copy link
Contributor

rhuss commented Apr 12, 2019

When using commands which requires a resource name as argument like kn revision get <revision> or kn service get <srv> (or kn service list if not merged together with kn service get as proposed in #48), then having a wildcard evaluation on the argument would be very helpful, especially when dealing with resource names that have autogenerated suffixes (like revisions).

More general, a semantic like for general Unix commands like ls would be very useful IMO.

  • kn revision get --> get all revisions
  • kn revision get * --> same as above
  • kn revision get myrevision-1-9865 --> get specific revision
  • kn revision get myrevision-1-* --> get revision with wildcard
  • kn revision get myrevision* --> filter on revisions, possibly returning multiple entries.
@duglin
Copy link
Contributor

duglin commented Apr 13, 2019

+1 I have scripts to do stuff like this for me for kubectl cmds. In particular, to get the equivalent of kubectl logs foo* is really useful when the pods name is generated.

@rhuss rhuss mentioned this issue Apr 18, 2019
@cppforlife
Copy link

cant use a star btw as it has meaning for bash.

@evankanderson
Copy link
Member

I believe bash will pass through the * if it does not glob anything, but if so, that's non-portable between directories and generally a bad idea. On the other hand, you can write 'foo*' without too much more difficulty, and the familiar syntax may be worth it.

@sixolet
Copy link
Contributor

sixolet commented Apr 26, 2019

Do we want glob or regex?

I like kn service get --glob 'myrevision-1-*' or kn service get --regex 'myrevision-1-.*' or something.

@rhuss
Copy link
Contributor Author

rhuss commented Apr 27, 2019

Right, a shell will leave * untouched if it doesn't match anything.

And yes, you are in danger if one of your files in the current directory is named after your service like a resource descriptor file, which is not unlikely that such a file exists holding e.g. a service definition. However, I would expect wildcard matching mostly for matching random suffixes like on revisions for which you probably don't have a file/directory of the same name in the cwd.

Tbh, I think we can require quoting in such a situation, much like sed and grep does, too. Having a --glob to explicitly switch that behaviour on is of not much value IMO, as you get an error with or without this option when bash globbing kicks in accidentally.

I.e. kn service get --glob myservice* and kn service get myservice* would both give an error if there's a file myservice.yml in the current directory. Likewise, both would work if properly quoted. Using wildcards is opt-in, so people who don't use it won't suffer from any side effects.

I'm for globbing instead of regexps as this is imo (a) sufficient and (b) easier to use.

@duglin
Copy link
Contributor

duglin commented Apr 28, 2019

Another option I've done in the past for my tools is to assume the name given is a prefix, so just default to "*" at then end under the covers. No worry about bash matching files.

@duglin
Copy link
Contributor

duglin commented Apr 28, 2019

And of course, exact full matches take precedence over longer wild-card possibilities, so an exact match would not result in any potential "don't know which one you mean" type of error.

@sixolet sixolet added the kind/feature New feature or request label Jul 11, 2019
navidshaikh added a commit to navidshaikh/client that referenced this issue Aug 28, 2019
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 15, 2020
@duglin
Copy link
Contributor

duglin commented Oct 15, 2020

@rhuss did you still want this?

@rhuss
Copy link
Contributor Author

rhuss commented Dec 1, 2020

@duglin good point, I'm not sure if this is still a top priority. Of course it makes a nice touch. For scripting this would make probably quite some sense, for interactive usage we probably should better level up on our completion game, to allow context sensitive completion values (like actual names that are deployed).

@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 23, 2021
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 24, 2021
@rhuss
Copy link
Contributor Author

rhuss commented Apr 26, 2021

/remove-lifecycle stale

@knative-prow-robot knative-prow-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 26, 2021
@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

6 participants