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

Provide option to avoid saving the inspec attributes to the node object #374

Merged
merged 3 commits into from
Jun 21, 2019

Conversation

alexpop
Copy link
Contributor

@alexpop alexpop commented Jun 20, 2019

Introducing a new cookbook attribute ['audit']['attributes_save'] to remove ['audit']['attributes'] from the node object if needed.

Thank you @trickyearlobe for the feedback!

Opening the PR for now while working on tests

@alexpop alexpop requested a review from a team June 20, 2019 13:33
@vjeffrey
Copy link

nice!

Copy link
Contributor

@jerryaldrichiii jerryaldrichiii left a comment

Choose a reason for hiding this comment

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

Love this so much. Thank you.

# Copies ['audit']['attributes'] into run_state for the audit_handler to read them later
# Deletes ['audit']['attributes'] if instructed by ['audit']['attributes_save']
def copy_audit_attributes
node.run_state['audit_attributes'] = node['audit']['attributes']
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmmmm....yasss.

@@ -41,7 +41,8 @@ def report
end
quiet = node['audit']['quiet']
fetcher = node['audit']['fetcher']
attributes = node['audit']['attributes'].to_h

attributes = node.run_state['audit_attributes'].to_h
Copy link
Contributor

Choose a reason for hiding this comment

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

Going from a Mash to a Hash going to cause any issues? (I know it was a .to_h before, but I'm curious)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nobody reported issues with it and tests are showing the expected values.

alexpop added 2 commits June 21, 2019 08:04
Signed-off-by: Alex Pop <alexpop@users.noreply.github.com>
Signed-off-by: Alex Pop <alexpop@users.noreply.github.com>
@alexpop alexpop force-pushed the ap/option-to-not-save-attributes branch from 5dc94ee to 6dd9a31 Compare June 21, 2019 07:36
@alexpop
Copy link
Contributor Author

alexpop commented Jun 21, 2019

Jerry and Victoria, thank you for the reviews!
I pushed another commit with ChefSpec tests to ensure further refactoring of the logic unexpectedly put the inspec attributes in the node object.

Signed-off-by: Alex Pop <alexpop@users.noreply.github.com>
@alexpop alexpop merged commit a19e31c into master Jun 21, 2019
@alexpop alexpop deleted the ap/option-to-not-save-attributes branch June 21, 2019 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants