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

[knife] Assume a default key when no colon in QUERY #3526

Closed
patcon opened this issue Jun 12, 2015 · 10 comments · Fixed by #5977
Closed

[knife] Assume a default key when no colon in QUERY #3526

patcon opened this issue Jun 12, 2015 · 10 comments · Fixed by #5977
Labels
Type: Enhancement Adds new functionality.

Comments

@patcon
Copy link
Contributor

patcon commented Jun 12, 2015

The thought would be that this could be name: by default (or perhaps fqdn:?), but it could be set to something else in knife.rb

knife search example.com
knife ssh example.com "uname"
@patcon
Copy link
Contributor Author

patcon commented Jun 12, 2015

On further consideration, using the fqdn key and NOT providing a means to set another default key would seem to imply that the feature in #3527 could equally apply to knife ssh (though not knife search):

knife ssh patcon@example.com "uname"`

Again, this would align with user expectations of the ssh command

@lamont-granquist
Copy link
Contributor

knife search node "foo" already goes through some magic to search name and fqdn and possibly a couple other fields by default. that code could simply be reused for knife ssh.

@patcon
Copy link
Contributor Author

patcon commented Jun 15, 2015

thanks! found it:

def fuzzify_query
if @query !~ /:/
@query = "tags:*#{@query}* OR roles:*#{@query}* OR fqdn:*#{@query}* OR addresses:*#{@query}*"
end
end

I'll mess around with it later

@patcon
Copy link
Contributor Author

patcon commented Jun 15, 2015

Hm. On consideration, "tags or role or fqdn or addresses" might be a little too general for a possibly destructive command, you think?

@lamont-granquist
Copy link
Contributor

I never run a destructive ssh command without validating the targets it will hit with a non-destructive command. And the knife ssh command is necessarily a chainsaw, anyone with access to it is trusted to not run 'knife ssh "sudo rm -rf / &"'

@patcon
Copy link
Contributor Author

patcon commented Jun 16, 2015

:) 👍 I'll look into tests then

@sawanoboly
Copy link
Contributor

@lamont-granquist @patcon

I agree that the QUERY has a default key when : was omited.

And, It will enough for in most use cases, I think.

  • for node => use name:,fqdn:, or ipaddress: by default
  • for other than the node (such as roles, users) => use name: by default

@patcon
Copy link
Contributor Author

patcon commented Jun 18, 2015

@sawanoboly Thanks for the feedback. @lamont-granquist said in the PR's inline comments that he preferred this share the same fuzziness as search, so I'm assuming that applies to all indexes. Correct me if I'm wrong though, @lamont-granquist

@lamont-granquist
Copy link
Contributor

Yes, and not just share the same semantics, but no code duplication. Extract a method, if there isn't one already, and use it both places consistently.

@lamont-granquist lamont-granquist added this to the Help Wanted milestone Sep 9, 2015
@lamont-granquist
Copy link
Contributor

And dan is updating the knife search node fuzzifier method in #3913 for policyfiles now (which is precisely why the fuzzifier needs to exist only in one spot, not many)

@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 25, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants