diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2011-07-07 00:03:51 -0700 |
|---|---|---|
| committer | Luke Kanies <luke@puppetlabs.com> | 2011-07-15 11:16:09 -0700 |
| commit | 7e5ca648112a2703ba827f96f36fe2a5f7d1c751 (patch) | |
| tree | 55c21248f39f17a72f0042f6f71689d9ba8a6c40 /lib | |
| parent | f4acb025f3a125d4c3c359fb6896ac20b36e06ab (diff) | |
| download | puppet-7e5ca648112a2703ba827f96f36fe2a5f7d1c751.tar.gz puppet-7e5ca648112a2703ba827f96f36fe2a5f7d1c751.tar.xz puppet-7e5ca648112a2703ba827f96f36fe2a5f7d1c751.zip | |
Making Fact json handling more resilient
We were failing if any values were nil, and values
were often nil, at least in testing.
We now only include non-nil values, and we handle nil
values just fine.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/puppet/node/facts.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb index 577b62b62..8d0a03474 100755 --- a/lib/puppet/node/facts.rb +++ b/lib/puppet/node/facts.rb @@ -61,18 +61,21 @@ class Puppet::Node::Facts def self.from_pson(data) result = new(data['name'], data['values']) - result.timestamp = Time.parse(data['timestamp']) - result.expiration = Time.parse(data['expiration']) + result.timestamp = Time.parse(data['timestamp']) if data['timestamp'] + result.expiration = Time.parse(data['expiration']) if data['expiration'] result end def to_pson(*args) - { - 'expiration' => expiration, + result = { 'name' => name, - 'timestamp' => timestamp, 'values' => strip_internal, - }.to_pson(*args) + } + + result['timestamp'] = timestamp if timestamp + result['expiration'] = expiration if expiration + + result.to_pson(*args) end # Add internal data to the facts for storage. |
