Class: HostedChef::ConfigInstaller
- Inherits:
-
Object
- Object
- HostedChef::ConfigInstaller
- Defined in:
- lib/hosted-chef/config_installer.rb
Overview
Handles the business of selecting the install location and writing out the API keys and knife config.
Instance Attribute Summary collapse
-
#install_type ⇒ Object
readonly
Returns the value of attribute install_type.
Instance Method Summary collapse
-
#initialize(api_client, options) ⇒ ConfigInstaller
constructor
A new instance of ConfigInstaller.
- #install_all ⇒ Object
- #install_dir ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(api_client, options) ⇒ ConfigInstaller
Returns a new instance of ConfigInstaller.
8 9 10 11 |
# File 'lib/hosted-chef/config_installer.rb', line 8 def initialize(api_client, ) @api_client, @options = api_client, @install_dir, @install_type = nil, nil end |
Instance Attribute Details
#install_type ⇒ Object (readonly)
Returns the value of attribute install_type.
6 7 8 |
# File 'lib/hosted-chef/config_installer.rb', line 6 def install_type @install_type end |
Instance Method Details
#install_all ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hosted-chef/config_installer.rb', line 24 def install_all puts "\nInstalling..." puts "> mkdir -p #{install_dir}" FileUtils.mkdir_p(install_dir) knife_rb = "#{@install_dir}/knife.rb" puts "> create #{knife_rb} 0644" File.open(knife_rb, File::RDWR|File::CREAT, 0644) {|f| f << @api_client.knife_config } user_pem = "#{@install_dir}/#{@options.username}.pem" puts "> create #{user_pem} 0600" File.open(user_pem, File::RDWR|File::CREAT, 0600) {|f| f << @api_client.user_key } validator_pem = "#{@install_dir}/#{@options.orgname}-validator.pem" puts "> create #{validator_pem} 0600" File.open(validator_pem, File::RDWR|File::CREAT, 0600) {|f| f << @api_client.validator_key } end |
#install_dir ⇒ Object
17 18 19 20 21 22 |
# File 'lib/hosted-chef/config_installer.rb', line 17 def install_dir unless @install_dir @install_dir, @install_type = select_install_dir end @install_dir end |
#validate! ⇒ Object
13 14 15 |
# File 'lib/hosted-chef/config_installer.rb', line 13 def validate! install_dir end |