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

Prevent 'false' from showing up in the console report #49

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

natemccurdy
Copy link

@natemccurdy natemccurdy commented Jun 21, 2021

Prior to this, when viewing the report in the console after diffing two
catalog files, the word "false" would show up right next to the number
of "Nodes with the most changes by differences".

For example, note the errant "false" at the end of this:

--------------------------------------------------------------------------------
1 out of 1 nodes changed.                                   0.34%
--------------------------------------------------------------------------------

Nodes with the most changes by percent changed:
1. foo.bar.net-production                                     0.34%

Nodes with the most changes by differences:
1. foo.bar.net-some_feature                                   8false

This was due to a Ruby .key? check inside a string interpolation of
nodes[:puppet_ouput], which when ":pull_output" was not a key in the
nodes hash evaluated to false. And since false was inside the
string interpolation, it got printed to the console.

This fixes that by switching to the "x if condition y" format of
conditional logic, which hides the output of the .key? check.

After this commit, the console output does not contain the word "false".

--------------------------------------------------------------------------------
1 out of 1 nodes changed.                                   0.34%
--------------------------------------------------------------------------------

Nodes with the most changes by percent changed:
1. foo.bar.net-production                                     0.34%

Nodes with the most changes by differences:
1. foo.bar.net-some_feature                                   8

Prior to this, when viewing the report in the console after diffing to
catalog files, the word "false" would show up right next to the number
of "Nodes with the most changes by differences".

For example, note the errant "false" at the end of this:
```
--------------------------------------------------------------------------------
1 out of 1 nodes changed.                                   0.34%
--------------------------------------------------------------------------------

Nodes with the most changes by percent changed:
1. foo.bar.net-production                                     0.34%

Nodes with the most changes by differences:
1. foo.bar.net-some_feature                                   8false
```

This was due to a Ruby `.key?` check inside a string interpolation of
`nodes[:puppet_ouput]`, which when ":pull_output" was not a key in the
`nodes` hash evaluated to `false`. And since `false` was inside the
string interpolation, it got printed to the console.

This fixes that by switching to the "x if condition y" format of
conditional logic, which hides the output of the `.key?` check.

After this commit, the console output does not contain the word "false".
```
--------------------------------------------------------------------------------
1 out of 1 nodes changed.                                   0.34%
--------------------------------------------------------------------------------

Nodes with the most changes by percent changed:
1. foo.bar.net-production                                     0.34%

Nodes with the most changes by differences:
1. foo.bar.net-some_feature                                   8
```
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 5d4606a into voxpupuli:master Jun 21, 2021
@natemccurdy natemccurdy deleted the fix_false_in_console_report branch June 21, 2021 18:34
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