aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-10 12:31:08 -0800
committerelijah <elijah@riseup.net>2013-02-10 12:31:08 -0800
commit656f9f9056a59cca2edf7939d14390127eca152b (patch)
treecfc34d43bb0049ca73b006aef5ee261bd616bc5e
parentafd89df25b9d0b3acab55ff46496359111acdb2a (diff)
downloadleap_cli-656f9f9056a59cca2edf7939d14390127eca152b.tar.gz
leap_cli-656f9f9056a59cca2edf7939d14390127eca152b.tar.bz2
moved vagrant config to Leapfile, added ~/.leaprc support.
-rw-r--r--lib/leap_cli/commands/new.rb1
-rw-r--r--lib/leap_cli/config/manager.rb8
-rw-r--r--lib/leap_cli/leapfile.rb26
3 files changed, 26 insertions, 9 deletions
diff --git a/lib/leap_cli/commands/new.rb b/lib/leap_cli/commands/new.rb
index c4a067e..b6eb4f1 100644
--- a/lib/leap_cli/commands/new.rb
+++ b/lib/leap_cli/commands/new.rb
@@ -88,6 +88,7 @@ module LeapCli; module Commands
## Optional:
# @custom_vagrant_vm_line = "config.vm.boot_mode = :gui"
# @log = "/tmp/leap.log"
+# @vagrant_network = '10.5.5.0/24'
]
end
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb
index 79a5c0e..b90c741 100644
--- a/lib/leap_cli/config/manager.rb
+++ b/lib/leap_cli/config/manager.rb
@@ -284,14 +284,8 @@ module LeapCli
end
end
- #
- # TODO: apply JSON spec
- #
- PRIVATE_IP_RANGES = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/
def validate_provider(provider)
- Util::assert! provider.vagrant.network =~ PRIVATE_IP_RANGES do
- log 0, :error, 'in provider.json: vagrant.network is not a local private network'
- end
+ # nothing yet.
end
end
diff --git a/lib/leap_cli/leapfile.rb b/lib/leap_cli/leapfile.rb
index 439b60c..c24f939 100644
--- a/lib/leap_cli/leapfile.rb
+++ b/lib/leap_cli/leapfile.rb
@@ -15,6 +15,11 @@ module LeapCli
attr_accessor :custom_vagrant_vm_line
attr_accessor :leap_version
attr_accessor :log
+ attr_accessor :vagrant_network
+
+ def initialize
+ @vagrant_network = '10.5.5.0/24'
+ end
def load
directory = File.expand_path(find_in_directory_tree('Leapfile'))
@@ -22,8 +27,8 @@ module LeapCli
return nil
else
self.provider_directory_path = directory
- leapfile = directory + '/Leapfile'
- instance_eval(File.read(leapfile), leapfile)
+ read_settings(directory + '/Leapfile')
+ read_settings(ENV['HOME'] + '/.leaprc')
self.platform_directory_path = File.expand_path(self.platform_directory_path || '../leap_platform', self.provider_directory_path)
return true
end
@@ -31,6 +36,14 @@ module LeapCli
private
+ def read_settings(file)
+ if File.exists? file
+ Util::log 2, :read, file
+ instance_eval(File.read(file), file)
+ validate(file)
+ end
+ end
+
def find_in_directory_tree(filename)
search_dir = Dir.pwd
while search_dir != "/"
@@ -41,6 +54,15 @@ module LeapCli
end
return search_dir
end
+
+ PRIVATE_IP_RANGES = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/
+
+ def validate(file)
+ Util::assert! vagrant_network =~ PRIVATE_IP_RANGES do
+ Util::log 0, :error, "in #{file}: vagrant_network is not a local private network"
+ end
+ end
+
end
end