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

Client discovery should default to the search query #48

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ declarative state. To get the `knife vault create` behavior, use
Corresponds to the "admin" option when using the chef-vault knife
plugin. Can be specified as a comma separated string or an array.
See examples, below.
* `clients` - A search query for the nodes' API clients that should
have access to the item.
* `clients` - Either a Chef::ApiClient object or a search query for the nodes' API clients that should
have access to the item. Defaults to using the query specified for `search`
* `search` - Search query that would match the same used for the
clients, gets stored as a field in the item.
* `raw_data` - The raw data, as a Ruby Hash, that will be stored in
Expand Down
9 changes: 7 additions & 2 deletions libraries/chef_vault_secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ def load_current_resource

Chef::Log.debug("#{new_resource.id} search query: '#{new_resource.search}'")
item.search(new_resource.search)
Chef::Log.debug("#{new_resource.id} clients: '#{new_resource.clients}'")
item.clients([new_resource.clients].flatten.join(',')) unless new_resource.clients.nil?
if new_resource.clients.nil?
Chef::Log.debug('No clients specified. Using search query to discover clients')
item.clients(new_resource.search)
else
Chef::Log.debug("#{new_resource.id} clients: '#{new_resource.clients}'")
item.clients([new_resource.clients].flatten.join(','))
end
Chef::Log.debug("#{new_resource.id} admins (users): '#{new_resource.admins}'")
item.admins([new_resource.admins].flatten.join(','))
item.save
Expand Down