Skip to content

Commit

Permalink
fix: remove apt:: prefix from fact variables
Browse files Browse the repository at this point in the history
Fact variables are top-scopped and should not be prefixed by module name.

This bug was introduced by cb6e58c.
  • Loading branch information
johanfleury committed Jan 2, 2023
1 parent 527d095 commit c0bbfbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions manifests/update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class apt::update {
assert_private()

#TODO: to catch if $apt_update_last_success has the value of -1 here. If we
#TODO: to catch if apt_update_last_success has the value of -1 here. If we
#opt to do this, a info/warn would likely be all you'd need likely to happen
#on the first run, but if it's not run in awhile something is likely borked
#with apt and we'd want to know about it.
Expand All @@ -18,8 +18,8 @@
#compare current date with the apt_update_last_success fact to determine
#if we should kick apt_update.
$daily_threshold = (Integer(Timestamp().strftime('%s')) - 86400)
if $apt::apt_update_last_success {
if $apt::apt_update_last_success + 0 < $daily_threshold {
if $facts['apt_update_last_success'] {
if $facts['apt_update_last_success'] + 0 < $daily_threshold {
$_kick_apt = true
} else {
$_kick_apt = false
Expand All @@ -33,8 +33,8 @@
#compare current date with the apt_update_last_success fact to determine
#if we should kick apt_update.
$weekly_threshold = (Integer(Timestamp().strftime('%s')) - 604800)
if $apt::apt_update_last_success {
if ( $apt::apt_update_last_success + 0 < $weekly_threshold ) {
if $facts['apt_update_last_success'] {
if ( $facts['apt_update_last_success'] + 0 < $weekly_threshold ) {
$_kick_apt = true
} else {
$_kick_apt = false
Expand Down
12 changes: 6 additions & 6 deletions spec/classes/apt_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': factval,
'apt_update_last_success': factval,
}
end
let(:pre_condition) do
Expand Down Expand Up @@ -76,7 +76,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': Time.now.to_i,
'apt_update_last_success': Time.now.to_i,
}
end
let(:pre_condition) do
Expand Down Expand Up @@ -113,7 +113,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': factval,
'apt_update_last_success': factval,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
Expand Down Expand Up @@ -167,7 +167,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': factval,
'apt_update_last_success': factval,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
Expand All @@ -193,7 +193,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': Time.now.to_i,
'apt_update_last_success': Time.now.to_i,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
Expand All @@ -218,7 +218,7 @@
id: 'Debian',
},
},
'apt::apt_update_last_success': nil,
'apt_update_last_success': nil,
}
end
let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
Expand Down

0 comments on commit c0bbfbd

Please sign in to comment.