Class: HostedChef::ConfigInstaller

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, options)
  @api_client, @options = api_client, options
  @install_dir, @install_type = nil, nil
end

Instance Attribute Details

#install_typeObject (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_allObject



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_dirObject



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