facterdb 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +10 -34
  3. data/CHANGELOG.md +28 -0
  4. data/bin/legacy-facts-striper +127 -0
  5. data/database/list_arch_os_facter.md +6 -16
  6. data/database/list_facter_os_arch.md +211 -227
  7. data/database/list_os_arch_facter.md +45 -56
  8. data/database/list_os_facter_arch.md +210 -229
  9. data/database/table.md +0 -3
  10. data/facts/4.0/almalinux-8-x86_64.facts +0 -63
  11. data/facts/4.0/almalinux-9-x86_64.facts +0 -59
  12. data/facts/4.0/debian-11-x86_64.facts +0 -58
  13. data/facts/4.0/freebsd-11-x86_64.facts +0 -42
  14. data/facts/4.0/freebsd-12-x86_64.facts +0 -42
  15. data/facts/4.0/freebsd-13-x86_64.facts +0 -42
  16. data/facts/4.0/opensuse-15-x86_64.facts +0 -54
  17. data/facts/4.0/oraclelinux-7-x86_64.facts +23 -16
  18. data/facts/4.0/redhat-8-x86_64.facts +0 -64
  19. data/facts/4.0/rocky-8-x86_64.facts +0 -60
  20. data/facts/4.0/rocky-9-x86_64.facts +0 -64
  21. data/facts/4.0/scientific-7-x86_64.facts +23 -16
  22. data/facts/4.0/solaris-11-sun4v.facts +0 -6
  23. data/facts/4.0/ubuntu-18.04-x86_64.facts +0 -60
  24. data/facts/4.0/ubuntu-20.04-x86_64.facts +0 -60
  25. data/facts/4.0/ubuntu-21.04-x86_64.facts +0 -60
  26. data/facts/4.0/ubuntu-21.10-x86_64.facts +0 -60
  27. data/facts/4.1/almalinux-8-x86_64.facts +0 -63
  28. data/facts/4.1/almalinux-9-x86_64.facts +0 -59
  29. data/facts/4.1/debian-11-x86_64.facts +0 -58
  30. data/facts/4.1/freebsd-11-x86_64.facts +0 -42
  31. data/facts/4.1/freebsd-12-x86_64.facts +0 -42
  32. data/facts/4.1/freebsd-13-x86_64.facts +0 -42
  33. data/facts/4.1/opensuse-15-x86_64.facts +0 -54
  34. data/facts/4.1/redhat-8-x86_64.facts +0 -64
  35. data/facts/4.1/rocky-8-x86_64.facts +0 -60
  36. data/facts/4.1/rocky-9-x86_64.facts +0 -64
  37. data/facts/4.1/ubuntu-18.04-x86_64.facts +0 -60
  38. data/facts/4.1/ubuntu-20.04-x86_64.facts +0 -60
  39. data/facts/4.1/ubuntu-21.04-x86_64.facts +0 -60
  40. data/facts/4.1/ubuntu-21.10-x86_64.facts +0 -60
  41. data/facts/4.2/almalinux-8-x86_64.facts +0 -59
  42. data/facts/4.2/almalinux-9-x86_64.facts +0 -59
  43. data/facts/4.2/amazon-2022-x86_64.facts +0 -7
  44. data/facts/4.2/archlinux-x86_64.facts +13 -56
  45. data/facts/4.2/centos-9-x86_64.facts +0 -62
  46. data/facts/4.2/darwin-20-x86_64.facts +1 -63
  47. data/facts/4.2/debian-11-x86_64.facts +0 -58
  48. data/facts/4.2/debian-12-i386.facts +0 -58
  49. data/facts/4.2/debian-12-x86_64.facts +0 -58
  50. data/facts/4.2/fedora-36-x86_64.facts +0 -63
  51. data/facts/4.2/fedora-37-x86_64.facts +0 -63
  52. data/facts/4.2/fedora-38-x86_64.facts +0 -62
  53. data/facts/4.2/fedora-39-x86_64.facts +0 -62
  54. data/facts/4.2/freebsd-11-x86_64.facts +0 -42
  55. data/facts/4.2/freebsd-12-x86_64.facts +0 -42
  56. data/facts/4.2/freebsd-13-x86_64.facts +0 -42
  57. data/facts/4.2/gentoo-2-x86_64.facts +0 -65
  58. data/facts/4.2/opensuse-15-x86_64.facts +0 -54
  59. data/facts/4.2/oraclelinux-7-x86_64.facts +0 -63
  60. data/facts/4.2/oraclelinux-8-x86_64.facts +0 -63
  61. data/facts/4.2/oraclelinux-9-x86_64.facts +0 -12
  62. data/facts/4.2/popos-21.10-x86_64.facts +0 -36
  63. data/facts/4.2/redhat-8-x86_64.facts +0 -64
  64. data/facts/4.2/redhat-9-x86_64.facts +0 -64
  65. data/facts/4.2/rocky-8-x86_64.facts +0 -60
  66. data/facts/4.2/rocky-9-x86_64.facts +0 -64
  67. data/facts/4.2/scientific-7-x86_64.facts +0 -63
  68. data/facts/4.2/sles-12-x86_64.facts +0 -54
  69. data/facts/4.2/sles-15-x86_64.facts +0 -58
  70. data/facts/4.2/ubuntu-18.04-x86_64.facts +0 -60
  71. data/facts/4.2/ubuntu-20.04-x86_64.facts +0 -60
  72. data/facts/4.2/ubuntu-21.04-x86_64.facts +0 -60
  73. data/facts/4.2/ubuntu-21.10-x86_64.facts +0 -60
  74. data/facts/4.2/ubuntu-22.04-x86_64.facts +0 -60
  75. data/facts/4.2/ubuntu-22.10-x86_64.facts +0 -60
  76. data/facts/4.2/windows-10-x86_64.facts +1 -44
  77. data/facts/4.2/windows-11-x86_64.facts +1 -44
  78. data/facts/4.2/windows-2012 r2-x86_64.facts +1 -42
  79. data/facts/4.2/windows-2012-x86_64.facts +7 -42
  80. data/facts/4.2/windows-2016-core-x86_64.facts +7 -43
  81. data/facts/4.2/windows-2016-x86_64.facts +7 -43
  82. data/facts/4.2/windows-2019-core-x86_64.facts +1 -43
  83. data/facts/4.2/windows-2019-x86_64.facts +1 -43
  84. data/facts/4.2/windows-2022-core-x86_64.facts +1 -44
  85. data/facts/4.2/windows-2022-x86_64.facts +1 -44
  86. data/facts/4.3/almalinux-8-x86_64.facts +0 -59
  87. data/facts/4.3/almalinux-9-x86_64.facts +0 -59
  88. data/facts/4.3/archlinux-x86_64.facts +13 -56
  89. data/facts/4.3/centos-9-x86_64.facts +0 -62
  90. data/facts/4.3/debian-11-x86_64.facts +0 -58
  91. data/facts/4.3/debian-12-i386.facts +0 -58
  92. data/facts/4.3/debian-12-x86_64.facts +0 -58
  93. data/facts/4.3/fedora-36-x86_64.facts +0 -63
  94. data/facts/4.3/fedora-37-x86_64.facts +0 -63
  95. data/facts/4.3/fedora-38-x86_64.facts +0 -62
  96. data/facts/4.3/fedora-39-x86_64.facts +0 -62
  97. data/facts/4.3/freebsd-13-x86_64.facts +0 -43
  98. data/facts/4.3/gentoo-2-x86_64.facts +0 -65
  99. data/facts/4.3/opensuse-15-x86_64.facts +0 -54
  100. data/facts/4.3/oraclelinux-8-x86_64.facts +0 -68
  101. data/facts/4.3/oraclelinux-9-x86_64.facts +0 -60
  102. data/facts/4.3/redhat-8-x86_64.facts +0 -64
  103. data/facts/4.3/redhat-9-x86_64.facts +0 -64
  104. data/facts/4.3/rocky-8-x86_64.facts +0 -64
  105. data/facts/4.3/rocky-9-x86_64.facts +0 -64
  106. data/facts/4.3/sles-12-x86_64.facts +0 -61
  107. data/facts/4.3/ubuntu-18.04-x86_64.facts +0 -60
  108. data/facts/4.3/ubuntu-20.04-x86_64.facts +0 -60
  109. data/facts/4.3/ubuntu-22.04-x86_64.facts +0 -60
  110. data/facts/4.3/windows-10-x86_64.facts +1 -44
  111. data/facts/4.3/windows-11-x86_64.facts +1 -44
  112. data/facts/4.3/windows-2012 r2-x86_64.facts +2 -43
  113. data/facts/4.3/windows-2012-x86_64.facts +1 -42
  114. data/facts/4.3/windows-2016-core-x86_64.facts +1 -43
  115. data/facts/4.3/windows-2016-x86_64.facts +1 -43
  116. data/facts/4.3/windows-2019-core-x86_64.facts +1 -43
  117. data/facts/4.3/windows-2019-x86_64.facts +1 -43
  118. data/facts/4.3/windows-2022-core-x86_64.facts +1 -44
  119. data/facts/4.3/windows-2022-x86_64.facts +1 -44
  120. data/facts/4.4/almalinux-8-x86_64.facts +0 -59
  121. data/facts/4.4/almalinux-9-x86_64.facts +0 -59
  122. data/facts/4.4/archlinux-x86_64.facts +13 -56
  123. data/facts/4.4/centos-9-x86_64.facts +0 -62
  124. data/facts/4.4/debian-11-x86_64.facts +0 -58
  125. data/facts/4.4/debian-12-i386.facts +0 -58
  126. data/facts/4.4/debian-12-x86_64.facts +0 -58
  127. data/facts/4.4/fedora-36-x86_64.facts +0 -63
  128. data/facts/4.4/fedora-37-x86_64.facts +0 -63
  129. data/facts/4.4/fedora-38-x86_64.facts +0 -62
  130. data/facts/4.4/fedora-39-x86_64.facts +0 -62
  131. data/facts/4.4/freebsd-13-x86_64.facts +0 -41
  132. data/facts/4.4/gentoo-2-x86_64.facts +0 -65
  133. data/facts/4.4/opensuse-15-x86_64.facts +0 -54
  134. data/facts/4.4/oraclelinux-8-x86_64.facts +0 -68
  135. data/facts/4.4/oraclelinux-9-x86_64.facts +0 -60
  136. data/facts/4.4/redhat-8-x86_64.facts +0 -64
  137. data/facts/4.4/redhat-9-x86_64.facts +0 -64
  138. data/facts/4.4/rocky-8-x86_64.facts +0 -64
  139. data/facts/4.4/rocky-9-x86_64.facts +0 -64
  140. data/facts/4.4/sles-12-x86_64.facts +0 -61
  141. data/facts/4.4/ubuntu-18.04-x86_64.facts +0 -60
  142. data/facts/4.4/ubuntu-20.04-x86_64.facts +0 -60
  143. data/facts/4.4/ubuntu-22.04-x86_64.facts +0 -60
  144. data/facts/4.4/windows-10-x86_64.facts +1 -44
  145. data/facts/4.4/windows-11-x86_64.facts +1 -44
  146. data/facts/4.4/windows-2012 r2-x86_64.facts +1 -42
  147. data/facts/4.4/windows-2012-x86_64.facts +1 -42
  148. data/facts/4.4/windows-2016-core-x86_64.facts +1 -43
  149. data/facts/4.4/windows-2016-x86_64.facts +2 -44
  150. data/facts/4.4/windows-2019-core-x86_64.facts +1 -43
  151. data/facts/4.4/windows-2019-x86_64.facts +1 -43
  152. data/facts/4.4/windows-2022-core-x86_64.facts +1 -44
  153. data/facts/4.4/windows-2022-x86_64.facts +1 -44
  154. data/facts/4.5/almalinux-8-x86_64.facts +0 -59
  155. data/facts/4.5/almalinux-9-x86_64.facts +0 -59
  156. data/facts/4.5/amazon-2-x86_64.facts +0 -54
  157. data/facts/4.5/archlinux-x86_64.facts +13 -56
  158. data/facts/4.5/centos-9-x86_64.facts +0 -62
  159. data/facts/4.5/debian-11-x86_64.facts +0 -58
  160. data/facts/4.5/debian-12-x86_64.facts +0 -58
  161. data/facts/4.5/fedora-36-x86_64.facts +0 -63
  162. data/facts/4.5/fedora-37-x86_64.facts +0 -63
  163. data/facts/4.5/fedora-38-x86_64.facts +0 -62
  164. data/facts/4.5/fedora-39-x86_64.facts +0 -62
  165. data/facts/4.5/freebsd-12-x86_64.facts +0 -43
  166. data/facts/4.5/freebsd-13-x86_64.facts +0 -43
  167. data/facts/4.5/gentoo-2-x86_64.facts +0 -65
  168. data/facts/4.5/opensuse-15-x86_64.facts +0 -54
  169. data/facts/4.5/oraclelinux-8-x86_64.facts +0 -68
  170. data/facts/4.5/oraclelinux-9-x86_64.facts +0 -60
  171. data/facts/4.5/redhat-8-x86_64.facts +0 -64
  172. data/facts/4.5/redhat-9-x86_64.facts +0 -64
  173. data/facts/4.5/rocky-8-x86_64.facts +0 -64
  174. data/facts/4.5/rocky-9-x86_64.facts +0 -64
  175. data/facts/4.5/ubuntu-18.04-x86_64.facts +0 -60
  176. data/facts/4.5/ubuntu-20.04-x86_64.facts +0 -60
  177. data/facts/4.5/ubuntu-22.04-x86_64.facts +0 -60
  178. data/facts/4.5/windows-10-x86_64.facts +1 -44
  179. data/facts/4.5/windows-11-x86_64.facts +1 -44
  180. data/facts/4.5/windows-2019-x86_64.facts +1 -43
  181. data/facts/4.5/windows-2022-x86_64.facts +1 -44
  182. data/facts/4.6/almalinux-8-x86_64.facts +0 -59
  183. data/facts/4.6/almalinux-9-x86_64.facts +0 -59
  184. data/facts/4.6/archlinux-x86_64.facts +13 -56
  185. data/facts/4.6/centos-9-x86_64.facts +0 -62
  186. data/facts/4.6/debian-11-x86_64.facts +0 -58
  187. data/facts/4.6/debian-12-x86_64.facts +0 -58
  188. data/facts/4.6/fedora-36-x86_64.facts +0 -63
  189. data/facts/4.6/fedora-37-x86_64.facts +0 -63
  190. data/facts/4.6/fedora-38-x86_64.facts +0 -62
  191. data/facts/4.6/fedora-39-x86_64.facts +0 -62
  192. data/facts/4.6/gentoo-2-x86_64.facts +0 -65
  193. data/facts/4.6/oraclelinux-8-x86_64.facts +0 -68
  194. data/facts/4.6/oraclelinux-9-x86_64.facts +0 -60
  195. data/facts/4.6/redhat-8-x86_64.facts +0 -64
  196. data/facts/4.6/redhat-9-x86_64.facts +0 -64
  197. data/facts/4.6/rocky-9-x86_64.facts +0 -64
  198. data/facts/4.6/ubuntu-20.04-x86_64.facts +0 -60
  199. data/facts/4.6/ubuntu-22.04-x86_64.facts +0 -60
  200. data/facts/4.6/windows-10-x86_64.facts +1 -44
  201. data/facts/4.6/windows-11-x86_64.facts +1 -44
  202. data/facts/4.6/windows-2019-x86_64.facts +1 -43
  203. data/facts/4.6/windows-2022-x86_64.facts +1 -44
  204. data/facts/4.7/almalinux-8-x86_64.facts +0 -59
  205. data/facts/4.7/almalinux-9-x86_64.facts +0 -59
  206. data/facts/4.7/archlinux-x86_64.facts +13 -56
  207. data/facts/4.7/centos-9-x86_64.facts +0 -62
  208. data/facts/4.7/debian-11-x86_64.facts +0 -58
  209. data/facts/4.7/debian-12-x86_64.facts +0 -58
  210. data/facts/4.7/fedora-36-x86_64.facts +0 -63
  211. data/facts/4.7/fedora-37-x86_64.facts +0 -63
  212. data/facts/4.7/fedora-38-x86_64.facts +0 -62
  213. data/facts/4.7/fedora-39-x86_64.facts +0 -62
  214. data/facts/4.7/gentoo-2-x86_64.facts +0 -65
  215. data/facts/4.7/openbsd-7-x86_64.facts +0 -31
  216. data/facts/4.7/opensuse-15-x86_64.facts +0 -54
  217. data/facts/4.7/oraclelinux-8-x86_64.facts +0 -68
  218. data/facts/4.7/oraclelinux-9-x86_64.facts +0 -60
  219. data/facts/4.7/redhat-8-x86_64.facts +0 -64
  220. data/facts/4.7/redhat-9-x86_64.facts +0 -64
  221. data/facts/4.7/rocky-9-x86_64.facts +0 -64
  222. data/facts/4.7/ubuntu-20.04-x86_64.facts +0 -60
  223. data/facts/4.7/ubuntu-22.04-x86_64.facts +0 -60
  224. data/facts/4.7/windows-10-x86_64.facts +1 -44
  225. data/facts/4.7/windows-11-x86_64.facts +1 -44
  226. data/facts/4.7/windows-2019-x86_64.facts +1 -43
  227. data/facts/4.7/windows-2022-x86_64.facts +1 -44
  228. data/facts/Vagrantfile +0 -32
  229. data/facts/get_facts.sh +10 -10
  230. data/facts/windows_get_facts.ps1 +1 -1
  231. data/lib/facterdb/bin.rb +1 -1
  232. data/lib/facterdb/version.rb +1 -1
  233. data/lib/facterdb.rb +6 -33
  234. data/spec/facter_db_spec.rb +27 -91
  235. data/spec/facts_spec.rb +24 -2
  236. metadata +4 -18
  237. data/facts/4.0/centos-7-x86_64.facts +0 -694
  238. data/facts/4.0/centos-8-x86_64.facts +0 -512
  239. data/facts/4.0/redhat-7-x86_64.facts +0 -694
  240. data/facts/4.1/centos-7-x86_64.facts +0 -582
  241. data/facts/4.1/centos-8-x86_64.facts +0 -514
  242. data/facts/4.2/centos-7-x86_64.facts +0 -593
  243. data/facts/4.2/centos-8-x86_64.facts +0 -521
  244. data/facts/4.2/redhat-7-x86_64.facts +0 -536
  245. data/facts/4.3/centos-7-x86_64.facts +0 -592
  246. data/facts/4.3/centos-8-x86_64.facts +0 -521
  247. data/facts/4.4/centos-7-x86_64.facts +0 -592
  248. data/facts/4.4/centos-8-x86_64.facts +0 -521
  249. data/facts/4.5/centos-7-x86_64.facts +0 -602
  250. data/facts/4.5/centos-8-x86_64.facts +0 -527
  251. data/facts/4.6/centos-8-x86_64.facts +0 -529
  252. data/facts/4.7/centos-8-x86_64.facts +0 -529
data/lib/facterdb.rb CHANGED
@@ -78,37 +78,6 @@ module FacterDB
78
78
  (external_fact_files + default_fact_files).uniq
79
79
  end
80
80
 
81
- # @deprecated Use {.get_facts} instead.
82
- def self.get_os_facts(facter_version = '*', filter = [])
83
- if facter_version == '*'
84
- if filter.is_a?(Array)
85
- filter_str = filter.map { |f| f.map { |k, v| "#{k}=#{v}" }.join(' and ') }.join(' or ')
86
- elsif filter.is_a?(Hash)
87
- filter_str = filter.map { |k, v| "#{k}=#{v}" }.join(' and ')
88
- elsif filter.is_a?(String)
89
- filter_str = filter
90
- else
91
- raise 'filter must be either an Array a Hash or a String'
92
- end
93
- elsif filter.is_a?(Array)
94
- filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map do |f|
95
- f.map do |k, v|
96
- "#{k}=#{v}"
97
- end.join(' and ')
98
- end.join(' or ')})"
99
- elsif filter.is_a?(Hash)
100
- filter_str = "facterversion=/^#{facter_version}/ and (#{filter.map { |k, v| "#{k}=#{v}" }.join(' and ')})"
101
- elsif filter.is_a?(String)
102
- filter_str = "facterversion=/^#{facter_version}/ and (#{filter})"
103
- else
104
- raise 'filter must be either an Array a Hash or a String'
105
- end
106
-
107
- warn "[DEPRECATION] `get_os_facts` is deprecated. Please use `get_facts(#{filter_str})` instead."
108
-
109
- get_facts(filter_str)
110
- end
111
-
112
81
  # @return [String] the string filter
113
82
  # @param filter [Object] The filter to convert to jgrep string
114
83
  def self.generate_filter_str(filter = nil)
@@ -137,13 +106,17 @@ module FacterDB
137
106
 
138
107
  # @return [Array[Hash[Symbol, Any]]] array of hashes of facts
139
108
  # @param filter [Object] The filter to convert to jgrep string
140
- def self.get_facts(filter = nil, cache = true)
109
+ # @param symbolize_keys [Boolean]
110
+ # Whether to symbolize the keys. Note this is only on the top level and not
111
+ # on nested values.
112
+ def self.get_facts(filter = nil, cache = true, symbolize_keys: true)
141
113
  if cache && filter && filter == Thread.current[:facterdb_last_filter_seen]
142
114
  return Thread.current[:facterdb_last_facts_seen]
143
115
  end
144
116
 
145
117
  filter_str = generate_filter_str(filter)
146
- result = JGrep.jgrep(database, filter_str).map { |hash| hash.map { |k, v| [k.to_sym, v] }.to_h }
118
+ result = JGrep.jgrep(database, filter_str)
119
+ result = result.map { |hash| hash.transform_keys(&:to_sym) } if symbolize_keys
147
120
  if cache
148
121
  Thread.current[:facterdb_last_filter_seen] = filter
149
122
  Thread.current[:facterdb_last_facts_seen] = result
@@ -197,91 +197,6 @@ describe FacterDB do
197
197
  end
198
198
  end
199
199
 
200
- describe '.get_os_facts' do
201
- subject(:result) { FacterDB.get_os_facts(facter_version, filter) }
202
-
203
- before do
204
- object = defined?(Warning) ? Warning : Kernel
205
- allow(object).to receive(:warn).and_call_original
206
- allow(object).to receive(:warn).with(a_string_matching(/`get_os_facts` is deprecated/))
207
- end
208
-
209
- context 'without parameters' do
210
- subject(:result) { FacterDB.get_os_facts }
211
-
212
- include_examples 'returns a result'
213
- end
214
-
215
- context 'when matching all Facter versions' do
216
- let(:facter_version) { '*' }
217
-
218
- context 'with an Array filter' do
219
- let(:filter) { [{ osfamily: 'Debian' }] }
220
-
221
- include_examples 'returns a result'
222
- end
223
-
224
- context 'with a Hash filter' do
225
- let(:filter) { { osfamily: 'Debian' } }
226
-
227
- include_examples 'returns a result'
228
- end
229
-
230
- context 'with a String filter' do
231
- let(:filter) { 'osfamily=Debian' }
232
-
233
- include_examples 'returns a result'
234
- end
235
-
236
- context 'with a filter of an unsupported type' do
237
- let(:filter) { true }
238
-
239
- it 'raises an error' do
240
- expect { result }.to raise_error(/filter must be either/)
241
- end
242
- end
243
- end
244
-
245
- context 'when matching a specific facter version' do
246
- let(:facter_version) { '4.0.52' }
247
-
248
- shared_examples 'returns only the specified version' do
249
- it 'only includes fact sets for the specified version' do
250
- expect(result).to all(include(facterversion: match(/^4\.0/)))
251
- end
252
- end
253
-
254
- context 'with an Array filter' do
255
- let(:filter) { [{ osfamily: 'Debian' }] }
256
-
257
- include_examples 'returns a result'
258
- include_examples 'returns only the specified version'
259
- end
260
-
261
- context 'with a Hash filter' do
262
- let(:filter) { { osfamily: 'Debian' } }
263
-
264
- include_examples 'returns a result'
265
- include_examples 'returns only the specified version'
266
- end
267
-
268
- context 'with a String filter' do
269
- let(:filter) { 'osfamily=Debian' }
270
-
271
- include_examples 'returns a result'
272
- include_examples 'returns only the specified version'
273
- end
274
-
275
- context 'with a filter of an unsupported type' do
276
- let(:filter) { true }
277
-
278
- it 'raises an error' do
279
- expect { result }.to raise_error(/filter must be either/)
280
- end
281
- end
282
- end
283
- end
284
-
285
200
  describe '.valid_filters?' do
286
201
  it 'invalid and false' do
287
202
  expect(FacterDB.valid_filters?('and')).to be_falsey
@@ -302,11 +217,11 @@ describe FacterDB do
302
217
  end
303
218
 
304
219
  it 'with hash' do
305
- expect(FacterDB.generate_filter_str({ osfamily: 'Debian' })).to eq('osfamily=Debian')
220
+ expect(FacterDB.generate_filter_str({ kernel: 'Linux' })).to eq('kernel=Linux')
306
221
  end
307
222
 
308
223
  it 'with Array' do
309
- expect(FacterDB.generate_filter_str([osfamily: 'Debian'])).to eq('(osfamily=Debian)')
224
+ expect(FacterDB.generate_filter_str([kernel: 'Linux'])).to eq('(kernel=Linux)')
310
225
  end
311
226
 
312
227
  it 'empty' do
@@ -319,28 +234,49 @@ describe FacterDB do
319
234
  end
320
235
 
321
236
  describe '.get_facts' do
322
- subject(:result) { FacterDB.get_facts(filter) }
237
+ subject(:result) { FacterDB.get_facts(filter, symbolize_keys: symbolize_keys) }
323
238
 
324
239
  let(:filter) { nil }
240
+ let(:symbolize_keys) { nil }
325
241
 
326
242
  context 'without parameters' do
327
243
  include_examples 'returns a result'
328
244
  end
329
245
 
246
+ context 'with stringified output' do
247
+ let(:symbolize_keys) { false }
248
+
249
+ it 'returns strings as keys in factsets' do
250
+ result.each do |factset|
251
+ expect(factset.keys).to all(be_an_instance_of(String))
252
+ end
253
+ end
254
+ end
255
+
256
+ context 'with symbolized output' do
257
+ let(:symbolize_keys) { true }
258
+
259
+ it 'returns strings as keys in factsets' do
260
+ result.each do |factset|
261
+ expect(factset.keys).to all(be_an_instance_of(Symbol))
262
+ end
263
+ end
264
+ end
265
+
330
266
  context 'with an Array filter' do
331
- let(:filter) { [osfamily: 'Debian'] }
267
+ let(:filter) { [kernel: 'Linux'] }
332
268
 
333
269
  include_examples 'returns a result'
334
270
  end
335
271
 
336
272
  context 'with a Hash filter' do
337
- let(:filter) { { osfamily: 'Debian' } }
273
+ let(:filter) { { kernel: 'Linux' } }
338
274
 
339
275
  include_examples 'returns a result'
340
276
  end
341
277
 
342
278
  context 'with a String filter' do
343
- let(:filter) { 'osfamily=Debian' }
279
+ let(:filter) { 'kernel=Linux' }
344
280
 
345
281
  include_examples 'returns a result'
346
282
  end
data/spec/facts_spec.rb CHANGED
@@ -98,8 +98,8 @@ describe 'Default Facts' do
98
98
  end
99
99
  end
100
100
 
101
- it 'contains the legacy ipaddress fact' do
102
- expect(content['ipaddress']).to not_be_nil.and not_be_empty
101
+ it 'does not contains the legacy ipaddress fact' do
102
+ expect(content['ipaddress']).to be_nil
103
103
  end
104
104
 
105
105
  it 'contains no facts from puppetlabs/stdlib' do
@@ -117,6 +117,28 @@ describe 'Default Facts' do
117
117
  expect(content['systemd_version']).to be_nil
118
118
  expect(content['systemd_internal_services']).to be_nil
119
119
  end
120
+
121
+ # those are used in newer rspec-puppet-facts versions
122
+ # by ensuring those facts exists, we can drop a huge amount of logic in rspec-puppet-facts
123
+ it 'contains the mandatory OS facts' do
124
+ expect(content['os']['release']['major']).to not_be_nil.and not_be_empty
125
+ expect(content['os']['name']).to not_be_nil.and not_be_empty
126
+ expect(content['os']['hardware']).to not_be_nil.and not_be_empty
127
+ end
128
+
129
+ it 'does not contain a legacy hostname, domain and fqdn fact' do
130
+ expect(content['hostname']).to be_nil
131
+ expect(content['fqdn']).to be_nil
132
+ expect(content['domain']).to be_nil
133
+ end
134
+
135
+ it 'does not contain the legacy osfamily fact' do
136
+ expect(content['osfamily']).to be_nil
137
+ end
138
+
139
+ it 'does not contain the legacy operatingsystem fact' do
140
+ expect(content['operatingsystem']).to be_nil
141
+ end
120
142
  end
121
143
  end
122
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facterdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-28 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -111,6 +111,7 @@ email:
111
111
  - voxpupuli@groups.io
112
112
  executables:
113
113
  - facterdb
114
+ - legacy-facts-striper
114
115
  extensions: []
115
116
  extra_rdoc_files: []
116
117
  files:
@@ -130,6 +131,7 @@ files:
130
131
  - README.md
131
132
  - Rakefile
132
133
  - bin/facterdb
134
+ - bin/legacy-facts-striper
133
135
  - database/list_arch_os_facter.md
134
136
  - database/list_facter_os_arch.md
135
137
  - database/list_os_arch_facter.md
@@ -152,15 +154,12 @@ files:
152
154
  - facterdb.gemspec
153
155
  - facts/4.0/almalinux-8-x86_64.facts
154
156
  - facts/4.0/almalinux-9-x86_64.facts
155
- - facts/4.0/centos-7-x86_64.facts
156
- - facts/4.0/centos-8-x86_64.facts
157
157
  - facts/4.0/debian-11-x86_64.facts
158
158
  - facts/4.0/freebsd-11-x86_64.facts
159
159
  - facts/4.0/freebsd-12-x86_64.facts
160
160
  - facts/4.0/freebsd-13-x86_64.facts
161
161
  - facts/4.0/opensuse-15-x86_64.facts
162
162
  - facts/4.0/oraclelinux-7-x86_64.facts
163
- - facts/4.0/redhat-7-x86_64.facts
164
163
  - facts/4.0/redhat-8-x86_64.facts
165
164
  - facts/4.0/rocky-8-x86_64.facts
166
165
  - facts/4.0/rocky-9-x86_64.facts
@@ -172,8 +171,6 @@ files:
172
171
  - facts/4.0/ubuntu-21.10-x86_64.facts
173
172
  - facts/4.1/almalinux-8-x86_64.facts
174
173
  - facts/4.1/almalinux-9-x86_64.facts
175
- - facts/4.1/centos-7-x86_64.facts
176
- - facts/4.1/centos-8-x86_64.facts
177
174
  - facts/4.1/debian-11-x86_64.facts
178
175
  - facts/4.1/freebsd-11-x86_64.facts
179
176
  - facts/4.1/freebsd-12-x86_64.facts
@@ -190,8 +187,6 @@ files:
190
187
  - facts/4.2/almalinux-9-x86_64.facts
191
188
  - facts/4.2/amazon-2022-x86_64.facts
192
189
  - facts/4.2/archlinux-x86_64.facts
193
- - facts/4.2/centos-7-x86_64.facts
194
- - facts/4.2/centos-8-x86_64.facts
195
190
  - facts/4.2/centos-9-x86_64.facts
196
191
  - facts/4.2/darwin-20-x86_64.facts
197
192
  - facts/4.2/debian-11-x86_64.facts
@@ -210,7 +205,6 @@ files:
210
205
  - facts/4.2/oraclelinux-8-x86_64.facts
211
206
  - facts/4.2/oraclelinux-9-x86_64.facts
212
207
  - facts/4.2/popos-21.10-x86_64.facts
213
- - facts/4.2/redhat-7-x86_64.facts
214
208
  - facts/4.2/redhat-8-x86_64.facts
215
209
  - facts/4.2/redhat-9-x86_64.facts
216
210
  - facts/4.2/rocky-8-x86_64.facts
@@ -237,8 +231,6 @@ files:
237
231
  - facts/4.3/almalinux-8-x86_64.facts
238
232
  - facts/4.3/almalinux-9-x86_64.facts
239
233
  - facts/4.3/archlinux-x86_64.facts
240
- - facts/4.3/centos-7-x86_64.facts
241
- - facts/4.3/centos-8-x86_64.facts
242
234
  - facts/4.3/centos-9-x86_64.facts
243
235
  - facts/4.3/debian-11-x86_64.facts
244
236
  - facts/4.3/debian-12-i386.facts
@@ -273,8 +265,6 @@ files:
273
265
  - facts/4.4/almalinux-8-x86_64.facts
274
266
  - facts/4.4/almalinux-9-x86_64.facts
275
267
  - facts/4.4/archlinux-x86_64.facts
276
- - facts/4.4/centos-7-x86_64.facts
277
- - facts/4.4/centos-8-x86_64.facts
278
268
  - facts/4.4/centos-9-x86_64.facts
279
269
  - facts/4.4/debian-11-x86_64.facts
280
270
  - facts/4.4/debian-12-i386.facts
@@ -310,8 +300,6 @@ files:
310
300
  - facts/4.5/almalinux-9-x86_64.facts
311
301
  - facts/4.5/amazon-2-x86_64.facts
312
302
  - facts/4.5/archlinux-x86_64.facts
313
- - facts/4.5/centos-7-x86_64.facts
314
- - facts/4.5/centos-8-x86_64.facts
315
303
  - facts/4.5/centos-9-x86_64.facts
316
304
  - facts/4.5/debian-11-x86_64.facts
317
305
  - facts/4.5/debian-12-x86_64.facts
@@ -339,7 +327,6 @@ files:
339
327
  - facts/4.6/almalinux-8-x86_64.facts
340
328
  - facts/4.6/almalinux-9-x86_64.facts
341
329
  - facts/4.6/archlinux-x86_64.facts
342
- - facts/4.6/centos-8-x86_64.facts
343
330
  - facts/4.6/centos-9-x86_64.facts
344
331
  - facts/4.6/debian-11-x86_64.facts
345
332
  - facts/4.6/debian-12-x86_64.facts
@@ -362,7 +349,6 @@ files:
362
349
  - facts/4.7/almalinux-8-x86_64.facts
363
350
  - facts/4.7/almalinux-9-x86_64.facts
364
351
  - facts/4.7/archlinux-x86_64.facts
365
- - facts/4.7/centos-8-x86_64.facts
366
352
  - facts/4.7/centos-9-x86_64.facts
367
353
  - facts/4.7/debian-11-x86_64.facts
368
354
  - facts/4.7/debian-12-x86_64.facts