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

Allow arbitrary data in Details map in results #1130

Merged

Conversation

zubron
Copy link
Contributor

@zubron zubron commented Jun 9, 2020

What this PR does / why we need it:
The previous Details structure in the Sonobuoy results format was a
map[string]string. As we are creating more plugins that are providing
reports in the Sonobuoy results format, this structure is limiting. To
allow more flexibility, the type is being changed to
map[string]interface{} to allow plugins to provide arbitrary data in
the Details field.

The version of the YAML library used when parsing the results in a
results tarball has been upgraded to v3. This is due to the fact that it
unmarshals data into a map[string]interface{} type when all the keys
are strings. In v2, the behaviour was to always marshal to
map[interface{}]interface{}. This is important as if the keys are not
strings then marshalling to JSON will fail when using the --detailed
mode of the results command.

See: go-yaml/yaml#384 and go-yaml/yaml#591.

Signed-off-by: Bridget McErlean bmcerlean@vmware.com

Release note:

The Sonobuoy Results format now uses map[string]interface{} for the Details field. This allows arbitrary data to be included in this field. For compatibility with other results processing operations, only string keys should be used in any maps contained within this field.

@@ -58,6 +58,7 @@ func manualProcessFile(pluginDir, currentFile string) (Item, error) {

rootObj.Status = resultObj.Status
rootObj.Items = resultObj.Items
rootObj.Details = resultObj.Details
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Including this as this field wasn't being set on the root item. It's covered in the new test in manual_test.go.

@zubron zubron force-pushed the allow-arbitrary-details-in-results branch 4 times, most recently from 35516dc to 180f9c5 Compare June 11, 2020 18:01
The previous `Details` structure in the Sonobuoy results format was a
`map[string]string`. As we are creating more plugins that are providing
reports in the Sonobuoy results format, this structure is limiting. To
allow more flexibility, the type is being changed to
`map[string]interface{}` to allow plugins to provide arbitrary data in
the `Details` field.

The version of the YAML library used when parsing the results in a
results tarball has been upgraded to v3. This is due to the fact that it
unmarshals data into a `map[string]interface{}` type when all the keys
are strings. In v2, the behaviour was to always marshal to
`map[interface{}]interface{}`. This is important as if the keys are not
strings then marshalling to JSON will fail when using the `--detailed`
mode of the `results` command.

Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
@zubron zubron force-pushed the allow-arbitrary-details-in-results branch from 180f9c5 to de8e23a Compare June 11, 2020 18:12
@zubron zubron merged commit 03ae14e into vmware-tanzu:master Jun 11, 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.

None yet

1 participant