fix ensure_packages duplicate checking#969
Conversation
Instead of just looking for an already existing package resource with the same name, we should check for the parameters, too. Otherwise having one ensure_packages call with ensure => present and one with ensure => absent leads to the second function call being ignored. It should throw a duplicate declaration error instead. Since we are already calling ensure_resource internally and ensure_resource itself does check for duplicates, we don't need that extra check in ensure_package.
|
but does with this patch: |
|
This looks great, thank you for your contribution! |
|
Some people are relying on the old behaviour though. It was introduced in #735 |
|
I'm having problems to update to 5.2.0 from 5.1.0. My code is: now I have problems with a node that contains I think that if there is no conflict between the |
|
4.16.0 Changelog has under bugfixes
5.2.0 Changelog under Fixed
The 'correct' behaviour seems to be based on individual opinion. I'm not sure changing the behaviour in a minor release was correct though. :) |
|
You are right about the 'correct' behaviour. But my question now (sure offtopic), then what is the purpose of |
|
Hi @amateo , I had a look at the surrounding code and I think the problem lies in If your resource is created without any params, e.g. because $opts is empty, The example above works just fine. The example below doesn't. Because in So what happens now is: And with that We probably need an issue for this though, since yes, this is somewhat of a regression and I didn't test the case of packages without parameters.. |
|
An alternative would be, for But in that case |
|
@HelenCampbell what do you think? |
Instead of just looking for an already existing package resource with
the same name, we should check for the parameters, too. Otherwise having
one ensure_packages call with ensure => present and one with ensure =>
absent leads to the second function call being ignored. It should throw
a duplicate declaration error instead.
Since we are already calling ensure_resource internally and
ensure_resource itself does check for duplicates, we don't need that
extra check in ensure_packages.