aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap_cli')
-rw-r--r--lib/leap_cli/commands/node.rb4
-rw-r--r--lib/leap_cli/leapfile.rb15
-rw-r--r--lib/leap_cli/path.rb66
3 files changed, 19 insertions, 66 deletions
diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb
index 21822d1..bf552d3 100644
--- a/lib/leap_cli/commands/node.rb
+++ b/lib/leap_cli/commands/node.rb
@@ -75,7 +75,7 @@ module LeapCli; module Commands
node = get_node_from_args(args)
new_name = args.last
ensure_dir [:node_files_dir, new_name]
- Path::NODE_PATHS.each do |path|
+ Leap::Platform.node_files.each do |path|
rename_file! [path, node.name], [path, new_name]
end
remove_directory! [:node_files_dir, node.name]
@@ -87,7 +87,7 @@ module LeapCli; module Commands
node.command :rm do |rm|
rm.action do |global_options,options,args|
node = get_node_from_args(args)
- (Path::NODE_PATHS + [:node_files_dir]).each do |path|
+ (Leap::Platform.node_files + [:node_files_dir]).each do |path|
remove_file! [path, node.name]
end
if node.vagrant?
diff --git a/lib/leap_cli/leapfile.rb b/lib/leap_cli/leapfile.rb
index 06db3b4..e37cd4e 100644
--- a/lib/leap_cli/leapfile.rb
+++ b/lib/leap_cli/leapfile.rb
@@ -28,10 +28,25 @@ module LeapCli
if directory == '/'
return nil
else
+ #
+ # set up paths
+ #
@provider_directory_path = directory
read_settings(directory + '/Leapfile')
read_settings(ENV['HOME'] + '/.leaprc')
@platform_directory_path = File.expand_path(@platform_directory_path || '../leap_platform', @provider_directory_path)
+
+ #
+ # load the platform
+ #
+ require "#{@platform_directory_path}/platform.rb"
+ if !Leap::Platform.compatible_with_cli?(LeapCli::VERSION)
+ Util.bail! "This leap command (version #{LeapCli::VERSION}) is not compatible with the platform #{@platform_directory_path} (which requires #{Platform.compatible_cli.first} to #{Platform.compatible_cli.last})."
+ end
+
+ #
+ # set defaults
+ #
if @allow_production_deploy.nil?
# by default, only allow production deploys from 'master' or if not a git repo
@allow_production_deploy = !LeapCli::Util.is_git_directory?(@provider_directory_path) ||
diff --git a/lib/leap_cli/path.rb b/lib/leap_cli/path.rb
index 4b17d45..b705788 100644
--- a/lib/leap_cli/path.rb
+++ b/lib/leap_cli/path.rb
@@ -2,68 +2,6 @@ require 'fileutils'
module LeapCli; module Path
- #
- # all the named paths, relative to provider directory.
- #
- NAMED_PATHS = {
- # directories
- :hiera_dir => 'hiera',
- :files_dir => 'files',
- :nodes_dir => 'nodes',
- :services_dir => 'services',
- :tags_dir => 'tags',
- :node_files_dir => 'files/nodes/#{arg}',
-
- # input config files
- :common_config => 'common.json',
- :provider_config => 'provider.json',
- :secrets_config => 'secrets.json',
- :node_config => 'nodes/#{arg}.json',
- :service_config => 'services/#{arg}.json',
- :tag_config => 'tags/#{arg}.json',
-
- # input templates
- :provider_json_template => 'files/service-definitions/provider.json.erb',
- :eip_service_json_template => 'files/service-definitions/#{arg}/eip-service.json.erb',
- :soledad_service_json_template => 'files/service-definitions/#{arg}/soledad-service.json.erb',
- :smtp_service_json_template => 'files/service-definitions/#{arg}/smtp-service.json.erb',
-
- # output files
- :user_ssh => 'users/#{arg}/#{arg}_ssh.pub',
- :user_pgp => 'users/#{arg}/#{arg}_pgp.pub',
- :known_hosts => 'files/ssh/known_hosts',
- :authorized_keys => 'files/ssh/authorized_keys',
- :ca_key => 'files/ca/ca.key',
- :ca_cert => 'files/ca/ca.crt',
- :client_ca_key => 'files/ca/client_ca.key',
- :client_ca_cert => 'files/ca/client_ca.crt',
- :dh_params => 'files/ca/dh.pem',
- :commercial_key => 'files/cert/#{arg}.key',
- :commercial_csr => 'files/cert/#{arg}.csr',
- :commercial_cert => 'files/cert/#{arg}.crt',
- :commercial_ca_cert => 'files/cert/commercial_ca.crt',
- :vagrantfile => 'test/Vagrantfile',
-
- # node output files
- :hiera => 'hiera/#{arg}.yaml',
- :node_ssh_pub_key => 'files/nodes/#{arg}/#{arg}_ssh.pub',
- :node_x509_key => 'files/nodes/#{arg}/#{arg}.key',
- :node_x509_cert => 'files/nodes/#{arg}/#{arg}.crt',
-
- # testing files
- :test_client_key => 'test/cert/client.key',
- :test_client_cert => 'test/cert/client.crt',
- :test_openvpn_config => 'test/openvpn/#{arg}.ovpn',
- :test_client_openvpn_template => 'test/openvpn/client.ovpn.erb'
- }
-
- #
- # paths that take node name as the argument
- #
- NODE_PATHS = [
- :node_config, :hiera, :node_x509_cert, :node_x509_key, :node_ssh_pub_key
- ]
-
def self.platform
@platform
end
@@ -122,8 +60,8 @@ module LeapCli; module Path
end
if name.is_a? Symbol
- Util::assert!(NAMED_PATHS[name], "Error, I don't know the path for :#{name} (with argument '#{arg}')")
- filename = eval('"' + NAMED_PATHS[name] + '"')
+ Util::assert!(Leap::Platform.paths[name], "Error, I don't know the path for :#{name} (with argument '#{arg}')")
+ filename = eval('"' + Leap::Platform.paths[name] + '"')
return provider_dir + '/' + filename
else
return name