From 490bfca05e7e0d9be75729ab39cbf9a4ff6ba25c Mon Sep 17 00:00:00 2001 From: Dr Nic Williams Date: Tue, 14 May 2013 08:58:31 -0400 Subject: [PATCH] Wired in cyoi to choose a provider/credentials --- Guardfile | 1 + lib/bosh-bootstrap/cli/commands/deploy.rb | 9 ++++++++- lib/bosh-bootstrap/cli/helpers/settings.rb | 12 +++++++++++- spec/unit/commands/deploy_spec.rb | 11 +++++++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Guardfile b/Guardfile index c8b9a96..e0d0b67 100644 --- a/Guardfile +++ b/Guardfile @@ -1,6 +1,7 @@ guard 'rspec', spec_paths: ["spec/unit"] do watch(%r{^spec/unit/(.+_spec)\.rb$}) watch(%r{^lib/bosh/cli/commands/(.+)\.rb$}) { |m| "spec/unit/cli" } + watch(%r{^lib/bosh-bootstrap/cli/commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" } watch(%r{^lib/bosh-bootstrap/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec/unit" } end diff --git a/lib/bosh-bootstrap/cli/commands/deploy.rb b/lib/bosh-bootstrap/cli/commands/deploy.rb index 6805495..e918898 100644 --- a/lib/bosh-bootstrap/cli/commands/deploy.rb +++ b/lib/bosh-bootstrap/cli/commands/deploy.rb @@ -1,16 +1,23 @@ module Bosh; module Bootstrap; module Cli; module Commands; end; end; end; end +require "cyoi/cli/provider" +require "bosh-bootstrap/cli/helpers" + # * select_provider # * select_or_provision_public_networking # public_ip or ip/network/gateway # * select_public_image_or_download_stemcell # download if stemcell # * create_microbosh_manifest # * microbosh_deploy class Bosh::Bootstrap::Cli::Commands::Deploy + include Bosh::Bootstrap::Cli::Helpers::Settings + def initialize end def perform - + cyoi_provider = Cyoi::Cli::Provider.new([settings_dir]) + cyoi_provider.execute! + reload_settings! end end \ No newline at end of file diff --git a/lib/bosh-bootstrap/cli/helpers/settings.rb b/lib/bosh-bootstrap/cli/helpers/settings.rb index db17a0c..db40bd4 100644 --- a/lib/bosh-bootstrap/cli/helpers/settings.rb +++ b/lib/bosh-bootstrap/cli/helpers/settings.rb @@ -10,7 +10,12 @@ module Bosh::Bootstrap::Cli::Helpers::Settings # Defaults to ~/.bosh_inception; and can be overridden with either: # * $SETTINGS - to a folder (supported method) def settings_dir - @settings_dir ||= ENV['SETTINGS'] || raise("please assign @settings_dir or $SETTINGS first") + @settings_dir ||= File.expand_path(ENV["SETTINGS"] || "~/.microbosh") + end + + def settings_dir=(settings_dir) + @settings_dir = File.expand_path(settings_dir) + reload_settings! end def settings_ssh_dir @@ -46,6 +51,11 @@ def save_settings! settings.create_accessors! end + def reload_settings! + @settings = nil + settings + end + def migrate_old_settings end end diff --git a/spec/unit/commands/deploy_spec.rb b/spec/unit/commands/deploy_spec.rb index 6b48dad..75164a6 100644 --- a/spec/unit/commands/deploy_spec.rb +++ b/spec/unit/commands/deploy_spec.rb @@ -2,7 +2,9 @@ require "bosh-bootstrap/cli/commands/deploy" describe Bosh::Bootstrap::Cli::Commands::Deploy do - include FileUtils + include Bosh::Bootstrap::Cli::Helpers::Settings + + let(:settings_dir) { File.expand_path("~/.microbosh") } before do FileUtils.mkdir_p(@stemcells_dir = File.join(Dir.mktmpdir, "stemcells")) @@ -20,7 +22,12 @@ # * create_microbosh_manifest # * microbosh_deploy describe "aws" do - it "deploy creates provisions IP address micro_bosh.yml, discovers/downloads stemcell/AMI, runs 'bosh micro deploy'" + it "deploy creates provisions IP address micro_bosh.yml, discovers/downloads stemcell/AMI, runs 'bosh micro deploy'" do + cyoi_provider = double(Cyoi::Cli::Provider) + cyoi_provider.stub(:execute!) + Cyoi::Cli::Provider.stub(:new).with([settings_dir]).and_return(cyoi_provider) + cmd.perform + end it "delete does nothing if not targetting a deployment" it "delete runs 'bosh micro delete' & releases IP address; updates settings" end