module Cyoi::Cli::Helpers::Settings

Public Instance Methods

migrate_old_settings() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 52
def migrate_old_settings
end
reload_settings!() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 47
def reload_settings!
  @settings = nil
  settings
end
save_settings!() click to toggle source

Saves current nested ReadWriteSettings into pure Hash-based YAML file Recreates accessors on ReadWriteSettings object (since something has changed)

# File lib/cyoi/cli/helpers/settings.rb, line 38
def save_settings!
  File.open(settings_path, "w") { |f| f << settings.to_nested_hash.to_yaml }
  settings.create_accessors!
end
settings() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 24
def settings
  @settings ||= begin
    unless File.exists?(settings_path)
      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() click to toggle source

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)

# File lib/cyoi/cli/helpers/settings.rb, line 12
def settings_dir
  @settings_dir ||= ENV['SETTINGS'] || raise("please assign @settings_dir or $SETTINGS first")
end
settings_path() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 20
def settings_path
  @settings_path ||= File.join(settings_dir, "settings.yml")
end
settings_ssh_dir() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 16
def settings_ssh_dir
  File.join(settings_dir, "ssh")
end
show_settings() click to toggle source
# File lib/cyoi/cli/helpers/settings.rb, line 43
def show_settings
  puts "Using settings file #{settings_path}"
end