saltstack-formulas / zabbix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
50 stars 121 forks source link

When creating directory that is included from agent config, strip filename or glob at the end #145

Closed ghormoon closed 3 years ago

ghormoon commented 3 years ago

PR progress checklist (to be filled in by reviewers)

What type of PR is this?

Primary type

Does this PR introduce a BREAKING CHANGE?

Potentially. Currently all the examples seem to end with "/" if it's an directory, so should work. If user creates an include "/path/to/an/directory", it will only create "/path/to/an/", as it doesn't have a way to determine it better, than the slash at the end.

Related issues and/or pull requests

https://github.com/saltstack-formulas/zabbix-formula/issues/111

Describe the changes you're proposing

Strip the filename or glob at the end of the path, if it's not a directory

Pillar / config required to test the proposed changes

try with both a directory (ending in "/") and a file-like path in agent includes, i did with zabbix: lookup: agent: includes:

Debug log showing how the proposed changes work


      ID: /etc/zabbix/zabbix_agent2.d/*.conf
Function: file.directory
    Name: /etc/zabbix/zabbix_agent2.d
  Result: True
 Comment: The directory /etc/zabbix/zabbix_agent2.d is in the correct state
 Started: 22:48:22.035102
Duration: 2.741 ms
 Changes:   

      ID: /tmp/test/
Function: file.directory
    Name: /tmp/test
  Result: True
 Comment: Directory /tmp/test updated
 Started: 22:48:22.038714
Duration: 3.47 ms
 Changes:   
          ----------
          /tmp/test:
              New Dir

Documentation checklist

no need to update examples/docs

Testing checklist

I did not write tests to this, is it necessary for such bugfix?

hatifnatt commented 3 years ago

Thanks @ghormoon !

saltstack-formulas-travis commented 3 years ago

:tada: This PR is included in version 1.0.5 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: