Module: Bosh::Gen::Settings
- Included in:
- Generators::NewReleaseGenerator
- Defined in:
- lib/bosh/gen/settings.rb
Instance Method Summary collapse
- #migrate_old_settings ⇒ Object
- #reload_settings! ⇒ Object
-
#save_settings! ⇒ Object
Saves current nested ReadWriteSettings into pure Hash-based YAML file Recreates accessors on ReadWriteSettings object (since something has changed).
-
#setting(nested_key, value) ⇒ Object
Set a nested setting with “key1.key2.key3” notation.
- #settings ⇒ Object
-
#settings_dir ⇒ Object
The base directory for holding the manifest settings file and private keys.
- #settings_dir=(settings_dir) ⇒ Object
- #settings_path ⇒ Object
- #settings_ssh_dir ⇒ Object
Instance Method Details
#migrate_old_settings ⇒ Object
59 60 |
# File 'lib/bosh/gen/settings.rb', line 59 def migrate_old_settings end |
#reload_settings! ⇒ Object
54 55 56 57 |
# File 'lib/bosh/gen/settings.rb', line 54 def reload_settings! @settings = nil settings end |
#save_settings! ⇒ Object
Saves current nested ReadWriteSettings into pure Hash-based YAML file Recreates accessors on ReadWriteSettings object (since something has changed)
49 50 51 52 |
# File 'lib/bosh/gen/settings.rb', line 49 def save_settings! File.open(settings_path, "w") { |f| f << settings.to_nested_hash.to_yaml } settings.create_accessors! end |
#setting(nested_key, value) ⇒ Object
Set a nested setting with “key1.key2.key3” notation
42 43 44 45 |
# File 'lib/bosh/gen/settings.rb', line 42 def setting(nested_key, value) settings.set(nested_key, value) save_settings! end |
#settings ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bosh/gen/settings.rb', line 29 def settings @settings ||= begin unless File.exists?(settings_path) FileUtils.mkdir_p(settings_dir) File.open(settings_path, "w") { |file| file << "--- {}" } end FileUtils.chmod(0600, settings_path) FileUtils.chmod(0700, settings_ssh_dir) if File.directory?(settings_ssh_dir) ReadWriteSettings.new(settings_path) end end |
#settings_dir ⇒ Object
The base directory for holding the manifest settings file and private keys
Defaults to ~/.bosh_inception; and can be overridden with either:
-
$SETTINGS - to a folder (supported method)
11 12 13 |
# File 'lib/bosh/gen/settings.rb', line 11 def settings_dir @settings_dir ||= File.(ENV["SETTINGS"] || "~/.bosh-gen") end |
#settings_dir=(settings_dir) ⇒ Object
15 16 17 18 19 |
# File 'lib/bosh/gen/settings.rb', line 15 def settings_dir=(settings_dir) @settings_dir = File.(settings_dir) @settings = @settings_path = nil reload_settings! end |
#settings_path ⇒ Object
25 26 27 |
# File 'lib/bosh/gen/settings.rb', line 25 def settings_path @settings_path ||= File.join(settings_dir, "settings.yml") end |
#settings_ssh_dir ⇒ Object
21 22 23 |
# File 'lib/bosh/gen/settings.rb', line 21 def settings_ssh_dir File.join(settings_dir, "ssh") end |