fix: remove `apt::` prefix from fact variables
authorJohan Fleury <jfleury@arcaik.net>
Mon, 2 Jan 2023 14:12:25 +0000 (09:12 -0500)
committerJohan Fleury <jfleury@arcaik.net>
Mon, 2 Jan 2023 14:12:25 +0000 (09:12 -0500)
Fact variables are top-scopped and should not be prefixed by module name.

This bug was introduced by cb6e58cedbd6d7a9bfc63c97c83d51eb39e9c7dc.

manifests/update.pp
spec/classes/apt_update_spec.rb

index ef37f52db04f1bfa19da690bb054b51c6cbda897..a9f2486b16bf87e9ad3f1f9143936a8ab45cdee3 100644 (file)
@@ -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.
@@ -18,8 +18,8 @@ class apt::update {
       #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
@@ -33,8 +33,8 @@ class apt::update {
       #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
index b3d1df545bf942b0eb3f8c57f466ac0f3db43cf4..71774550f8b2796a559ad91c3dfd866951f57ccb 100644 (file)
@@ -24,7 +24,7 @@ describe 'apt::update', type: :class do
                 id: 'Debian',
               },
             },
-            'apt::apt_update_last_success': factval,
+            'apt_update_last_success': factval,
           }
         end
         let(:pre_condition) do
@@ -76,7 +76,7 @@ describe 'apt::update', type: :class do
               id: 'Debian',
             },
           },
-          'apt::apt_update_last_success': Time.now.to_i,
+          'apt_update_last_success': Time.now.to_i,
         }
       end
       let(:pre_condition) do
@@ -113,7 +113,7 @@ describe 'apt::update', type: :class do
                 id: 'Debian',
               },
             },
-            'apt::apt_update_last_success': factval,
+            'apt_update_last_success': factval,
           }
         end
         let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" }
@@ -167,7 +167,7 @@ describe 'apt::update', type: :class do
                   id: 'Debian',
                 },
               },
-              'apt::apt_update_last_success': factval,
+              'apt_update_last_success': factval,
             }
           end
           let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }
@@ -193,7 +193,7 @@ describe 'apt::update', type: :class do
                 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}',} }" }
@@ -218,7 +218,7 @@ describe 'apt::update', type: :class do
                 id: 'Debian',
               },
             },
-            'apt::apt_update_last_success': nil,
+            'apt_update_last_success': nil,
           }
         end
         let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" }