vagrant-clone 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/.rakeTasks +7 -0
  3. data/.idea/inspectionProfiles/Project_Default.xml +6 -0
  4. data/.idea/misc.xml +4 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/runConfigurations/clone.xml +21 -0
  7. data/.idea/runConfigurations/libvirt.xml +21 -0
  8. data/.idea/vagrant-clone.iml +114 -0
  9. data/.idea/vcs.xml +6 -0
  10. data/.idea/workspace.xml +948 -0
  11. data/Gemfile +9 -3
  12. data/Gemfile.lock +123 -37
  13. data/Rakefile +2 -1
  14. data/Vagrantfile +9 -0
  15. data/cookbooks/apt/CHANGELOG.md +321 -0
  16. data/cookbooks/apt/CONTRIBUTING.md +2 -0
  17. data/cookbooks/apt/MAINTAINERS.md +15 -0
  18. data/cookbooks/apt/README.md +250 -0
  19. data/cookbooks/apt/attributes/default.rb +57 -0
  20. data/cookbooks/apt/files/15update-stamp +1 -0
  21. data/cookbooks/apt/files/apt-proxy-v2.conf +50 -0
  22. data/cookbooks/apt/libraries/helpers.rb +49 -0
  23. data/cookbooks/apt/libraries/matchers.rb +16 -0
  24. data/cookbooks/apt/metadata.json +1 -0
  25. data/cookbooks/apt/recipes/cacher-client.rb +52 -0
  26. data/cookbooks/apt/recipes/cacher-ng.rb +39 -0
  27. data/cookbooks/apt/recipes/default.rb +93 -0
  28. data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
  29. data/cookbooks/apt/resources/preference.rb +90 -0
  30. data/cookbooks/apt/templates/01proxy.erb +11 -0
  31. data/cookbooks/apt/templates/10dpkg-options.erb +8 -0
  32. data/cookbooks/apt/templates/10recommends.erb +3 -0
  33. data/cookbooks/apt/templates/20auto-upgrades.erb +5 -0
  34. data/cookbooks/apt/templates/50unattended-upgrades.erb +75 -0
  35. data/cookbooks/apt/templates/acng.conf.erb +275 -0
  36. data/cookbooks/apt/templates/unattended-upgrades.seed.erb +1 -0
  37. data/cookbooks/build-essential/.foodcritic +1 -0
  38. data/cookbooks/build-essential/CHANGELOG.md +257 -0
  39. data/cookbooks/build-essential/CONTRIBUTING.md +2 -0
  40. data/cookbooks/build-essential/MAINTAINERS.md +15 -0
  41. data/cookbooks/build-essential/README.md +134 -0
  42. data/cookbooks/build-essential/attributes/default.rb +21 -0
  43. data/cookbooks/build-essential/libraries/matchers.rb +9 -0
  44. data/cookbooks/build-essential/metadata.json +1 -0
  45. data/cookbooks/build-essential/recipes/_windows.rb +53 -0
  46. data/cookbooks/build-essential/recipes/default.rb +24 -0
  47. data/cookbooks/build-essential/resources/build_essential.rb +106 -0
  48. data/cookbooks/build-essential/resources/xcode_command_line_tools.rb +61 -0
  49. data/cookbooks/compat_resource/CHANGELOG.md +53 -0
  50. data/cookbooks/compat_resource/CONTRIBUTING.md +2 -0
  51. data/cookbooks/compat_resource/MAINTAINERS.md +16 -0
  52. data/cookbooks/compat_resource/README.md +60 -0
  53. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/constants.rb +47 -0
  54. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +40 -0
  55. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb +73 -0
  56. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +315 -0
  57. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb +292 -0
  58. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +37 -0
  59. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb +70 -0
  60. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb +98 -0
  61. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb +74 -0
  62. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +510 -0
  63. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/powershell_out.rb +117 -0
  64. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +328 -0
  65. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/property.rb +713 -0
  66. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_repository.rb +269 -0
  67. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/apt_update.rb +105 -0
  68. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/noop.rb +56 -0
  69. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/support/yum_repo.erb +132 -0
  70. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/systemd_unit.rb +253 -0
  71. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider/yum_repository.rb +136 -0
  72. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb +164 -0
  73. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +114 -0
  74. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_repository.rb +65 -0
  75. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/apt_update.rb +52 -0
  76. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/systemd_unit.rb +81 -0
  77. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource/yum_repository.rb +97 -0
  78. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource.rb +214 -0
  79. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +174 -0
  80. data/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef.rb +29 -0
  81. data/cookbooks/compat_resource/files/lib/chef_compat/mixin/properties.rb +8 -0
  82. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/exceptions.rb +10 -0
  83. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/log.rb +30 -0
  84. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/mixin/params_validate.rb +17 -0
  85. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/node.rb +9 -0
  86. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/property.rb +15 -0
  87. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/provider.rb +65 -0
  88. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe.rb +118 -0
  89. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/recipe_hook.rb +20 -0
  90. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb +60 -0
  91. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource.rb +156 -0
  92. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_builder.rb +167 -0
  93. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_list.rb +49 -0
  94. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection/resource_set.rb +49 -0
  95. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/resource_collection.rb +103 -0
  96. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/run_context.rb +691 -0
  97. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb +153 -0
  98. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef.rb +33 -0
  99. data/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches.rb +41 -0
  100. data/cookbooks/compat_resource/files/lib/chef_compat/property.rb +6 -0
  101. data/cookbooks/compat_resource/files/lib/chef_compat/recipe.rb +8 -0
  102. data/cookbooks/compat_resource/files/lib/chef_compat/resource/lwrp_base.rb +44 -0
  103. data/cookbooks/compat_resource/files/lib/chef_compat/resource.rb +56 -0
  104. data/cookbooks/compat_resource/files/lib/chef_upstream_version.rb +3 -0
  105. data/cookbooks/compat_resource/files/lib/compat_resource.rb +35 -0
  106. data/cookbooks/compat_resource/libraries/autoload.rb +31 -0
  107. data/cookbooks/compat_resource/metadata.json +1 -0
  108. data/cookbooks/inifile_chef_gem/CHANGELOG.md +11 -0
  109. data/cookbooks/inifile_chef_gem/README.md +46 -0
  110. data/cookbooks/inifile_chef_gem/metadata.json +51 -0
  111. data/cookbooks/inifile_chef_gem/metadata.rb +11 -0
  112. data/cookbooks/inifile_chef_gem/resources/default.rb +28 -0
  113. data/cookbooks/mariadb/CHANGELOG.md +332 -0
  114. data/cookbooks/mariadb/README.md +225 -0
  115. data/cookbooks/mariadb/attributes/default.rb +199 -0
  116. data/cookbooks/mariadb/libraries/mariadb_conn_helper.rb +53 -0
  117. data/cookbooks/mariadb/libraries/mariadb_helper.rb +216 -0
  118. data/cookbooks/mariadb/libraries/matchers.rb +21 -0
  119. data/cookbooks/mariadb/metadata.json +1 -0
  120. data/cookbooks/mariadb/providers/configuration.rb +39 -0
  121. data/cookbooks/mariadb/recipes/_audit_plugin.rb +63 -0
  122. data/cookbooks/mariadb/recipes/_debian_galera.rb +62 -0
  123. data/cookbooks/mariadb/recipes/_debian_server.rb +78 -0
  124. data/cookbooks/mariadb/recipes/_mariadb_repository.rb +29 -0
  125. data/cookbooks/mariadb/recipes/_redhat_client.rb +27 -0
  126. data/cookbooks/mariadb/recipes/_redhat_galera.rb +55 -0
  127. data/cookbooks/mariadb/recipes/_redhat_server.rb +58 -0
  128. data/cookbooks/mariadb/recipes/client.rb +47 -0
  129. data/cookbooks/mariadb/recipes/config.rb +115 -0
  130. data/cookbooks/mariadb/recipes/default.rb +46 -0
  131. data/cookbooks/mariadb/recipes/devel.rb +41 -0
  132. data/cookbooks/mariadb/recipes/galera.rb +324 -0
  133. data/cookbooks/mariadb/recipes/plugins.rb +3 -0
  134. data/cookbooks/mariadb/recipes/repository.rb +45 -0
  135. data/cookbooks/mariadb/recipes/server.rb +157 -0
  136. data/cookbooks/mariadb/resources/configuration.rb +13 -0
  137. data/cookbooks/mariadb/resources/mysql2_gem.rb +25 -0
  138. data/cookbooks/mariadb/resources/replication.rb +192 -0
  139. data/cookbooks/mariadb/templates/default/conf.d.generic.erb +19 -0
  140. data/cookbooks/mariadb/templates/default/debian.cnf.erb +12 -0
  141. data/cookbooks/mariadb/templates/default/mariadb-server.seed.erb +13 -0
  142. data/cookbooks/mariadb/templates/default/mariadb_grants.erb +42 -0
  143. data/cookbooks/mariadb/templates/default/my.cnf.erb +210 -0
  144. data/cookbooks/mariadb/templates/default/root.cnf.erb +5 -0
  145. data/cookbooks/mingw/.foodcritic +1 -0
  146. data/cookbooks/mingw/CHANGELOG.md +50 -0
  147. data/cookbooks/mingw/CONTRIBUTING.md +2 -0
  148. data/cookbooks/mingw/MAINTAINERS.md +14 -0
  149. data/cookbooks/mingw/README.md +133 -0
  150. data/cookbooks/mingw/files/default/bash.bat +17 -0
  151. data/cookbooks/mingw/files/default/custom-upgrade.sh +23 -0
  152. data/cookbooks/mingw/files/default/custom_prefix.sh +13 -0
  153. data/cookbooks/mingw/files/default/pthread.h +719 -0
  154. data/cookbooks/mingw/files/default/time.h +297 -0
  155. data/cookbooks/mingw/libraries/_helper.rb +38 -0
  156. data/cookbooks/mingw/metadata.json +1 -0
  157. data/cookbooks/mingw/recipes/default.rb +19 -0
  158. data/cookbooks/mingw/resources/get.rb +56 -0
  159. data/cookbooks/mingw/resources/msys2_package.rb +139 -0
  160. data/cookbooks/mingw/resources/tdm_gcc.rb +114 -0
  161. data/cookbooks/ohai/.foodcritic +2 -0
  162. data/cookbooks/ohai/CHANGELOG.md +166 -0
  163. data/cookbooks/ohai/CONTRIBUTING.md +2 -0
  164. data/cookbooks/ohai/MAINTAINERS.md +15 -0
  165. data/cookbooks/ohai/README.md +134 -0
  166. data/cookbooks/ohai/libraries/matchers.rb +41 -0
  167. data/cookbooks/ohai/metadata.json +1 -0
  168. data/cookbooks/ohai/recipes/default.rb +20 -0
  169. data/cookbooks/ohai/resources/hint.rb +55 -0
  170. data/cookbooks/ohai/resources/plugin.rb +117 -0
  171. data/cookbooks/selinux_policy/.gitignore +51 -0
  172. data/cookbooks/selinux_policy/.kitchen.yml +25 -0
  173. data/cookbooks/selinux_policy/.rubocop.yml +2 -0
  174. data/cookbooks/selinux_policy/.travis.yml +26 -0
  175. data/cookbooks/selinux_policy/Berksfile +8 -0
  176. data/cookbooks/selinux_policy/CHANGELOG.md +155 -0
  177. data/cookbooks/selinux_policy/LICENSE +13 -0
  178. data/cookbooks/selinux_policy/README.md +217 -0
  179. data/cookbooks/selinux_policy/Rakefile +68 -0
  180. data/cookbooks/selinux_policy/TESTING.md +2 -0
  181. data/cookbooks/selinux_policy/Thorfile +12 -0
  182. data/cookbooks/selinux_policy/attributes/default.rb +5 -0
  183. data/cookbooks/selinux_policy/chefignore +102 -0
  184. data/cookbooks/selinux_policy/libraries/helper-disabled.rb +29 -0
  185. data/cookbooks/selinux_policy/libraries/matchers.rb +57 -0
  186. data/cookbooks/selinux_policy/metadata.json +58 -0
  187. data/cookbooks/selinux_policy/metadata.rb +20 -0
  188. data/cookbooks/selinux_policy/providers/boolean.rb +28 -0
  189. data/cookbooks/selinux_policy/providers/fcontext.rb +78 -0
  190. data/cookbooks/selinux_policy/providers/module.rb +81 -0
  191. data/cookbooks/selinux_policy/providers/permissive.rb +26 -0
  192. data/cookbooks/selinux_policy/providers/port.rb +58 -0
  193. data/cookbooks/selinux_policy/recipes/default.rb +9 -0
  194. data/cookbooks/selinux_policy/recipes/install.rb +32 -0
  195. data/cookbooks/selinux_policy/resources/boolean.rb +8 -0
  196. data/cookbooks/selinux_policy/resources/fcontext.rb +8 -0
  197. data/cookbooks/selinux_policy/resources/module.rb +21 -0
  198. data/cookbooks/selinux_policy/resources/permissive.rb +6 -0
  199. data/cookbooks/selinux_policy/resources/port.rb +9 -0
  200. data/cookbooks/seven_zip/CHANGELOG.md +30 -0
  201. data/cookbooks/seven_zip/README.md +108 -0
  202. data/cookbooks/seven_zip/attributes/default.rb +31 -0
  203. data/cookbooks/seven_zip/libraries/matchers.rb +33 -0
  204. data/cookbooks/seven_zip/metadata.json +1 -0
  205. data/cookbooks/seven_zip/providers/archive.rb +68 -0
  206. data/cookbooks/seven_zip/recipes/default.rb +41 -0
  207. data/cookbooks/seven_zip/resources/archive.rb +29 -0
  208. data/cookbooks/windows/.foodcritic +2 -0
  209. data/cookbooks/windows/CHANGELOG.md +528 -0
  210. data/cookbooks/windows/CONTRIBUTING.md +2 -0
  211. data/cookbooks/windows/MAINTAINERS.md +21 -0
  212. data/cookbooks/windows/README.md +803 -0
  213. data/cookbooks/windows/attributes/default.rb +21 -0
  214. data/cookbooks/windows/files/dism_features.rb +45 -0
  215. data/cookbooks/windows/libraries/matchers.rb +586 -0
  216. data/cookbooks/windows/libraries/powershell_helper.rb +53 -0
  217. data/cookbooks/windows/libraries/registry_helper.rb +356 -0
  218. data/cookbooks/windows/libraries/version.rb +207 -0
  219. data/cookbooks/windows/libraries/version_helper.rb +79 -0
  220. data/cookbooks/windows/libraries/windows_helper.rb +174 -0
  221. data/cookbooks/windows/libraries/windows_privileged.rb +103 -0
  222. data/cookbooks/windows/libraries/wmi_helper.rb +32 -0
  223. data/cookbooks/windows/metadata.json +1 -0
  224. data/cookbooks/windows/recipes/default.rb +21 -0
  225. data/cookbooks/windows/resources/auto_run.rb +46 -0
  226. data/cookbooks/windows/resources/certificate.rb +166 -0
  227. data/cookbooks/windows/resources/certificate_binding.rb +128 -0
  228. data/cookbooks/windows/resources/feature.rb +82 -0
  229. data/cookbooks/windows/resources/feature_dism.rb +108 -0
  230. data/cookbooks/windows/resources/feature_powershell.rb +70 -0
  231. data/cookbooks/windows/resources/feature_servermanagercmd.rb +76 -0
  232. data/cookbooks/windows/resources/font.rb +80 -0
  233. data/cookbooks/windows/resources/http_acl.rb +110 -0
  234. data/cookbooks/windows/resources/pagefile.rb +152 -0
  235. data/cookbooks/windows/resources/path.rb +54 -0
  236. data/cookbooks/windows/resources/printer.rb +103 -0
  237. data/cookbooks/windows/resources/printer_port.rb +101 -0
  238. data/cookbooks/windows/resources/share.rb +291 -0
  239. data/cookbooks/windows/resources/shortcut.rb +53 -0
  240. data/cookbooks/windows/resources/task.rb +384 -0
  241. data/cookbooks/windows/resources/zipfile.rb +125 -0
  242. data/cookbooks/yum/.foodcritic +1 -0
  243. data/cookbooks/yum/CHANGELOG.md +351 -0
  244. data/cookbooks/yum/CONTRIBUTING.md +2 -0
  245. data/cookbooks/yum/MAINTAINERS.md +16 -0
  246. data/cookbooks/yum/README.md +125 -0
  247. data/cookbooks/yum/attributes/main.rb +103 -0
  248. data/cookbooks/yum/libraries/matchers.rb +9 -0
  249. data/cookbooks/yum/metadata.json +1 -0
  250. data/cookbooks/yum/recipes/default.rb +26 -0
  251. data/cookbooks/yum/recipes/dnf_yum_compat.rb +29 -0
  252. data/cookbooks/yum/resources/globalconfig.rb +119 -0
  253. data/cookbooks/yum/templates/.DS_Store +0 -0
  254. data/cookbooks/yum/templates/main.erb +276 -0
  255. data/cookbooks/yum-epel/CHANGELOG.md +138 -0
  256. data/cookbooks/yum-epel/CONTRIBUTING.md +2 -0
  257. data/cookbooks/yum-epel/MAINTAINERS.md +19 -0
  258. data/cookbooks/yum-epel/README.md +172 -0
  259. data/cookbooks/yum-epel/attributes/default.rb +8 -0
  260. data/cookbooks/yum-epel/attributes/epel-debuginfo.rb +15 -0
  261. data/cookbooks/yum-epel/attributes/epel-source.rb +15 -0
  262. data/cookbooks/yum-epel/attributes/epel-testing-debuginfo.rb +15 -0
  263. data/cookbooks/yum-epel/attributes/epel-testing-source.rb +15 -0
  264. data/cookbooks/yum-epel/attributes/epel-testing.rb +15 -0
  265. data/cookbooks/yum-epel/attributes/epel.rb +21 -0
  266. data/cookbooks/yum-epel/metadata.json +1 -0
  267. data/cookbooks/yum-epel/recipes/default.rb +27 -0
  268. data/cookbooks/yum-scl/.kitchen.dokken.yml +24 -0
  269. data/cookbooks/yum-scl/.kitchen.yml +24 -0
  270. data/cookbooks/yum-scl/.rubocop.yml +6 -0
  271. data/cookbooks/yum-scl/.travis.yml +28 -0
  272. data/cookbooks/yum-scl/Berksfile +3 -0
  273. data/cookbooks/yum-scl/Berksfile.lock +25 -0
  274. data/cookbooks/yum-scl/CHANGELOG.md +11 -0
  275. data/cookbooks/yum-scl/Gemfile +46 -0
  276. data/cookbooks/yum-scl/README.md +76 -0
  277. data/cookbooks/yum-scl/attributes/centos.rb +83 -0
  278. data/cookbooks/yum-scl/attributes/default.rb +15 -0
  279. data/cookbooks/yum-scl/attributes/scientific.rb +1 -0
  280. data/cookbooks/yum-scl/files/default/RPM-GPG-KEY-CentOS-SIG-SCLo +20 -0
  281. data/cookbooks/yum-scl/libraries/yum_scl_helper.rb +33 -0
  282. data/cookbooks/yum-scl/metadata.json +42 -0
  283. data/cookbooks/yum-scl/metadata.rb +12 -0
  284. data/cookbooks/yum-scl/recipes/chef_install.rb +52 -0
  285. data/cookbooks/yum-scl/recipes/default.rb +17 -0
  286. data/cookbooks/yum-scl/recipes/native_install.rb +35 -0
  287. data/lib/vagrant-clone/command/clone.rb +66 -61
  288. data/lib/vagrant-clone/errors.rb +61 -0
  289. data/lib/vagrant-clone/util/clone_manager_base.rb +69 -0
  290. data/lib/vagrant-clone/util/clone_managers/docker.rb +31 -0
  291. data/lib/vagrant-clone/util/clone_managers/libvirt.rb +254 -0
  292. data/lib/vagrant-clone/util/vagrantfile_managers/docker.rb +154 -0
  293. data/lib/vagrant-clone/util/vagrantfile_managers/libvirt.rb +159 -0
  294. data/lib/vagrant-clone/version.rb +2 -2
  295. data/lib/vagrant-clone.rb +6 -6
  296. data/libvirt.txt +7 -0
  297. data/performance_testing.rb +165 -0
  298. data/results.txt +45 -0
  299. data/scripts/create_box.sh +134 -0
  300. data/test.rb +92 -0
  301. data/tools/create_box.sh +130 -0
  302. data/vagrant-clone.gemspec +7 -7
  303. metadata +296 -5
  304. data/lib/vagrant-clone/command/errors.rb +0 -16
  305. data/lib/vagrant-clone/command/provider/docker.rb +0 -13
  306. data/lib/vagrant-clone/utils/vagrantfile_manager.rb +0 -47
@@ -0,0 +1,713 @@
1
+ #
2
+ # NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
3
+ #
4
+ # THIS IS A FILE AUTOGENERATED BY 'rake update' DO NOT EDIT!!!!
5
+ #
6
+ # NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
7
+ #
8
+
9
+ begin
10
+ require 'chef/property'
11
+ rescue LoadError; end
12
+
13
+ require 'chef_compat/copied_from_chef'
14
+ class Chef
15
+ module ::ChefCompat
16
+ module CopiedFromChef
17
+ #
18
+ # Author:: John Keiser <jkeiser@chef.io>
19
+ # Copyright:: Copyright 2015-2016, John Keiser.
20
+ # License:: Apache License, Version 2.0
21
+ #
22
+ # Licensed under the Apache License, Version 2.0 (the "License");
23
+ # you may not use this file except in compliance with the License.
24
+ # You may obtain a copy of the License at
25
+ #
26
+ # http://www.apache.org/licenses/LICENSE-2.0
27
+ #
28
+ # Unless required by applicable law or agreed to in writing, software
29
+ # distributed under the License is distributed on an "AS IS" BASIS,
30
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ # See the License for the specific language governing permissions and
32
+ # limitations under the License.
33
+ #
34
+
35
+ require "chef_compat/copied_from_chef/chef/delayed_evaluator"
36
+
37
+ class Chef < (defined?(::Chef) ? ::Chef : Object)
38
+ #
39
+ # Type and validation information for a property on a resource.
40
+ #
41
+ # A property named "x" manipulates the "@x" instance variable on a
42
+ # resource. The *presence* of the variable (`instance_variable_defined?(@x)`)
43
+ # tells whether the variable is defined; it may have any actual value,
44
+ # constrained only by validation.
45
+ #
46
+ # Properties may have validation, defaults, and coercion, and have full
47
+ # support for lazy values.
48
+ #
49
+ # @see Chef::Resource.property
50
+ # @see Chef::DelayedEvaluator
51
+ #
52
+ class Property < (defined?(::Chef::Property) ? ::Chef::Property : Object)
53
+ #
54
+ # Create a reusable property type that can be used in multiple properties
55
+ # in different resources.
56
+ #
57
+ # @param options [Hash<Symbol,Object>] Validation options. See Chef::Resource.property for
58
+ # the list of options.
59
+ #
60
+ # @example
61
+ # Property.derive(default: 'hi')
62
+ #
63
+ def self.derive(**options)
64
+ new(**options)
65
+ end
66
+
67
+ #
68
+ # Create a new property.
69
+ #
70
+ # @param options [Hash<Symbol,Object>] Property options, including
71
+ # control options here, as well as validation options (see
72
+ # Chef::Mixin::ParamsValidate#validate for a description of validation
73
+ # options).
74
+ # @option options [Symbol] :name The name of this property.
75
+ # @option options [Class] :declared_in The class this property comes from.
76
+ # @option options [Symbol] :instance_variable_name The instance variable
77
+ # tied to this property. Must include a leading `@`. Defaults to `@<name>`.
78
+ # `nil` means the property is opaque and not tied to a specific instance
79
+ # variable.
80
+ # @option options [Boolean] :desired_state `true` if this property is part of desired
81
+ # state. Defaults to `true`.
82
+ # @option options [Boolean] :identity `true` if this property is part of object
83
+ # identity. Defaults to `false`.
84
+ # @option options [Boolean] :name_property `true` if this
85
+ # property defaults to the same value as `name`. Equivalent to
86
+ # `default: lazy { name }`, except that #property_is_set? will
87
+ # return `true` if the property is set *or* if `name` is set.
88
+ # @option options [Boolean] :nillable `true` opt-in to Chef-13 style behavior where
89
+ # attempting to set a nil value will really set a nil value instead of issuing
90
+ # a warning and operating like a getter
91
+ # @option options [Object] :default The value this property
92
+ # will return if the user does not set one. If this is `lazy`, it will
93
+ # be run in the context of the instance (and able to access other
94
+ # properties) and cached. If not, the value will be frozen with Object#freeze
95
+ # to prevent users from modifying it in an instance.
96
+ # @option options [Proc] :coerce A proc which will be called to
97
+ # transform the user input to canonical form. The value is passed in,
98
+ # and the transformed value returned as output. Lazy values will *not*
99
+ # be passed to this method until after they are evaluated. Called in the
100
+ # context of the resource (meaning you can access other properties).
101
+ # @option options [Boolean] :required `true` if this property
102
+ # must be present; `false` otherwise. This is checked after the resource
103
+ # is fully initialized.
104
+ #
105
+ def initialize(**options)
106
+ super if defined?(::Chef::Property)
107
+ options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo }
108
+ @options = options
109
+ options[:name] = options[:name].to_sym if options[:name]
110
+ options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]
111
+
112
+ # Replace name_attribute with name_property
113
+ if options.has_key?(:name_attribute)
114
+ # If we have both name_attribute and name_property and they differ, raise an error
115
+ if options.has_key?(:name_property)
116
+ raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{self}."
117
+ end
118
+ # replace name_property with name_attribute in place
119
+ options = Hash[options.map { |k, v| k == :name_attribute ? [ :name_property, v ] : [ k, v ] }]
120
+ @options = options
121
+ end
122
+
123
+ # Only pick the first of :default, :name_property and :name_attribute if
124
+ # more than one is specified.
125
+ if options.has_key?(:default) && options[:name_property]
126
+ if options[:default].nil? || options.keys.index(:name_property) < options.keys.index(:default)
127
+ options.delete(:default)
128
+ preferred_default = :name_property
129
+ else
130
+ options.delete(:name_property)
131
+ preferred_default = :default
132
+ end
133
+ Chef.log_deprecation("Cannot specify both default and name_property together on property #{self}. Only one (#{preferred_default}) will be obeyed. In Chef 13, this will become an error. Please remove one or the other from the property.")
134
+ end
135
+
136
+ # Validate the default early, so the user gets a good error message, and
137
+ # cache it so we don't do it again if so
138
+ begin
139
+ # If we can validate it all the way to output, do it.
140
+ @stored_default = input_to_stored_value(nil, default, is_default: true)
141
+ rescue Chef::Exceptions::CannotValidateStaticallyError
142
+ # If the validation is not static (i.e. has procs), we will have to
143
+ # coerce and validate the default each time we run
144
+ end
145
+ end
146
+
147
+ def to_s
148
+ "#{name || "<property type>"}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
149
+ end
150
+
151
+ #
152
+ # The name of this property.
153
+ #
154
+ # @return [String]
155
+ #
156
+ def name
157
+ options[:name]
158
+ end
159
+
160
+ #
161
+ # The class this property was defined in.
162
+ #
163
+ # @return [Class]
164
+ #
165
+ def declared_in
166
+ options[:declared_in]
167
+ end
168
+
169
+ #
170
+ # The instance variable associated with this property.
171
+ #
172
+ # Defaults to `@<name>`
173
+ #
174
+ # @return [Symbol]
175
+ #
176
+ def instance_variable_name
177
+ if options.has_key?(:instance_variable_name)
178
+ options[:instance_variable_name]
179
+ elsif name
180
+ :"@#{name}"
181
+ end
182
+ end
183
+
184
+ #
185
+ # The raw default value for this resource.
186
+ #
187
+ # Does not coerce or validate the default. Does not evaluate lazy values.
188
+ #
189
+ # Defaults to `lazy { name }` if name_property is true; otherwise defaults to
190
+ # `nil`
191
+ #
192
+ def default
193
+ return options[:default] if options.has_key?(:default)
194
+ return Chef::DelayedEvaluator.new { name } if name_property?
195
+ nil
196
+ end
197
+
198
+ #
199
+ # Whether this is part of the resource's natural identity or not.
200
+ #
201
+ # @return [Boolean]
202
+ #
203
+ def identity?
204
+ options[:identity]
205
+ end
206
+
207
+ #
208
+ # Whether this is part of desired state or not.
209
+ #
210
+ # Defaults to true.
211
+ #
212
+ # @return [Boolean]
213
+ #
214
+ def desired_state?
215
+ return true if !options.has_key?(:desired_state)
216
+ options[:desired_state]
217
+ end
218
+
219
+ #
220
+ # Whether this is name_property or not.
221
+ #
222
+ # @return [Boolean]
223
+ #
224
+ def name_property?
225
+ options[:name_property]
226
+ end
227
+
228
+ #
229
+ # Whether this property has a default value.
230
+ #
231
+ # @return [Boolean]
232
+ #
233
+ def has_default?
234
+ options.has_key?(:default) || name_property?
235
+ end
236
+
237
+ #
238
+ # Whether this property is required or not.
239
+ #
240
+ # @return [Boolean]
241
+ #
242
+ def required?
243
+ options[:required]
244
+ end
245
+
246
+ #
247
+ # Whether this property is sensitive or not.
248
+ #
249
+ # Defaults to false.
250
+ #
251
+ # @return [Boolean]
252
+ #
253
+ def sensitive?
254
+ options.fetch(:sensitive, false)
255
+ end
256
+
257
+ #
258
+ # Validation options. (See Chef::Mixin::ParamsValidate#validate.)
259
+ #
260
+ # @return [Hash<Symbol,Object>]
261
+ #
262
+ def validation_options
263
+ @validation_options ||= options.reject do |k, v|
264
+ [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable, :sensitive].include?(k)
265
+ end
266
+ end
267
+
268
+ #
269
+ # Handle the property being called.
270
+ #
271
+ # The base implementation does the property get-or-set:
272
+ #
273
+ # ```ruby
274
+ # resource.myprop # get
275
+ # resource.myprop value # set
276
+ # ```
277
+ #
278
+ # Subclasses may implement this with any arguments they want, as long as
279
+ # the corresponding DSL calls it correctly.
280
+ #
281
+ # @param resource [Chef::Resource] The resource to get the property from.
282
+ # @param value The value to set (or NOT_PASSED if it is a get).
283
+ #
284
+ # @return The current value of the property. If it is a `set`, lazy values
285
+ # will be returned without running, validating or coercing. If it is a
286
+ # `get`, the non-lazy, coerced, validated value will always be returned.
287
+ #
288
+ def call(resource, value = NOT_PASSED)
289
+ if value == NOT_PASSED
290
+ return get(resource)
291
+ end
292
+
293
+ if value.nil? && !nillable?
294
+ # In Chef 12, value(nil) does a *get* instead of a set, so we
295
+ # warn if the value would have been changed. In Chef 13, it will be
296
+ # equivalent to value = nil.
297
+ result = get(resource, nil_set: true)
298
+
299
+ # Warn about this becoming a set in Chef 13.
300
+ begin
301
+ input_to_stored_value(resource, value)
302
+ # If nil is valid, and it would change the value, warn that this will change to a set.
303
+ if !result.nil?
304
+ Chef.log_deprecation("An attempt was made to change #{name} from #{result.inspect} to nil by calling #{name}(nil). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil.")
305
+ end
306
+ rescue Chef::Exceptions::DeprecatedFeatureError
307
+ raise
308
+ rescue
309
+ # If nil is invalid, warn that this will become an error.
310
+ Chef.log_deprecation("nil is an invalid value for #{self}. In Chef 13, this warning will change to an error. Error: #{$!}")
311
+ end
312
+
313
+ result
314
+ else
315
+ # Anything else, such as myprop(value) is a set
316
+ set(resource, value)
317
+ end
318
+ end
319
+
320
+ #
321
+ # Get the property value from the resource, handling lazy values,
322
+ # defaults, and validation.
323
+ #
324
+ # - If the property's value is lazy, it is evaluated, coerced and validated.
325
+ # - If the property has no value, and is required, raises ValidationFailed.
326
+ # - If the property has no value, but has a lazy default, it is evaluated,
327
+ # coerced and validated. If the evaluated value is frozen, the resulting
328
+ # - If the property has no value, but has a default, the default value
329
+ # will be returned and frozen. If the default value is lazy, it will be
330
+ # evaluated, coerced and validated, and the result stored in the property.
331
+ # - If the property has no value, but is name_property, `resource.name`
332
+ # is retrieved, coerced, validated and stored in the property.
333
+ # - Otherwise, `nil` is returned.
334
+ #
335
+ # @param resource [Chef::Resource] The resource to get the property from.
336
+ #
337
+ # @return The value of the property.
338
+ #
339
+ # @raise Chef::Exceptions::ValidationFailed If the value is invalid for
340
+ # this property, or if the value is required and not set.
341
+ #
342
+ def get(resource, nil_set: false)
343
+ # If it's set, return it (and evaluate any lazy values)
344
+ if is_set?(resource)
345
+ value = get_value(resource)
346
+ value = stored_value_to_output(resource, value)
347
+
348
+ else
349
+ # We are getting the default value.
350
+
351
+ # If the user does something like this:
352
+ #
353
+ # ```
354
+ # class MyResource < Chef::Resource
355
+ # property :content
356
+ # action :create do
357
+ # file '/x.txt' do
358
+ # content content
359
+ # end
360
+ # end
361
+ # end
362
+ # ```
363
+ #
364
+ # It won't do what they expect. This checks whether you try to *read*
365
+ # `content` while we are compiling the resource.
366
+ if !nil_set &&
367
+ resource.respond_to?(:resource_initializing) &&
368
+ resource.resource_initializing &&
369
+ resource.respond_to?(:enclosing_provider) &&
370
+ resource.enclosing_provider &&
371
+ resource.enclosing_provider.new_resource &&
372
+ resource.enclosing_provider.new_resource.respond_to?(name)
373
+ Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
374
+ end
375
+
376
+ if has_default?
377
+ # If we were able to cache the stored_default, grab it.
378
+ if defined?(@stored_default)
379
+ value = @stored_default
380
+ else
381
+ # Otherwise, we have to validate it now.
382
+ value = input_to_stored_value(resource, default, is_default: true)
383
+ end
384
+ value = stored_value_to_output(resource, value, is_default: true)
385
+
386
+ # If the value is mutable (non-frozen), we set it on the instance
387
+ # so that people can mutate it. (All constant default values are
388
+ # frozen.)
389
+ if !value.frozen? && !value.nil?
390
+ set_value(resource, value)
391
+ end
392
+
393
+ value
394
+
395
+ elsif required?
396
+ raise Chef::Exceptions::ValidationFailed, "#{name} is required"
397
+ end
398
+ end
399
+ end
400
+
401
+ #
402
+ # Set the value of this property in the given resource.
403
+ #
404
+ # Non-lazy values are coerced and validated before being set. Coercion
405
+ # and validation of lazy values is delayed until they are first retrieved.
406
+ #
407
+ # @param resource [Chef::Resource] The resource to set this property in.
408
+ # @param value The value to set.
409
+ #
410
+ # @return The value that was set, after coercion (if lazy, still returns
411
+ # the lazy value)
412
+ #
413
+ # @raise Chef::Exceptions::ValidationFailed If the value is invalid for
414
+ # this property.
415
+ #
416
+ def set(resource, value)
417
+ set_value(resource, input_to_stored_value(resource, value))
418
+ end
419
+
420
+ #
421
+ # Find out whether this property has been set.
422
+ #
423
+ # This will be true if:
424
+ # - The user explicitly set the value
425
+ # - The property has a default, and the value was retrieved.
426
+ #
427
+ # From this point of view, it is worth looking at this as "what does the
428
+ # user think this value should be." In order words, if the user grabbed
429
+ # the value, even if it was a default, they probably based calculations on
430
+ # it. If they based calculations on it and the value changes, the rest of
431
+ # the world gets inconsistent.
432
+ #
433
+ # @param resource [Chef::Resource] The resource to get the property from.
434
+ #
435
+ # @return [Boolean]
436
+ #
437
+ def is_set?(resource)
438
+ value_is_set?(resource)
439
+ end
440
+
441
+ #
442
+ # Reset the value of this property so that is_set? will return false and the
443
+ # default will be returned in the future.
444
+ #
445
+ # @param resource [Chef::Resource] The resource to get the property from.
446
+ #
447
+ def reset(resource)
448
+ reset_value(resource)
449
+ end
450
+
451
+ #
452
+ # Coerce an input value into canonical form for the property.
453
+ #
454
+ # After coercion, the value is suitable for storage in the resource.
455
+ # You must validate values after coercion, however.
456
+ #
457
+ # Does no special handling for lazy values.
458
+ #
459
+ # @param resource [Chef::Resource] The resource we're coercing against
460
+ # (to provide context for the coerce).
461
+ # @param value The value to coerce.
462
+ #
463
+ # @return The coerced value.
464
+ #
465
+ # @raise Chef::Exceptions::ValidationFailed If the value is invalid for
466
+ # this property.
467
+ #
468
+ def coerce(resource, value)
469
+ if options.has_key?(:coerce)
470
+ # If we have no default value, `nil` is never coerced or validated
471
+ unless !has_default? && value.nil?
472
+ value = exec_in_resource(resource, options[:coerce], value)
473
+ end
474
+ end
475
+ value
476
+ end
477
+
478
+ #
479
+ # Validate a value.
480
+ #
481
+ # Calls Chef::Mixin::ParamsValidate#validate with #validation_options as
482
+ # options.
483
+ #
484
+ # @param resource [Chef::Resource] The resource we're validating against
485
+ # (to provide context for the validate).
486
+ # @param value The value to validate.
487
+ #
488
+ # @raise Chef::Exceptions::ValidationFailed If the value is invalid for
489
+ # this property.
490
+ #
491
+ def validate(resource, value)
492
+ # If we have no default value, `nil` is never coerced or validated
493
+ unless value.nil? && !has_default?
494
+ if resource
495
+ resource.validate({ name => value }, { name => validation_options })
496
+ else
497
+ name = self.name || :property_type
498
+ Chef::Mixin::ParamsValidate.validate({ name => value }, { name => validation_options })
499
+ end
500
+ end
501
+ end
502
+
503
+ #
504
+ # Derive a new Property that is just like this one, except with some added or
505
+ # changed options.
506
+ #
507
+ # @param options [Hash<Symbol,Object>] List of options that would be passed
508
+ # to #initialize.
509
+ #
510
+ # @return [Property] The new property type.
511
+ #
512
+ def derive(**modified_options)
513
+ # Since name_property, name_attribute and default override each other,
514
+ # if you specify one of them in modified_options it overrides anything in
515
+ # the original options.
516
+ options = self.options
517
+ if modified_options.has_key?(:name_property) ||
518
+ modified_options.has_key?(:name_attribute) ||
519
+ modified_options.has_key?(:default)
520
+ options = options.reject { |k, v| k == :name_attribute || k == :name_property || k == :default }
521
+ end
522
+ self.class.new(options.merge(modified_options))
523
+ end
524
+
525
+ #
526
+ # Emit the DSL for this property into the resource class (`declared_in`).
527
+ #
528
+ # Creates a getter and setter for the property.
529
+ #
530
+ def emit_dsl
531
+ # We don't create the getter/setter if it's a custom property; we will
532
+ # be using the existing getter/setter to manipulate it instead.
533
+ return if !instance_variable_name
534
+
535
+ # We prefer this form because the property name won't show up in the
536
+ # stack trace if you use `define_method`.
537
+ declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
538
+ def #{name}(value=NOT_PASSED)
539
+ raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
540
+ self.class.properties[#{name.inspect}].call(self, value)
541
+ end
542
+ def #{name}=(value)
543
+ raise "Property `#{name}` of `\#{self}` was incorrectly passed a block. Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block_given?
544
+ self.class.properties[#{name.inspect}].set(self, value)
545
+ end
546
+ EOM
547
+ rescue SyntaxError
548
+ # If the name is not a valid ruby name, we use define_method.
549
+ declared_in.define_method(name) do |value = NOT_PASSED, &block|
550
+ raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
551
+ self.class.properties[name].call(self, value)
552
+ end
553
+ declared_in.define_method("#{name}=") do |value, &block|
554
+ raise "Property `#{name}` of `#{self}` was incorrectly passed a block! Possible property-resource collision. To call a resource named `#{name}` either rename the property or else use `declare_resource(:#{name}, ...)`" if block
555
+ self.class.properties[name].set(self, value)
556
+ end
557
+ end
558
+
559
+ #
560
+ # The options this Property will use for get/set behavior and validation.
561
+ #
562
+ # @see #initialize for a list of valid options.
563
+ #
564
+ attr_reader :options
565
+
566
+ #
567
+ # Find out whether this type accepts nil explicitly.
568
+ #
569
+ # A type accepts nil explicitly if "is" allows nil, it validates as nil, *and* is not simply
570
+ # an empty type.
571
+ #
572
+ # A type is presumed to accept nil if it does coercion (which must handle nil).
573
+ #
574
+ # These examples accept nil explicitly:
575
+ # ```ruby
576
+ # property :a, [ String, nil ]
577
+ # property :a, [ String, NilClass ]
578
+ # property :a, [ String, proc { |v| v.nil? } ]
579
+ # ```
580
+ #
581
+ # This does not (because the "is" doesn't exist or doesn't have nil):
582
+ #
583
+ # ```ruby
584
+ # property :x, String
585
+ # ```
586
+ #
587
+ # These do not, even though nil would validate fine (because they do not
588
+ # have "is"):
589
+ #
590
+ # ```ruby
591
+ # property :a
592
+ # property :a, equal_to: [ 1, 2, 3, nil ]
593
+ # property :a, kind_of: [ String, NilClass ]
594
+ # property :a, respond_to: [ ]
595
+ # property :a, callbacks: { "a" => proc { |v| v.nil? } }
596
+ # ```
597
+ #
598
+ # @param resource [Chef::Resource] The resource we're coercing against
599
+ # (to provide context for the coerce).
600
+ #
601
+ # @return [Boolean] Whether this value explicitly accepts nil.
602
+ #
603
+ # @api private
604
+ def explicitly_accepts_nil?(resource)
605
+ options.has_key?(:coerce) ||
606
+ (options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
607
+ end
608
+
609
+ # @api private
610
+ def get_value(resource)
611
+ if instance_variable_name
612
+ resource.instance_variable_get(instance_variable_name)
613
+ else
614
+ resource.send(name)
615
+ end
616
+ end
617
+
618
+ # @api private
619
+ def set_value(resource, value)
620
+ if instance_variable_name
621
+ resource.instance_variable_set(instance_variable_name, value)
622
+ else
623
+ resource.send(name, value)
624
+ end
625
+ end
626
+
627
+ # @api private
628
+ def value_is_set?(resource)
629
+ if instance_variable_name
630
+ resource.instance_variable_defined?(instance_variable_name)
631
+ else
632
+ true
633
+ end
634
+ end
635
+
636
+ # @api private
637
+ def reset_value(resource)
638
+ if instance_variable_name
639
+ if value_is_set?(resource)
640
+ resource.remove_instance_variable(instance_variable_name)
641
+ end
642
+ else
643
+ raise ArgumentError, "Property #{name} has no instance variable defined and cannot be reset"
644
+ end
645
+ end
646
+
647
+ private
648
+
649
+ def exec_in_resource(resource, proc, *args)
650
+ if resource
651
+ if proc.arity > args.size
652
+ value = proc.call(resource, *args)
653
+ else
654
+ value = resource.instance_exec(*args, &proc)
655
+ end
656
+ else
657
+ # If we don't have a resource yet, we can't exec in resource!
658
+ raise Chef::Exceptions::CannotValidateStaticallyError, "Cannot validate or coerce without a resource"
659
+ end
660
+ end
661
+
662
+ def input_to_stored_value(resource, value, is_default: false)
663
+ unless value.is_a?(DelayedEvaluator)
664
+ value = coerce_and_validate(resource, value, is_default: is_default)
665
+ end
666
+ value
667
+ end
668
+
669
+ def stored_value_to_output(resource, value, is_default: false)
670
+ # Crack open lazy values before giving the result to the user
671
+ if value.is_a?(DelayedEvaluator)
672
+ value = exec_in_resource(resource, value)
673
+ value = coerce_and_validate(resource, value, is_default: is_default)
674
+ end
675
+ value
676
+ end
677
+
678
+ # Coerces and validates the value. If the value is a default, it will warn
679
+ # the user that invalid defaults are bad mmkay, and return it as if it were
680
+ # valid.
681
+ def coerce_and_validate(resource, value, is_default: false)
682
+ result = coerce(resource, value)
683
+ begin
684
+ # If the input is from a default, we need to emit an invalid default warning on validate.
685
+ validate(resource, result)
686
+ rescue Chef::Exceptions::CannotValidateStaticallyError
687
+ # This one gets re-raised
688
+ raise
689
+ rescue
690
+ # Anything else is just an invalid default: in those cases, we just
691
+ # warn and return the (possibly coerced) value to the user.
692
+ if is_default
693
+ if value.nil?
694
+ Chef.log_deprecation("Default value nil is invalid for property #{self}. Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property #{name.inspect}, [ String, nil ], default: nil'). Error: #{$!}")
695
+ else
696
+ Chef.log_deprecation("Default value #{value.inspect} is invalid for property #{self}. In Chef 13 this will become an error: #{$!}.")
697
+ end
698
+ else
699
+ raise
700
+ end
701
+ end
702
+
703
+ result
704
+ end
705
+
706
+ def nillable?
707
+ !!options[:nillable]
708
+ end
709
+ end
710
+ end
711
+ end
712
+ end
713
+ end