| If a custom fact returns a Time value, then facter will report:
$ mkdir facts |
$ cat > facts/time.rb <<END |
Facter.add(:now) do |
setcode { Time.now } |
end |
END |
$ bx facter --custom-dir /Users/josh/work/facter/facts --trace |
[2021-01-29 11:59:02.519014 ] ERROR Facter - Fact resolution fact='now', resolution='<anonymous>' resolved to an invalid value: Expected 2021-01-29 11:59:02 -0800 to be one of [Integer, Float, TrueClass, FalseClass, NilClass, Symbol, String, Array, Hash], but was Time |
backtrace: |
/Users/josh/work/facter/lib/facter/custom_facts/util/normalization.rb:29:in `normalize' |
/Users/josh/work/facter/lib/facter/custom_facts/core/resolvable.rb:71:in `value' |
/Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:209:in `block in find_first_real_value' |
/Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:207:in `each' |
/Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:207:in `find_first_real_value' |
/Users/josh/work/facter/lib/facter/custom_facts/util/fact.rb:133:in `block (2 levels) in value'
|
Note that Date is missing from https://github.com/puppetlabs/facter/blob/0654f8f6858ca0163680b3d8dfc53d90345f0f35/lib/facter/custom_facts/util/normalization.rb#L8, but facter does accept Date: https://github.com/puppetlabs/facter/blob/0654f8f6858ca0163680b3d8dfc53d90345f0f35/lib/facter/custom_facts/util/normalization.rb#L19. So we probably need to add Date to VALID_TYPES... However, if facter serializes a Date, it does so using Date#to_s which will be different for different locales. I would expect facter to always serialize using a well known format like ISO 8601. That said facter 3 did not support date or time types (https://github.com/puppetlabs/facter/blob/3.x/lib/schema/facter.yaml#L5-L14) so I'm inclined to think facter 4 shouldn't either, and Date should be removed from the case statement. |