Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2ba079665 | ||
|
|
c8d0dba1cb | ||
|
|
e8d2552caa | ||
|
|
927a57f738 | ||
|
|
f65538c1b1 | ||
|
|
470c8043af | ||
|
|
3e69b27f5f | ||
|
|
f4b1e3701b |
+10
-12
@@ -1,7 +1,7 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
foreman (0.18.0)
|
foreman (0.19.0)
|
||||||
term-ansicolor (~> 1.0.5)
|
term-ansicolor (~> 1.0.5)
|
||||||
thor (>= 0.13.6)
|
thor (>= 0.13.6)
|
||||||
|
|
||||||
@@ -28,16 +28,14 @@ GEM
|
|||||||
mustache (>= 0.7.0)
|
mustache (>= 0.7.0)
|
||||||
rdiscount (>= 1.5.8)
|
rdiscount (>= 1.5.8)
|
||||||
rr (1.0.2)
|
rr (1.0.2)
|
||||||
rspec (2.0.1)
|
rspec (2.6.0)
|
||||||
rspec-core (~> 2.0.1)
|
rspec-core (~> 2.6.0)
|
||||||
rspec-expectations (~> 2.0.1)
|
rspec-expectations (~> 2.6.0)
|
||||||
rspec-mocks (~> 2.0.1)
|
rspec-mocks (~> 2.6.0)
|
||||||
rspec-core (2.0.1)
|
rspec-core (2.6.4)
|
||||||
rspec-expectations (2.0.1)
|
rspec-expectations (2.6.0)
|
||||||
diff-lcs (>= 1.1.2)
|
diff-lcs (~> 1.1.2)
|
||||||
rspec-mocks (2.0.1)
|
rspec-mocks (2.6.0)
|
||||||
rspec-core (~> 2.0.1)
|
|
||||||
rspec-expectations (~> 2.0.1)
|
|
||||||
term-ansicolor (1.0.5)
|
term-ansicolor (1.0.5)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
|
|
||||||
@@ -52,4 +50,4 @@ DEPENDENCIES
|
|||||||
rcov (~> 0.9.8)
|
rcov (~> 0.9.8)
|
||||||
ronn
|
ronn
|
||||||
rr (~> 1.0.2)
|
rr (~> 1.0.2)
|
||||||
rspec (~> 2.0.0)
|
rspec (~> 2.6.0)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ task :default => :spec
|
|||||||
task :release => :man
|
task :release => :man
|
||||||
|
|
||||||
desc "Run all specs"
|
desc "Run all specs"
|
||||||
Rspec::Core::RakeTask.new(:spec) do |t|
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||||
t.pattern = 'spec/**/*_spec.rb'
|
t.pattern = 'spec/**/*_spec.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ task :rcov => "rcov:build" do
|
|||||||
%x{ open coverage/index.html }
|
%x{ open coverage/index.html }
|
||||||
end
|
end
|
||||||
|
|
||||||
Rspec::Core::RakeTask.new("rcov:build") do |t|
|
RSpec::Core::RakeTask.new("rcov:build") do |t|
|
||||||
t.pattern = 'spec/**/*_spec.rb'
|
t.pattern = 'spec/**/*_spec.rb'
|
||||||
t.rcov = true
|
t.rcov = true
|
||||||
t.rcov_opts = [ "--exclude", ".bundle", "--exclude", "spec" ]
|
t.rcov_opts = [ "--exclude", ".bundle", "--exclude", "spec" ]
|
||||||
|
|||||||
+1
-1
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
|
|||||||
gem.add_development_dependency 'fakefs', '~> 0.2.1'
|
gem.add_development_dependency 'fakefs', '~> 0.2.1'
|
||||||
gem.add_development_dependency 'rcov', '~> 0.9.8'
|
gem.add_development_dependency 'rcov', '~> 0.9.8'
|
||||||
gem.add_development_dependency 'rr', '~> 1.0.2'
|
gem.add_development_dependency 'rr', '~> 1.0.2'
|
||||||
gem.add_development_dependency 'rspec', '~> 2.0.0'
|
gem.add_development_dependency 'rspec', '~> 2.6.0'
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ class Foreman::CLI < Thor
|
|||||||
method_option :log, :type => :string, :aliases => "-l"
|
method_option :log, :type => :string, :aliases => "-l"
|
||||||
method_option :port, :type => :numeric, :aliases => "-p"
|
method_option :port, :type => :numeric, :aliases => "-p"
|
||||||
method_option :user, :type => :string, :aliases => "-u"
|
method_option :user, :type => :string, :aliases => "-u"
|
||||||
|
method_option :template, :type => :string, :aliases => "-t"
|
||||||
method_option :concurrency, :type => :string, :aliases => "-c",
|
method_option :concurrency, :type => :string, :aliases => "-c",
|
||||||
:banner => '"alpha=5,bar=3"'
|
:banner => '"alpha=5,bar=3"'
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ private ######################################################################
|
|||||||
def options
|
def options
|
||||||
original_options = super
|
original_options = super
|
||||||
return original_options unless File.exists?(".foreman")
|
return original_options unless File.exists?(".foreman")
|
||||||
defaults = YAML::load_file(".foreman")
|
defaults = YAML::load_file(".foreman") || {}
|
||||||
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,12 @@ private ######################################################################
|
|||||||
puts "[foreman export] %s" % message
|
puts "[foreman export] %s" % message
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_template(name)
|
def export_template(exporter, file, template_root)
|
||||||
File.read(File.expand_path("../../../../data/export/#{name}", __FILE__))
|
if template_root && File.exist?(file_path = File.join(template_root, file))
|
||||||
|
File.read(file_path)
|
||||||
|
else
|
||||||
|
File.read(File.expand_path("../../../../data/export/#{exporter}/#{file}", __FILE__))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_file(filename, contents)
|
def write_file(filename, contents)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
|
|||||||
app = options[:app] || File.basename(engine.directory)
|
app = options[:app] || File.basename(engine.directory)
|
||||||
user = options[:user] || app
|
user = options[:user] || app
|
||||||
log_root = options[:log] || "/var/log/#{app}"
|
log_root = options[:log] || "/var/log/#{app}"
|
||||||
|
template_root = options[:template]
|
||||||
|
|
||||||
Dir["#{location}/#{app}*.conf"].each do |file|
|
Dir["#{location}/#{app}*.conf"].each do |file|
|
||||||
say "cleaning up: #{file}"
|
say "cleaning up: #{file}"
|
||||||
@@ -19,14 +20,14 @@ class Foreman::Export::Upstart < Foreman::Export::Base
|
|||||||
|
|
||||||
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
|
concurrency = Foreman::Utils.parse_concurrency(options[:concurrency])
|
||||||
|
|
||||||
master_template = export_template("upstart/master.conf.erb")
|
master_template = export_template("upstart", "master.conf.erb", template_root)
|
||||||
master_config = ERB.new(master_template).result(binding)
|
master_config = ERB.new(master_template).result(binding)
|
||||||
write_file "#{location}/#{app}.conf", master_config
|
write_file "#{location}/#{app}.conf", master_config
|
||||||
|
|
||||||
process_template = export_template("upstart/process.conf.erb")
|
process_template = export_template("upstart", "process.conf.erb", template_root)
|
||||||
|
|
||||||
engine.processes.values.each do |process|
|
engine.processes.values.each do |process|
|
||||||
process_master_template = export_template("upstart/process_master.conf.erb")
|
process_master_template = export_template("upstart", "process_master.conf.erb", template_root)
|
||||||
process_master_config = ERB.new(process_master_template).result(binding)
|
process_master_config = ERB.new(process_master_template).result(binding)
|
||||||
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
|
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.18.0"
|
VERSION = "0.19.0"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,4 +21,19 @@ describe Foreman::Export::Upstart do
|
|||||||
File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
|
File.read("/tmp/init/app-bravo.conf").should == example_export_file("upstart/app-bravo.conf")
|
||||||
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
|
File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("upstart/app-bravo-1.conf")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with alternate templates" do
|
||||||
|
let(:template_root) { "/tmp/alternate" }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FileUtils.mkdir_p template_root
|
||||||
|
File.open("#{template_root}/master.conf.erb", "w") { |f| f.puts "alternate_template" }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can export with alternate template files" do
|
||||||
|
upstart.export("/tmp/init", :template => template_root)
|
||||||
|
|
||||||
|
File.read("/tmp/init/app.conf").should == "alternate_template\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ def example_export_file(filename)
|
|||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
Rspec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.color_enabled = true
|
config.color_enabled = true
|
||||||
config.include FakeFS::SpecHelpers
|
config.include FakeFS::SpecHelpers
|
||||||
config.mock_with :rr
|
config.mock_with :rr
|
||||||
|
|||||||
Reference in New Issue
Block a user