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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CAT-1646) - Remove section if it has empty line but does not have any settings #532

Merged
merged 1 commit into from Mar 11, 2024

Conversation

Ramesh7
Copy link
Contributor

@Ramesh7 Ramesh7 commented Mar 7, 2024

Summary

Current implementation keeping section as it is if just contain empty line as described here, this change will delete the section if just contain empty line.

Related Issues (if any)

#524

Checklist

  • 馃煝 Spec tests.
  • 馃煝 Acceptance tests.
  • Manually verified. (For example puppet apply)

@Ramesh7 Ramesh7 added the bugfix label Mar 7, 2024
@Ramesh7 Ramesh7 changed the title (CAT-1646) - Remove section if its not have any settings (CAT-1646) - Remove section if it has empty line but does not have any settings Mar 7, 2024
@Ramesh7 Ramesh7 added the wip Work In Progress label Mar 7, 2024
@Ramesh7 Ramesh7 force-pushed the CAT-1646-remove-section-when-its-empty branch 3 times, most recently from 42cfdb1 to ac3f688 Compare March 7, 2024 13:53
@Ramesh7 Ramesh7 removed the wip Work In Progress label Mar 7, 2024
@Ramesh7 Ramesh7 force-pushed the CAT-1646-remove-section-when-its-empty branch from ac3f688 to 4ebe030 Compare March 7, 2024 17:36
@Ramesh7 Ramesh7 marked this pull request as ready for review March 7, 2024 18:06
@Ramesh7 Ramesh7 requested review from bastelfreak, ekohl, smortex and a team as code owners March 7, 2024 18:06
Copy link
Collaborator

@bastelfreak bastelfreak left a comment

Choose a reason for hiding this comment

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

I am not sure if people rely on the old behaviour. If they do, this would be a breaking change. I don't think it's a breaking change, but I cannot rule it out.

Besides that I think that the implementation is fine.

@Ramesh7
Copy link
Contributor Author

Ramesh7 commented Mar 11, 2024

I am not sure if people rely on the old behaviour. If they do, this would be a breaking change. I don't think it's a breaking change, but I cannot rule it out.

Besides that I think that the implementation is fine.

Agreed with you @bastelfreak, BTW it will just remove the empty section which has only new line but it won't impact if a section just has comment. So I feel it should be good to go.

@Ramesh7 Ramesh7 merged commit df37025 into main Mar 11, 2024
46 of 48 checks passed
@Ramesh7 Ramesh7 deleted the CAT-1646-remove-section-when-its-empty branch March 11, 2024 03:07
@vchepkov
Copy link

This is a breaking change and it needs to be an optional behavior. For example, this breaks splunk indexer configuration, which configures replication port with no other settings:

[replication_port://9887]

I would have to use file_line now

@smortex
Copy link
Collaborator

smortex commented Mar 31, 2024

When I read #524 (which this PR is supposed to address and should have been closed?), I understand that the behavior was different when removing the last setting of a section depending on the presence or absence of blank lines in that section, and I guess the behavior is still different if the section has comments. Inconsistency is indeed not great.

AFAIAC, a ini_setting resource should manage settings, and not sections (with the exception of adding the section when in does not already exist), and when removing the last setting of a section, I would never expect that section to disappear. It is basically the behavior of ini-style file manipulation library I have worked with, e.g. GLib.KeyFile. If the user want to remove a section, they should be able to do so by using a relevant resource, that is a specific function for the GLib.Keyfile example, or a specific resource i.e. ini_section { "legacy": ensure => absent }.

I believe we should revert this and release 6.1.2 to remove this breaking change. Then if we want to re-introduce this, a new major version will be required, and I would vote for changing the ini_setting interface to not prune empty sections anymore and have a dedicated resource that can be used to ensure a section is explicitly absent.

@Ramesh7, @vchepkov, @bastelfreak what do you think?

@vchepkov
Copy link

I agree

smortex added a commit that referenced this pull request Mar 31, 2024
PR #532 introduced 4ebe030 breaks
backwards compatibility and is part of a patch release, as stated here:
#532 (comment)

This reverts commit 4ebe030.

This will allow us to do a new patch release that fix the unexpected
backwards incompatible change, and leave the room to implement this as
part of a next major version of the module.
smortex added a commit that referenced this pull request Mar 31, 2024
PR #532 introduced 4ebe030 which breaks
backwards compatibility and is part of a patch release, as reported here:
#532 (comment)

This reverts commit 4ebe030.

This will allow us to do a new patch release that fix the unexpected
backwards incompatible change, and leave the room to implement this as
part of a next major version of the module.
smortex added a commit that referenced this pull request Apr 1, 2024
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
smortex added a commit that referenced this pull request Apr 1, 2024
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
smortex added a commit that referenced this pull request Apr 1, 2024
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
smortex added a commit that referenced this pull request Apr 1, 2024
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
smortex added a commit that referenced this pull request Apr 1, 2024
When the last setting of a section was removed, the whole section was
removed unless it contained white space of comments.  In #532, this was
changed to also remove sections that only contained space (blank lines),
but it caused regressions and was reverted in #535.

For consistency, we completely suppress the auto-removal of "empty"
sections: removing the last setting of a section will not remove this
section anymore, just like what happens for sections with only blank
lines and comments.
@smortex
Copy link
Collaborator

smortex commented Apr 1, 2024

I opened three PR that are ready for testing (each PR include the previous ones):

The last 2 are draft as they should not be merged before a new release including the first PR is done. However, they are ready for review.

Thanks!

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.

None yet

4 participants