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

Fixed knife vault show -F json and knife vault list -F json don't always output valid JSON #348

Conversation

sanga1794
Copy link
Contributor

@sanga1794 sanga1794 commented Jun 8, 2020

Description

Fixed knife vault show -F json and knife vault list -F json don't always output valid JSON

Related Issue

Fixed: #313

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

Signed-off-by: sanga17 <sausekar@msystechnologies.com>
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
@sanga1794 sanga1794 requested a review from a team June 8, 2020 10:04
@sanga1794 sanga1794 changed the title WIP: Fixed knife vault show -F json and knife vault list -F json don't always output valid JSON Fixed knife vault show -F json and knife vault list -F json don't always output valid JSON Jun 10, 2020
@@ -35,7 +35,7 @@ def run
bags.each_key do |bagname|
vaultbags.push(bagname) if bag_is_vault?(bagname)
end
output vaultbags.join("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this going to result in hard to read output on the CLI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @tas50, nothing impacted on the CLI's output, but if we use join it is causing issues for JSON format, as posted in the issue.

split_vault_keys(bag)[1].each do |item|
output item
end
output split_vault_keys(bag)[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's more than 1 key this will only show a single key. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @tas50,yes it is intentional as split_vault_keys method return array of keys and items

.

And regarding the change made in PR, below are some o/ps before change and after change:

Before Change:

knife vault show val_passwords
   root
   root1
knife vault show val_passwords -F json
   "root"
   "root1"
knife vault show val_passwords -F yaml
	--- root
	...
	--- root1
	...

After Change:

knife vault show val_passwords
	root
	root1
knife vault show val_passwords -F json
	[
  	"root",
  	"root1"
	]
knife vault show val_passwords -F yaml
	---
	- root
	- root1

Copy link
Contributor

@tas50 tas50 left a comment

Choose a reason for hiding this comment

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

This seems like a breaking change

@tas50 tas50 merged commit 215f028 into chef:master Sep 28, 2020
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.

knife vault show -F json and knife vault list -F json don't always output valid JSON
3 participants