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

Handle JSON facts structured as name/values #242

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

kpaulisse
Copy link
Contributor

@kpaulisse kpaulisse commented Feb 12, 2021

Overview

This pull request allows JSON facts to come in the following format without double-encoding them. You can get facts structured like this by running puppet facts find $(hostname):

{
  "name":"rspec-node.abc.github.net",
  "values":{
    "apt_update_last_success":1458162123,
    "architecture":"amd64",
    "datacenter":"xyz",
    "fqdn":"rspec-node.xyz.github.net",
    "_timestamp":"2014-12-02 14:56:20 -0600"
  }
}

The YAML fact handler already had logic that dealt with this case, but the JSON handler didn't. So if you submitted the above JSON file in --fact-file it would end up double-encoding them internally:

{
  "name":"unknown.node",
  "values":{
    "name": "rspec-node.abc.github.net",
    "values":{
      "apt_update_last_success":1458162123,
      "architecture":"amd64",
      "datacenter":"xyz",
      "fqdn":"rspec-node.xyz.github.net",
      "_timestamp":"2014-12-02 14:56:20 -0600"
    }
  }
}

Checklist

  • Make sure that all of the tests pass, and fix any that don't. Just run rake in your checkout directory, or review the CI job triggered whenever you push to a pull request.
  • Make sure that there is 100% test coverage by running rake coverage:spec or ignoring untestable sections of code with # :nocov comments. If you need help getting to 100% coverage please ask; however, don't just submit code with no tests.
  • If you have added a new command line option, we would greatly appreciate a corresponding integration test that exercises it from start to finish. This is optional but recommended.
  • If you have added any new gem dependencies, make sure those gems are licensed under the MIT or Apache 2.0 license. We cannot add any dependencies on gems licensed under GPL.
  • If you have added any new gem dependencies, make sure you've checked in a copy of the .gem file into the vendor/cache directory.

@ahayworth ahayworth merged commit 6701b4f into github:master Feb 16, 2021
@ahayworth ahayworth added this to the 2.1.0 milestone Feb 16, 2021
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.

2 participants