Class: HostedChef::Controller
- Inherits:
-
Object
- Object
- HostedChef::Controller
- Defined in:
- lib/hosted-chef/controller.rb
Overview
Controller and Presentation (yes, I know) for the Hosted Chef user setup task (currently the only task).
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #fetch_and_install ⇒ Object
- #goodbye ⇒ Object
- #greeting ⇒ Object
-
#initialize(argv = ARGV) ⇒ Controller
constructor
A new instance of Controller.
- #run ⇒ Object
- #setup_and_validate ⇒ Object
Constructor Details
#initialize(argv = ARGV) ⇒ Controller
Returns a new instance of Controller.
9 10 11 12 13 14 15 |
# File 'lib/hosted-chef/controller.rb', line 9 def initialize(argv=ARGV) @argv = argv @options = ArgvParser.new(argv).parse @api_client = ApiClient.new(@options) @validator = ConfigValidator.new(@api_client, @options) @config_installer = ConfigInstaller.new(@api_client, @options) end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
7 8 9 |
# File 'lib/hosted-chef/controller.rb', line 7 def argv @argv end |
Instance Method Details
#fetch_and_install ⇒ Object
40 41 42 |
# File 'lib/hosted-chef/controller.rb', line 40 def fetch_and_install @config_installer.install_all end |
#goodbye ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hosted-chef/controller.rb', line 44 def goodbye puts(<<-RESOURCES) You're ready to go! To verify your configuration, try running `knife client list` If you should run into trouble check the following resources: * Knife built-in manuals: run `knife help` * Documentation at http://wiki.opscode.com * Get support from Opscode: http://help.opscode.com/ RESOURCES end |
#greeting ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hosted-chef/controller.rb', line 17 def greeting puts(<<-WELCOME) Welcome to Opscode Hosted Chef. We're going to download your API keys and knife config from Opscode and install them on your system. Before you continue, please be aware that this program will update your API key and your organization's validation key. The existing keys for these accounts will be expired and no longer valid. Your config will be created in #{@config_installer.install_dir} WELCOME unless HighLine.new.agree("Ready to get started? (yes/no): ") STDERR.puts "goodbye." exit 1 end end |
#run ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hosted-chef/controller.rb', line 58 def run @config_installer.validate! greeting @options.ask_for_missing_opts setup_and_validate fetch_and_install goodbye rescue Interrupt, EOFError puts "\nexiting..." exit! 1 end |
#setup_and_validate ⇒ Object
36 37 38 |
# File 'lib/hosted-chef/controller.rb', line 36 def setup_and_validate @validator.validate! end |