]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
moved vagrant config to Leapfile, added ~/.leaprc support.
authorelijah <elijah@riseup.net>
Sun, 10 Feb 2013 20:31:08 +0000 (12:31 -0800)
committerelijah <elijah@riseup.net>
Sun, 10 Feb 2013 20:31:08 +0000 (12:31 -0800)
lib/leap_cli/commands/new.rb
lib/leap_cli/config/manager.rb
lib/leap_cli/leapfile.rb

index c4a067e5f2d2fd7b93ddb6bdb3563204264978aa..b6eb4f1363908db583f642bdff16116815f00946 100644 (file)
@@ -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
 
index 79a5c0e6111df7bc2a66062153964035e5ab2fc9..b90c7415d29219ff9dea24ffe15ac5174da1add5 100644 (file)
@@ -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
index 439b60ce8a14ab9653801dc595fdd951ecf13c16..c24f939e721b9973714372d6d70b4fadeb32580b 100644 (file)
@@ -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