summaryrefslogtreecommitdiff
path: root/lib/leap_cli
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-03-22 11:45:06 -0700
committerelijah <elijah@riseup.net>2016-03-22 11:45:06 -0700
commitb163e19053d8bda055476ff2a9244411e7e1cfa9 (patch)
tree55ca97731280c8a3b00b649906233c878fd5089a /lib/leap_cli
parentb1311b89b3626fe4194801f1c8d954a6f0d9b70e (diff)
ensure that compile is run first when generating zone, firewall, or hosts output.
Diffstat (limited to 'lib/leap_cli')
-rw-r--r--lib/leap_cli/commands/compile.rb40
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/leap_cli/commands/compile.rb b/lib/leap_cli/commands/compile.rb
index 0b3e02e4..47b003eb 100644
--- a/lib/leap_cli/commands/compile.rb
+++ b/lib/leap_cli/commands/compile.rb
@@ -10,28 +10,14 @@ module LeapCli
c.command :all do |all|
all.action do |global_options,options,args|
environment = args.first
- if !LeapCli.leapfile.environment.nil? && !environment.nil? && environment != LeapCli.leapfile.environment
- bail! "You cannot specify an ENVIRONMENT argument while the environment is pinned."
- end
- if environment
- if manager.environment_names.include?(environment)
- compile_hiera_files(manager.filter([environment]), false)
- else
- bail! "There is no environment named `#{environment}`."
- end
- else
- clean_export = LeapCli.leapfile.environment.nil?
- compile_hiera_files(manager.filter, clean_export)
- end
- if file_exists?(:static_web_readme)
- compile_provider_json(environment)
- end
+ compile_command(environment)
end
end
c.desc "Prints a DNS zone file for your provider."
c.command :zone do |zone|
zone.action do |global_options, options, args|
+ compile_command(nil)
compile_zone_file
end
end
@@ -39,6 +25,7 @@ module LeapCli
c.desc "Print entries suitable for an /etc/hosts file, useful for testing your provider."
c.command :hosts do |hosts|
hosts.action do |global_options, options, args|
+ compile_command(nil)
compile_hosts_file
end
end
@@ -46,6 +33,7 @@ module LeapCli
c.desc "Compile provider.json bootstrap files for your provider."
c.command 'provider.json' do |provider|
provider.action do |global_options, options, args|
+ compile_command(nil)
compile_provider_json
end
end
@@ -55,6 +43,7 @@ module LeapCli
"rules in case you also have a restrictive network firewall."
c.command :firewall do |zone|
zone.action do |global_options, options, args|
+ compile_command(nil)
compile_firewall
end
end
@@ -64,6 +53,25 @@ module LeapCli
protected
+ def compile_command(environment)
+ if !LeapCli.leapfile.environment.nil? && !environment.nil? && environment != LeapCli.leapfile.environment
+ bail! "You cannot specify an ENVIRONMENT argument while the environment is pinned."
+ end
+ if environment
+ if manager.environment_names.include?(environment)
+ compile_hiera_files(manager.filter([environment]), false)
+ else
+ bail! "There is no environment named `#{environment}`."
+ end
+ else
+ clean_export = LeapCli.leapfile.environment.nil?
+ compile_hiera_files(manager.filter, clean_export)
+ end
+ if file_exists?(:static_web_readme)
+ compile_provider_json(environment)
+ end
+ end
+
#
# a "clean" export of secrets will also remove keys that are no longer used,
# but this should not be done if we are not examining all possible nodes.