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
N°7506 - Add method to check if a specific module is installed in iTop #39
N°7506 - Add method to check if a specific module is installed in iTop #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with Denis, as-is the PR doesn't suit us for the following reasons:
- Just looking for a module in that class / table can return true even though the module has been uninstalled. This table is an history, not the current state of the instance.
- Ideally, it would look for the most recent "datamodel %" entry, than look for the module at the exact same datetime.
Oh, that's right indeed. I'll see how it could be retrieved the best then... |
It seems that the
|
Yeah, also had something like this in mind. Please see 8b8849d. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a unit test that check:
- That a common module is present (eg.
itop-structure
as tests run on an iTop 3.2, oritop-config
) - That a fake module is not present (eg.
fake-module
)
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
I lost a full day trying to get the tests working, so I added what I got and should work, but the old version of phpunit does not seem to do what I'm expecting it to do somehow.. |
Thank you very much for coding the extra mile with the unit test, it means a lot. |
Just discussing the unit test with @odain-cbd before merging |
Dear Thomas, I just cloned your fork and indeed there issues with PHPUNIT somehow. we will upgrade this lib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see my proposal
I don't feel like this method fits well into the Utils class, but I have moved and fixed the test. |
c78f77e
to
f35e7f7
Compare
f35e7f7
to
3e2120d
Compare
Discussing this with Stephen, wouldn't it be better if we could pass an optional "min version" for the module? |
"I don't feel like this method fits well into the Utils class, but I have moved and fixed the test." I agree with you. maybe it should be located somewhere else than Utils. I just proposed it to let you validate this feature. now that is tested you may easily move it in a proper place. maybe a new class? |
@Molkobain I'm not sure if this should also be in the same method.. What do you propose as its prototype then? An optional argument or the method returning the latest version number (as it is now putting into the logs)? I don't think the versions are that relevant for the collectors. The one I know that has module checks, only checks if the classes are available: example. For my own use-case I wouldn't mind the version as well. Do you have other examples?
@odain-cbd I still feel it fits well in |
For instance, if you collect data about racks or servers, the "width" field was not added ar first in the Regarding the signature, I'd say something like the following, but totally open to other suggestions: public static function CheckModuleInstallation(string $sName, ?string $sMinVersion = null, bool $bRequired = false, RestClient $oClient = null): bool If |
I was more asking for current existing collectors that actually check for a version or have a need for it. Your example is also a valid one. I'm more in favour of this method returning the installed version, so the version can be checked elsewhere. |
Discussed in DM with Hipska, prototype will remain the same, but |
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
I wasn't sure to which class it could be added. Might as well be a static method on
Utils
or even somewhere else.