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

Make --output_report work when diffing two catalog files or directories. #50

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

natemccurdy
Copy link

Prior to this, the --output_report flag only worked when invoking
puppet catalog diff with two hostnames (i.e. when remotely compiling
catalogs). If you tried to diff two catalog files and save a report, the
report would not be saved.

After this, the --outuput_report flag works will all invocations of
puppet catalog diff and a report will be saved if used when passing
two catalog files.

For example, this now correctly saves a report:

puppet catalog diff catalog-A.json catalog-B.json --output_report ~/report.json

Fixes issue #37

Prior to this, the `--output_report` flag only worked when invoking
`puppet catalog diff` with two hostnames (i.e. when remotely compiling
catalogs). If you tried to diff two catalog files and save a report, the
report would not be saved.

After this, the `--outuput_report` flag works will all invocations of
`puppet catalog diff` and a report will be saved if used when passing
two catalog files.

For example, this now correctly saves a report:
```
puppet catalog diff catalog-A.json catalog-B.json --output_report ~/report.json
```
Copy link
Member

@raphink raphink left a comment

Choose a reason for hiding this comment

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

lgtm

@raphink raphink merged commit afbfee0 into voxpupuli:master Jun 21, 2021
@natemccurdy natemccurdy deleted the issues/37/report branch June 21, 2021 18:29
@alexjfisher
Copy link
Member

@bastelfreak I think this needs reverting. You're not seeing anything in catalog-diff-viewer since your json is missing the fields that were added to nodes after the report was written.

@alexjfisher
Copy link
Member

Pre this PR, the report.json (run against a single node ie --fact_search 'fqdn=host.example.com')

{
  "host.example.com": {
    "old_version": "de6c598f2b8dc45c20db040cdc7000f0ac8ad1eb",
    "new_version": "de6c598f2b8dc45c20db040cdc7000f0ac8ad1eb",
    "old_environment": "production",
    "new_environment": "production",
    "total_resources_in_old": 1874,
    "total_resources_in_new": 1874,
    "only_in_old": [],
    "only_in_new": [],
    "differences_in_old": {},
    "differences_in_new": {},                                                                                                                                                                                                                   "differences_as_diff": {},
    "params_in_old": {},
    "params_in_new": {},
    "content_differences": {},
    "catalag_percentage_added": "0.00",
    "catalog_percentage_removed": "0.00",
    "catalog_percentage_changed": "0.00",
    "added_and_removed_resources": "0 / 0",
    "node_percentage": 0,
    "node_differences": 0
  },
  "total_percentage": 0,
  "with_changes": 0,
  "most_changed": [],
  "most_differences": [],
  "total_nodes": 1,
  "date": "2022-06-10T16:12:28+01:00",
  "all_changed_nodes": [],
  "pull_output": {
    "failed_nodes": {},
    "failed_nodes_total": 0,
    "compiled_nodes": [],
    "compiled_nodes_total": 0,
    "total_nodes": 1,
    "total_percentage": 0,
    "failed_to_compile_files": [],
    "example_compile_errors": []
  }
}

After this PR...

{
  "host.example.com": {
    "old_version": "de6c598f2b8dc45c20db040cdc7000f0ac8ad1eb",
    "new_version": "de6c598f2b8dc45c20db040cdc7000f0ac8ad1eb",
    "old_environment": "production",
    "new_environment": "production",
    "total_resources_in_old": 1874,
    "total_resources_in_new": 1874,
    "only_in_old": [],
    "only_in_new": [],
    "differences_in_old": {},
    "differences_in_new": {},
    "differences_as_diff": {},
    "params_in_old": {},
    "params_in_new": {},
    "content_differences": {},
    "catalag_percentage_added": "0.00",
    "catalog_percentage_removed": "0.00",
    "catalog_percentage_changed": "0.00",
    "added_and_removed_resources": "0 / 0",
    "node_percentage": 0,
    "node_differences": 0
  }
}

@bastelfreak
Copy link
Member

I also reverted this in my environment and can confirm that the catalog-diff-viewer fails to display the diff with this change, but it works without it.

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.

4 participants