bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Package fails to detect nil version #175

Closed lordnynex closed 7 years ago

lordnynex commented 7 years ago

Hello,

In my previous issue I mentioned hiera is looking for common.yaml by default. If this fails to load for whatever reason, the recipe crashes and burns with a very misleading exception

lib/fpm/cookery/package/version.rb:53:in `split_version': undefined method `split' for nil:NilClass (NoMethodError)

It seems version.rb has an opportunity to test for nil and exit with a meaningful error message. Additionally, maybe there is some sort of global indicator saying 'hiera failed to load' that can be checked. In this situation if there is no hiera files loaded and version is nil, it's pretty safe to assume the user misconfigured something and maybe throw an error with some explanation of why this is occurring.

bernd commented 7 years ago

Fixed via #176

tomeon commented 7 years ago

@lordnynex -- rather than raise an error if the version is miconfigured, the mentioned PR tracks fpm's behavior and sets the version to 1.0 if it is not provided explicitly.

lordnynex commented 7 years ago

@bernd @BaxterStockman Just some feedback on this PR

The assumption of 1.0 carries mild risk for people using fpm-cookery as a part of a CI/CD flow if version is broken after the package is well established. Example, critical-package-1.5-1.deb is in production, and I mangle hiera config; apt install will always believe it's at the latest package version. I suppose the same can be said for backages using semver < 1.0, only in reverse.

This is not a huge deal as I can work around it with version checks in testing, but it may be worth calling out in the documentation.