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

Add delete_if_empty parameter to the ini_subsetting type/provider #405

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

mmarod
Copy link
Contributor

@mmarod mmarod commented Jul 10, 2020

Adds the capability to remove a parent setting when a subsetting is empty.

Example:

[one]
key = alphabet
key2 = moo

When the following Puppet resource is specified, the key is removed instead of being left empty:

ini_subsetting { 'ensure => absent for alpha':
  ensure          => absent,
  path            => "/tmp/inifile.ini",
  section         => 'one',
  setting         => 'key',
  subsetting      => 'alpha',
  delete_if_empty => true,
}

This results in:

[one]
key2 = moo

Instead of

[one]
key = 
key2 = moo

@mmarod mmarod requested a review from a team as a code owner July 10, 2020 16:15
@puppet-community-rangefinder
Copy link

ini_subsetting is a type

Breaking changes to this file MAY impact these 15 modules (near match):

This module is declared in 127 of 575 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@mmarod mmarod force-pushed the delete_if_empty branch 6 times, most recently from 98d30ad to e71b0f4 Compare July 10, 2020 17:26
accommodate for the case when parent setting should be removed when the
value is empty.
@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2020

Codecov Report

Merging #405 into master will increase coverage by 0.27%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #405      +/-   ##
==========================================
+ Coverage   89.56%   89.83%   +0.27%     
==========================================
  Files          10       10              
  Lines         594      600       +6     
==========================================
+ Hits          532      539       +7     
+ Misses         62       61       -1     
Impacted Files Coverage Δ
lib/puppet/provider/ini_subsetting/ruby.rb 97.91% <100.00%> (+0.09%) ⬆️
lib/puppet/type/ini_subsetting.rb 98.61% <100.00%> (+1.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cded33b...0f5e303. Read the comment docs.

@daianamezdrea
Copy link
Contributor

daianamezdrea commented Jul 14, 2020

Hi @mmarod, this looks good to me and also, all the tests went good. Thank you for your contribution!

@daianamezdrea daianamezdrea merged commit df46d2a into puppetlabs:master Jul 14, 2020
@mmarod mmarod deleted the delete_if_empty branch July 20, 2021 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants